Update version 15.4
I fixed the moment when a stop order with a large lot remained in the market after taking a profit.

The principle behind the strategy:

The sytem will set a grid of orders at the pre-set distance (set by “Step” parameter) from each other. It will place SellLimit orders above and BuyLimit orders below the current price. Lot size of the order, which is the closest to the current price, can be set by “Lots” parameter or set as a percentage of free margin by “RiskPercent” parameter. The further orders will have a lot size multiplied by a coefficient (set by “K_Lot” parameter). The maximum lot size will be limited by “Max_Lot” parameter. The idea behind the strategy is that the price can not move in one direction for ever without pulling back.
If we make an incorrect forecast of the market entry direction, then the one-direction orders will be averaged and closed in profit upon the next price pullback.

Let’s consider an example of a trade:


On the first screenshot you can see that the Expert Advisor sets orders in both directions from the current price. Notice that at that it has opened two opposite orders – Buy and Sell orders – at once.


The price goes down, and the Sell order is closed by take-profit. At that several Buy orders are opened. Since the lot size of Buy orders increases as the price goes downwards, a break-even point total for a series of Buy orders approaches to the current price every time the lot size increases. When the price makes a minor pullback upwards, we take profit after the entire series of Buy orders closes.


Afterwards the price goes a rather long distance downwards again. At that several subsequent Sell orders are closed in profit. When the price makes a pullback upwards again, a series of Buy orders is closed in profit again.

After each close of a series of one-direction orders by total profit, limit-orders of the same direction will be deleted, and a grid of orders of the direction that has been closed will be set again.

The most frightful thing for the Expert Advisor will be a long-sustained pullbackless trend that is established, when global economic problems arise. “OrdersNoTP” parameter will act as an insurance against this pullbackless trend. It enables setting that number of open positions, at which positions of the opposite direction stop to be closed by profit and support positions of this direction that experience a drawdown. If we have 10 open Buy positions (“OrdersNoTP=10”), then open Sell positions will not be closed by profit.

Take-profit will be set from the break-even point total for one-direction orders. Its size can be changed by the Expert Advisor depending on the number of orders. That is, if “деление_профита = true” and “Takeprofit=10”, then take-profit of the first order will be set at the distance of 10 points from the total break-even point, take-profit of the second order will be set at the distance of 5 points, etc. Thus, the more positions are opened in the given direction, the closer the take-profit of these positions will be moved by the Expert Advisor to the current price. However, the entire series of one-direction orders will be always closed in profit.

The Expert Advisor enables setting its time of autotrading, for example: TimeStart= 10, TimeEnd = 22, FridayHourClose = 16. It follows that the Expert Advisor will set new series of orders only from 10 a.m. to 10 p.m. all days except Friday (it will work only up to 4 p.m. on Friday).

In order to get similar results, you need to optimize the Expert Advisor. You can read how to do this here: https://cmillion.ru/optimization/
The cost of the Expert Advisor is 50 USD. Payment methods: https://cmillion.ru/en/pay/


extern int     Step           = 20;    //расстояние между открываемыми ордерами в сетке ордеров  
extern double  Lots           = 0.0;   //если=0 то лот будет расчитан как процент от свободных средств по RiskPercent %  
extern double  RiskPercent    = 0.01;  //Lots = AccountBalance() * (RiskPercent / 100.0) / 10000.0 
extern double  K_Lot          = 1.5;   //умножение лота  
extern double  Max_Lot        = 50;    //ограничение размера лота 
extern int     DigitsLot      = 2;     //кол-во знаков после запятой в размере лота (2 - 0,01) (1 - 0,1) 
extern int     OrdersNoTP     = 5;     //кол-во ордеров, после которого запрещаем выставлять тейкпрофит прибыльному паправлению 
extern double  ProfitClose    = 50;    //прибыль в валюте депозита, при которой закрываем все ордера. 
extern int     Takeprofit     = 35; 
extern bool    деление_профита = true;   //ТР делится на кол-во колен 
extern bool    VirtualTS      = false; //выставлять виртуальный или реальный тралл  
extern int     TrailingStop   = 0;     //если 0 то нет тралла стоплоссов  
extern int     OrdersTek      = 3;      //текущее цисло отложек, применяется для снижения нагрузки на ДЦ 
extern string   _____________  = "Filter Time"; 
extern int     TimeStart       = 0 ,    //ограничение времени работы советника 
               TimeEnd         = 24,    //не открываем ордера и закрываем отложки если время не между TimeStart и TimeEnd 
               FridayHourClose = 16;    //час закрытия ордеров в пятницу

In the updated version 13(14) added trading stop orders together with limit.

48.7 KiB
Version: 15.4
58.4 KiB