Exp5 Close Minus by Plus for MT5
- Utilities
- Vladislav Andruschenko
- Version: 24.918
- Updated: 18 September 2024
EA can close unprofitable positions by searching for and closing profitable positions.
This assistant looks for, among all positions, the most unprofitable position in the terminal.
Further, by searching for the remaining profitable positions, he calculates a series of positions that can cover the loss when the profit of one or more positions is greater than the loss of another position.
If a set of such positions is found, then the adviser closes them.
A series of positions can consist of absolutely any position.
Their maximum number is adjustable in the advisor settings.
You can also specify the minimum loss for the search and additional profit for closing.
MT4 version | Full Description | How To Buy | How To Install | How to get Log Files | How To Test and Optimize | All products from Expforex |
You can test the Expert Advisor in the strategy tester and trade with our EAPADPRO toolbar in visual mode!
How Close Minus by Plus works on the Chart
Suppose
- You open a BUY #1 position at a price of 1.600 ;
- The Price goes down to 1.550, and the current loss is -50 points;
- Breakeven point(Average Price) = 1.600 ;
- If we open SELL #2, Sell #3, and Sell #4;
- Expert Advisor starts executing the main algorithm.
- Then the total profit will be +5 $;
- The Expert Advisor (EA) activates the algorithm, and 4 positions must be closed.
Operation of the Expert Advisor
The operation involves attaching the Expert Advisor to a separate chart, making the necessary settings, and continuing to work on 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:
close #22079015 sell 1.00 EURUSD at 1.35141 at price 1.35119
Tickets of prof positions: .22079015
close #22085491 sell 1.00 USDCHF at 0.90423 at price 0.90430
Tickets of loss positions: 22085491
Number of positions to Close: 80635972
All profit from open positions: 20 dollars
Maximum profit ticket: 22079015
Maximum profit: 20 dollars
Maximum Loss ticket: 22085491
Maximum loss: -7 dollars
Overlapping loss positions by closing profitable positions started using the minus:
Settings
Name | Description |
---|---|
TypeOfUnitToClose | Type of profit and loss. In dollars or points(Pips) |
MinLossInUnit | Minimum loss of position in units ( TypeOfUnitToClose ), which is taken into account by the Expert advisor. An order with a loss in the “MinLossPoss_in_unit” units (dollars or points) must be set in the negative zone. This is important for finding loss-making positions. For example: MinLossInUnit = -100 TypeOfUnitToClose = dollars, then the EA looks for or expects a position at a loss greater than or equal to -100 dollars, for example, -100 dollars, -150 dollars, -200 dollars, and so on. The position with a loss of -99 dollars is already ignored. |
AdditionalProfitInUnit | The number of units of profit for the difference in the closing of the set of positions. Position (one or several deals) with a total profit exceeding the loss on the ” AdditionalProfitInUnit ” units. For example: AdditionalProfitInUnit = 10 MinLossInUnit = -100 TypeOfUnitToClose = dollars: The advisor is looking for or waiting for at least 2 positions, one of which is at a loss of -100 dollars and the second with a profit of +110 dollars. If such positions(Deals) are found, then the Expert Advisor(EA) will close these positions(Deals). |
MaxPos_in_Class | The parameter “MaxPos_in_Class” should limit the number of profitable closing positions. For example: MaxPos_in_Class = 3, then the Expert Advisor (EA) will look for a set to close from a maximum of 3 profitable positions +1 unprofitable. |
FirstSymbolClose | Search for pairs of positions and close only the currency pair that we are processing. You can turn off (false) FirstSymbolClose parameter; then, the EA will close any pair from the losing and profitable positions in the entire account, regardless of which currency pair is included in the calculation. When you turn on (true) FirstSymbolClose – the expert advisor monitors and closes a series of positions from one currency pair. |
OpenHoura OpenMinutea | The start time of the Expert Advisor |
CloseHoura CloseMinutea | The end time of the Expert Advisor |
OrderToClose | Positions type: -1 = All Orders, 1 = Sell, 0 = Buy |
MagicToClose | Magic Number of positions: -1 = any magic numbers. Or you can specify a unique magic number of its positions, which should be processed. You can specify multiple magic numbers separated by commas. For example: 777,888,999 |
SymbolToClose | The currency pair for monitoring -1 = All symbols 1 = Only the current symbol (the symbol that EA is installed) You can write a list of currency pairs separated by commas. For example, EURUSD, USDCHF, USDJPY |
Thank you for the good work!!! Keep up the good work!!!