Exp4 Close Minus by Plus
Covers losing positions by identifying and closing winning positions.
This assistant looks for the most loss-making position among all positions in the terminal.
Further, by searching for other positions, it calculates a series of orders that can cover the loss and closes them.
The series of orders can include any position. The maximum number of positions is specified in the settings of the Expert Advisor.
You can test the Expert Advisor in the strategy tester and trade with our EAPADPRO toolbar in visual mode!
- TypeOfUnitToClose - type of profit and loss calculations. In USD or in points.
- MinLossInUnit - the minimum loss of a position in units (TypeOfUnitToClose), to be taken into account by the EA.
- An order with a loss of "MinLossPoss_in_unit" units (USD or points), should be placed in the negative zone.
- It is the upper limit when searching for unprofitable positions.
- For example: MinLossInUnit = -100, TypeOfUnitToClose = USD.
- Then the EA looks for or waits for a position with a loss greater than or equal to -100 USD, for example: -100 USD, -150 USD, -200 USD and so on.
- A position with a loss of -99 USD is ignored.
- AdditionalProfitInUnit - the amount of profit units for the difference to close a set of positions.
- Position (or several) with the total profit exceeding the loss by "AdditionalProfitInUnit" units.
- For example: AdditionalProfitInUnit= 10, MinLossInUnit= -100, TypeOfUnitToClose = USD.
- The EA will look for or wait for at least 2 positions, where one position has a loss of -100 USD and the other has a profit of +110 USD. At this point, the EA decides if it is necessary to activate its functions.
- MaxPos_in_Class - the "MaxPos_in_Class" parameter should limit the number of positions of the entire closing "set".
- For example: MaxPos_in_Class = 3, then the EA will look for a closing set with 3 positions at most (1 unprofitable and 2 profitable ones).
- FirstSymbolClose - search for position pairs and close only those in the currency of the currently processed losing position.
- You can disable the FirstSymbolClose, parameter. Then the EA will close any sets of losing and profitable positions on the entire account, regardless of the currency pair included in calculation.
- When the FirstSymbolClose function is enabled, the EA considers and closes sets of the same currency pair.
- OrderToClose - type of positions: -1 = All Orders, 1 = Sell, 0 = Buy;
- MagiсToClose - magic number of positions: -1 = any, or you can specify a unique magic number of your positions to be processed.
- SymbolToClose - currency pair to monitor: -1 = All Symbol, 1 = Current Symbol;
- Dear friends and users of our EAs, please add your ratings in the Reviews section.
- All updates to our forex software are free!
- Developer of forex tools: Expforex
Operation of the Expert Advisor
The operation involves attaching the Expert Advisor to a separate chart, making the necessary settings and continuing to work in our terminal. When the programmed condition triggers, the Expert Advisor comes into play and starts making calculations.
All calculations are written to the log, as follows:
2014.02.05 01:18:38.408 - Exp - CloseMinusByPlus USDCHF,H1: close #22079015 sell 1.00 EURUSD at 1.35141 at price 1.35119 2014.02.05 01:18:38.346 - Exp - CloseMinusByPlus USDCHF,H1: Tickets of prof positions: .22079015 2014.02.05 01:18:38.346 - Exp - CloseMinusByPlus USDCHF,H1: close #22085491 sell 1.00 USDCHF at 0.90423 at price 0.90430 2014.02.05 01:18:38.283 - Exp - CloseMinusByPlus USDCHF,H1: Tickets of loss positions: 22085491 2014.02.05 01:18:38.283 - Exp - CloseMinusByPlus USDCHF,H1: Numbers of positions to Close: 80635972 2014.02.05 01:18:38.283 - Exp - CloseMinusByPlus USDCHF,H1: All profit from open positions: 20 dollars 2014.02.05 01:18:38.283 - Exp - CloseMinusByPlus USDCHF,H1: Maximim profit ticket: 22079015 2014.02.05 01:18:38.283 - Exp - CloseMinusByPlus USDCHF,H1: Maximim profit: 20 dollars 2014.02.05 01:18:38.283 - Exp - CloseMinusByPlus USDCHF,H1: Maximum Loss ticket: 22085491 2014.02.05 01:18:38.283 - Exp - CloseMinusByPlus USDCHF,H1: Maximim loss: -7 dollars 2014.02.05 01:18:38.283 - Exp - CloseMinusByPlus USDCHF,H1: Overlapping loss positions by closing profitable positions started using the currency pair minus:
- Additional languages added to the panel: Spanish, Portuguese (Brazil), German, Chinese, Japanese;
The translation was made using the GOOGLE Translator + MQL + Terminal site!
if you find an error in your language, please report it in messages. Thank!
- Increase the speed of the panel;
- Renamed the parameters:
TypyClose = TypeOfUnitToClose
MinLossPoss_in_unit = MinLossInUnit
ProfitPerLoss_in_unit = AdditionalProfitInUnit
MagikToClose = MagicToClose
Details on the panel in our blog: https://www.mql5.com/en/blogs/post/687140
MinLossPoss_in_unit - should be set in the negative zone. This is the upper limit when searching for unprofitable positions.
If the parameter is set to MinLossPoss_in_unit=-10, then the unprofitable trade (covered by the profitable ones) must be less than -10 dollars (points)
MinLossPoss_in_unit = parameter that limits the EA operation if the negative trade is greater than the MinLossPoss_in_unit. For example, when opening a trade, it profit = -spread.
The algorithm works if there are 2 or more positions to be closed.
- Added enumerations to select calculation and close type.