Open a position for EA MT5
- Utilitaires
- Konstantin Kulikov
- Version: 1.0
Hello everyone,
this is another utility that I wrote specifically for users using my profile with a large number of experts and sets (https://www.mql5.com/en/blogs/post/750723) .
This utility is useful for working with a profile using grid strategies (averaging and martingale). As we know, such strategies periodically fall into a large drawdown and you need to be careful when opening averaging positions (do not open too many). In my profile, I use a limit of 3 positions for each EA, if this was not enough to exit the drawdown, then the positions are against a strong trend and you need to choose a key level (the most likely for a rebound or trend reversal) to open the next position.
Consider the situation, some EA has opened 3 positions against the trend, then you do not want EA to continue averaging on its own, but you want to choose the price value at which to open the next position. To do this, you need:
- Attach the utility "Open a position for EA" to the chart of the symbol for which the drawdown.
- In the "Magic_positions" parameter, register the magic number of EA whose positions are in drawdown. This is necessary so that EA takes into account the open position of the "Open a position for EA" utility, this will allow EA to control all open positions and close them at the appropriate moment.
- Specify the desired trading lot size for the new position in the "Lots" parameter.
- Set the desired price to open the next position in the "Price_for_pending_order" parameter field. The type of orders will suit "ORDERS_LIMIT" (selected in the "Type_Orders" parameter), but in some situation "ORDERS_STOP" may be useful to you, or you can just instantly open a position at the current price (without taking into account the "Price_for_pending_order" parameter) - MARKET_BUY or MARKET_SELL.
That's all, I'll describe a few more additional parameters that may come in handy.
- "Comment_position" - comment for a new position/order, can be any (does not affect anything).
- "Allow_only_in_direction_open_positions" - if "true", it will allow you to open a position/order only in the direction of open positions (i.e. BUY or SELL). It's like insurance, so as not to accidentally open a trade in another direction.
- "Delete_order_if_position_opened" - if "true", the pending order will be deleted if a position with the specified magic number somehow opens (for example, EA will open a position according to its logic, or another pending order with this magic number will be trigger).
- "Remove_utility_after_execution" - if "true", the utility will be removed from the chart after performing its function.
Version for MT4: https://www.mql5.com/en/market/product/107311