Exp Averager is inended for averaging your deals that have had a drawdown and have gone against the trend. After a specified number of points equal to Distance, our Expert Advisor opens a position in the same direction with the volume equal to "Volume of he previous deal" * LotsMartin. The Expert Advisor also modifies the general take profit on all deals moving it to the level of "Zero line point of all the positions in the same direction" + TakeProfit points.
It also can modify the stop loss of all positions (if TrailingStopUSE=true), when the price breaks the level of "Zero line point of all the positions in the same direction" at a distance of TrailingStop points.
The Expert Advisor settings includes an option, in which you can set the maximum number of positions opened for averaging (MaxOrdersOpen).
The Expert Advisor works on the currency pair to which chart it is attached. For example, to enable the averaging for EURUSD, open the EURUSD chart and run the Expert Advisor.
You can also restrict the averaging for some order types (OrderToAverage) and the magic numbers of the orders (MagikToAverage).
This Expert Advisor can be tested in the strategy tester of the terminal. For the test, one buy position of 0.1 lot will be opened when you start the EA.
- MaxOrdersOpen - the maximum number of opened orders, 0 - unlimited.
- TakeProfitALL - total take profit for modification.
- AllTradeTrail - Allow modification of trailing stop\breakeven\take profit for all trades, including the ones opened by user. On the given currency pair.
- Distance - distance for the opened grid positions for opening against the trend.
- DistanceMartin - increase\decrease the distance for the next position in the grid. Martingale for distance.
- StopLoss - stop loss for the averaging trade against the trend.
- LotsMartin - volume increase for the grid of positions against the trend.
- LotAdditional - additional lot for an averaged position against the trend.
- LotMax - maximum averaging lot against the trend.
- SleepForOpenbetweenLastClose - delay in minutes for opening averaging trades after a trade is closed.
- OpenOnly1ofBar - allows opening only 1 averaging\additional trade per bar (depends on the current TF).
- OrderToAverage - the type of orders. -1 - all orders, 1 - Sell, 0 - Buy.
- MagikToAverage - the magic number of the orders, -1 - all orders.
- TrailingStopUSE - use trailing stop.
- TrailingStop - trailing distance, 0 - the minimum allowed.
- TrailingStep - trailing step.
- MovingInWLUSE - enable breakeven when opening averaging\additional trades
- LevelWLoss - distance from the price for placing stop loss
- LevelProfit - distance in profit after which the breakeven is set at LevelWLoss points.
- ADDITIONALDistance - the distance for additional positions opened for the grid - additional opening based on the trend.
- ADDITIONALDistanceMartin - increase\decrease the distance for the next position in the grid for opening additional positions based on the trend. Martingale for distance.
- ADDITIONALStopLoss - stop loss for the additional trades opened based on the trend.
- ADDITIONALLotsMartin - increase the lot for the grid of positions for opening additional positions based on the trend.
- ADDITIONALLotAdditional - additional lot for the additional positions.
- ADDITIONALLotMax - maximum lot for opening additional positions.
Example of the Expert Advisor operation:
Distance = 100 points, take profit = 250 points, LotsMartin = 2.
2 2013.01.02 09:00 modify 1 0.10 1.32732 0.00000 1.32982 0.00 10000.00
3 2013.01.02 11:27 buy 2 0.20 1.32632 0.00000 0.00000 0.00 10000.00
4 2013.01.02 11:27 modify 1 0.10 1.32732 0.00000 1.32915 0.00 10000.00
5 2013.01.02 11:27 modify 2 0.20 1.32632 0.00000 1.32915 0.00 10000.00
6 2013.01.02 12:20 buy 3 0.40 1.32532 0.00000 0.00000 0.00 10000.00
7 2013.01.02 12:20 modify 1 0.10 1.32732 0.00000 1.32839 0.00 10000.00
8 2013.01.02 12:20 modify 2 0.20 1.32632 0.00000 1.32839 0.00 10000.00
9 2013.01.02 12:20 modify 3 0.40 1.32532 0.00000 1.32839 0.00 10000.00
10 2013.01.02 12:27 buy 4 0.80 1.32429 0.00000 0.00000 0.00 10000.00
11 2013.01.02 12:27 modify 1 0.10 1.32732 0.00000 1.32754 0.00 10000.00
12 2013.01.02 12:27 modify 2 0.20 1.32632 0.00000 1.32754 0.00 10000.00
13 2013.01.02 12:27 modify 3 0.40 1.32532 0.00000 1.32754 0.00 10000.00
14 2013.01.02 12:27 modify 4 0.80 1.32429 0.00000 1.32754 0.00 10000.00
15 2013.01.02 14:28 t/p 1 0.10 1.32754 0.00000 1.32754 2.20 10002.20
16 2013.01.02 14:28 t/p 2 0.20 1.32754 0.00000 1.32754 24.40 10026.60
17 2013.01.02 14:28 t/p 3 0.40 1.32754 0.00000 1.32754 88.80 10115.40
18 2013.01.02 14:28 t/p 4 0.80 1.32754 0.00000 1.32754 260.00 10375.40
Added block for opening additional positions based on the trend:
- ADDITIONALDistance - the distance for opening additional grid positions based on the trend.
- ADDITIONALDistanceMartin - the distance multiplier for opening additional positions based on the trend.
- ADDITIONALLotsMartin - increase the lot size of the grid positions for opening additional positions based on the trend
- ADDITIONALLotAdditional - additional lot for the additional position for opening additional positions based on the trend
- ADDITIONALLotMax = maximum lot to use when opening the averaging positions. 0 - disabled
- ADDITIONALStopLoss - Stop loss of the opening additional positions based on the trend
Added block for transferring the stop loss to breakeven.
Note: breakeven is set starting from the middle 0 line.
- MovingInWLUSE - transfer the position to breakeven;
- LevelWLoss - transfer the stop loss to +LevelWLoss points;
- LevelProfit - when the trade gains LevelProfit points of profit;
- Added the EAPADPRO information panel
Details on the panel in our blog:
The following data has been moved to the Strategy Info block:
BUY Average/Lot - Next averaging in points for BUY / Next averaging lot
SELL Average/Lot - Next averaging in points for SELL / Next averaging lot
Average Price Buy - Average price for BUY deals
Average Price Sell - Average price for SELL deals
Last Price Buy - The last known price of the lowest BUY trade
Last Price Sell - The last known price of the highest SELL trade
Last Lot Buy - The last known lot of the lowest BUY trade
Last Lot Sell - The last known lot of the highest SELL trade
If TakeProfitALL = 0, then take profit is not placed.
Added the OpenOnly1ofBar parameter
If OpenOnly1ofBar = true, the averaging positions will only be placed 1 time on the current bar. The parameter has been added in order to avoid opening multiple trades on 1 bar during the release of important news.
Delayed opening of the new averaging order after closing the last position, in seconds.
It allows you to delay before opening, if the positions are closed by another expert, for example CloseIfProfitorLoss with Trailing.
Added option MarketWatch
MarketWatch (true - false)
This option can be enabled for the accounts in the group consisting ECN \ NDD and \ or accounts that use Market execution.
Principle: In the accounts of the group of ECN \ NDD and \ or accounts that use Market execution is forbidden to open positions with established Stoploss \ Take Profit, but is allowed to open a position with a Stop Loss \ TakeProfit = 0, and at the same time after the successful opening of the modified position Stoploss on and \ or Take Profit
This feature, when turned on, first opens position, then sets Stoploss \ takeprofit for it.
Например: Если При расчете лота для усреднения
(начальный лот позиции 0.1 LotsMartin=2 и LotAdditional=0.1) сделка усреднения должна открыться как 0.3 лота и LotMax=0.2, то сделка откроется 0.2 лотом
At 4-digit brokers, a stop loss lagged behind the price. When modifying and enabling a trailing stop, all trades of one direction are modified by a common stop loss.
Previously, each position moved from the mid line on its own when a common trailing stop was enabled. This could occassionally affect the simultaneous position closing.
Added LotAdditional variable allowing you to add a lot to the one being opened. If LotAdditional=0, an ordinary lot is opened. If, for example, LotsMartin=1 and LotAdditional=0.5, each following averaging lot is equal to the last trade's lot + 0.5.