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).

Results of backtesting in Strategy Tester


Limit_9_10000_01-02-2013 по 29-10-2013

Limit_9_10000_01-01-2014 по 01-08-2014

Real Account Statement:

This is a demo-version of the Expert Advisor. You may use it in a Strategy Tester and on demo accounts without any limits. You need to enter a key to start trading on a real account. Learn more ….

There is a topic about the Expert Advisor on the MT5 forum, where you can find more details of its operation, discussion and all its improvements.


extern int     Step           = 20;   //distance between orders opened within a grid of orders
extern double Lots           = 0.0;   //if=0, then lot size will be calculated as a percentage of free margin set in “RiskPercent %” parameter
extern double RiskPercent   = 0.01; //Lots = AccountBalance() * (RiskPercent / 100.0) / 10000.0
extern double K_Lot         = 1.5;   //lot multiplier
extern double Max_Lot       = 50;   //limits a lot size
extern int     DigitsLot     = 2;     //number of decimal places in the lot size (2 - 0,01) (1 - 0,1)
extern int     OrdersNoTP     = 5;     //if this number of orders is exceeded, the Expert Advisor is disallowed to set a take-profit for profitable one-direction orders
extern double ProfitClose   = 50;   //profit in deposit currency, by which all orders will be closed
extern int     Takeprofit     = 35;
extern bool   деление_профита = true;   //take-profit will be divided in a number of open orders
extern bool   VirtualTS     = false; //enables a virtual or a real trailing stop
extern int     TrailingStop   = 0;     //if 0, then stop-losses will not be trailed
extern int     OrdersTek     = 3;     //number of open pending orders; it is used to reduce a load on a dealing center

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

48.7 KiB
49.2 KiB