Main window of the Expert Advisor


The primary task of the Expert Advisor is to decrease a drawdown and close all orders opened by other Expert Advisors or manually. It has also built-in functions for usual trading, so it can be used as a basic tool for making money.

The principle behind its strategy:

All the actions performed by the Expert Advisor are controlled by built-in trend indicators,


but, as practice has shown, many users disable these indicators to accelerate a process of “settlement” (i.e. closing an order or orders in profit). It’s up to you to decide whether it is good or not. Personally, I watch the Expert Advisor’s trading during my spare time. If I have my spare time to connect to a VPS server frequently and look at the market situation, I disable the indicators and let the Expert Advisor accumulate a larger volume. If I don’t have an opportunity to look at my account balance during a week or a longer time, I enable a pair of indicators to control actions performed by the Expert Advisor.


If you enable all the indicators, the process of “settlement” may go on for years. So, test the Expert Advisor in a Strategy Tester before you enable the indicators and make a decision about how much indicators you need and what timeframes you should use for them. (When running the Expert Advisor for the first time, all indicators will be enabled so that you cannot set orders by mistake.)

Usual trading


When pressing Buy, Sell or BuyStop, SellStop buttons, the corresponding order of the predetermined lot size will be immediately set. These stop orders will be opened at the pre-set distance from a price (in this case the distance equals to 5 points).

auto buttons

If you press the auto button above the Buy or Sell buttons, the corresponding market positions will be opened automatically in accordance with a direction shown by the indicators, if only there are no positions opened in the given direction.


There are no open positions for the given currency pair.

All the indicators have been disabled (buttons have been pushed off)

If auto buttons above the Buy or Sell buttons have been pressed, Buy and Sell positions will be simultaneously opened.

If the indicators have been enabled, positions will be opened in case of coincidence of all the indicators’ readings regarding a price direction.

tral order button

If you press the button, two stop orders will be always opened at the high/low of candles on the timeframe specified in input parameter (“TF_Tral_Candle”) regardless of the indicators’ readings, but at a distance from a current price not closer than that set on the info panel (in this case the distance equals 5 points). If a price goes lower then, a SellStop order will not move on, and a BuyStop order will move downwards following the price based on the candles on the timeframe specified in the “TF_Tral_Candle” parameter. When the SellStop order triggers, a new SellStop order of a predetermined lot size will be placed 5 pips lower than a current price or below the last candle low.

Closing in profit

The function is set by AllSumProfit parameter – a percentage of profit necessary to close all orders.

However, you would better set the function directly in the inputs window of the Expert Advisor. If set to 0, the function will be disabled.


On the left side of the inputs window (it is highlighted in yellow)

The function works, if only there are no open locking positions.


There are several open Buy orders. Profit has been set as a percentage value (0,5%) of deposit ($50).


As soon as their total profit equals $50, all the open orders will be closed.


In this case the profit amounts to a little more than $50 ($52,61): this is due to the fact that a price jumps higher and the orders are closed with a small delay. Such a delay can have a negative effect on your trading results, so I don’t recommend you to set a too small profit: it is also true for minimum profit necessary for closing locking and averaging orders.

Closing distant losing orders

If there are several opposite positions opened for a current currency pair, a function of “settlement” will come into action.

The Expert Advisor will start its work by searching for orders placed far away from a current price and attempt to close them on account of profit of other orders. You can specify a certain order by setting its ticket in the Expert Advisor’s inputs – in that case the Expert Advisor will “settle” (i.e. close an order or orders in profit) it and stop its work. If 0, the Expert Advisor will search for distant orders by itself.


In this case the Expert Advisor “settles” a Buy position (ticket 7) and a Sell position (ticket 18).

Loss is total loss of a position, and Lot is its total size. Close shows the loss for that part of a position, which we want to close. LotClose is a lot size of a losing position, which we close. Profitable locking orders, on account of which a part of a losing position will be closed, are listed below.

The Expert Advisor will close orders in a number of ways:

  1. Averaging orders against a trend.

In this case the averaging is made in an unusual way: we average the whole order by the use of other orders of huge lots and thereby increase the drawdown. The Expert Advisor will split a losing order into several parts (the number of parts is set in its inputs) and start to close every part separately. Of course, it will take much more time to do it than to close the whole order. On the other hand, the drawdown will be much less. The Expert Advisor will close orders of both directions simultaneously, i.e. it will “settle” Buy (the upmost) and Sell (the undermost) orders simultaneously. The orders intended for “settling” other orders will be placed depending on the indicator’s readings.

A lot size that we “bite out of” a losing position and the first averaging order are set in the input parameters. Each subsequent trade will be placed at a specified distance from an open price of a previous trade, and lot size will be multiplied by a coefficient.


If the indicators are enabled, all averaging orders will be placed in case of coincidence of all the indicators’ readings regarding a price direction.

If you press the auto button, the function will be disabled at the predetermined level of loss (in our case the level equals 50%) and forcibly enabled at the lower level of loss.

  1. Locking

The Expert Advisor will protect your deposit from the drawdown by the use of locking orders. Locking is enabled manually by pressing the “Lock” button or forcibly, if the drawdown on the given currency pair hits a critical percentage value of the deposit set in the inputs (50% by default). Lock orders are not placed all at once, but in a distributed manner. Moreover, they are distributed not only by the price (grid), but by lots too. At first, the Expert Advisor will measure a misbalance between Buy and Sell orders. Let’s assume that we have 10 lots for Buy orders and 25 lots for Sell orders. There is the misbalance of 15 lots on the Buy side. The Expert Advisor will divide the misbalance in the predetermined number of parts, for example, 10. Afterwards, it will analyze direction of the price movement using the built-in indicator’s readings and place the first lock order of 1.5 lots in this direction. If the price keeps going up, then the second order of the lot equal to (15-1.5)/10 = 1.35 lots will be placed at a distance specified in the inputs. Therefore, the lots of the lock orders will be decreasing, until the difference in lot size between Buy and Sell orders disappears.

If the indicators are enabled, all locking orders will be placed in case of coincidence of all the indicators’ readings regarding a price direction.

If you press the auto button, the function will be enabled forcibly at the predetermined level of loss (in our case the level equals 50%) and disabled at the lower level of loss.

  1. Closing orders in the direction of a trend

The Expert Advisor will analyze the possibility of using profitable orders for closing a losing order, which is far away from a current price. For example, we have 5 Buy open orders, which total profit is 15$, and a far-away Sell open order, which loss amounts to 10$. The Expert Advisor will close the far-away order and 5 profitable orders and thereby decrease the drawdown and trading volumes of open orders. Orders are closed in case if only profitable orders are in the same direction as a trend is. It is necessary so that the Expert Advisor can eliminate the misbalance by the lock orders at once. In addition, the losing order can be also split into several parts, if the value set in the “LotClose” (“the number of parts, into which the lot of losing trade is divided”) input parameter is greater than 1.

Orders are closed in the direction of a trend and on the basis of averaging allowing for a profit from “closing locking and averaging orders”.

  1. Trailing stop

If you enable trailing, the Expert Advisor will gradually close orders in profit. At that the trailing will work based on the built-in indicators’ readings too. The trailing will be disabled, while the indicators show that the price goes in the direction, in which the profit grows. As soon as the price starts to reverse, the trailing will be enabled, and profitable orders will be closed thereby decreasing the lot size and increasing the profit.

The Expert Advisor has many indicator functions:


– “ls” — a button for displaying distant orders

The button opens a window, in which the most distant orders currently being “settled” by the Expert Advisor are displayed.

– “or” – a button for analysis of open orders

By pressing the button the Expert Advisor will display information above each order about its lot size, profit and comments.

– “nl” – a break-even button

By pressing the button the Expert Advisor will display break-even levels for certain orders and a total break-even level.

– “pr” – a button for displaying input parameters

The button opens the inputs window, in which the inputs can be changed. The changed inputs will be automatically imported from global variables, so you will not able to change default values of the inputs without removing the global variables. It allows you to set up the inputs once and not change them in the new versions of the Expert Advisor.

– button for trading history analysis

By pressing the button a window, where you can see trading results of the Expert Advisor over 2 days, a week and a month, will be displayed.

– button for scrolling back trading results of the Expert Advisor

By pressing the button a window, where actions performed by the Expert Advisor on a current currency pair are described in a chronological order, will be displayed.

Terms of Use:

The Expert Advisor will operate on a demo account and in a Strategy Tester. If you wish to use it on a real account, you need to purchase it.

The cost of linking the Expert Advisor to one account is 75$.

The cost of linking the Expert Advisor to your name (i.e. to all your accounts opened in your name) is 250$.

You can also get the Expert Advisor via an affiliate program. This requires opening an account via one of the affiliate programs listed on the web-page – – and replenishing it for no less than $100.

If you wish to get the Expert Advisor, contact me via e-mail or Skype:

Skype: mqlcmillion

Update Advisor: version 140317


1) Added the option of allowing Locke to put orders inside the positions, not just above or below the extreme SetLockN=true
2) Added arrow indicators when you turn off the buttons
3) Removed dotted stripes that extend to the orders! ShowLineOrders=false
4) Fixed window ls the amount of issued option Loss
5) Changed the size of the profit figures for the areas now the higher the value, the smaller the font size. (so that large amounts do not have nalazili each other)
6) Put the figure of imbalance on lots in the direction of the imbalance indicated by color (red/blue)
7) Added button closing orders (all buy, sell)
8) Added option allowing to set the pending order closer than MinStepStopOrdes from open positions to avoid overlapping position to each other.
if you set MinStepStopOrdes = 0 then everything will be as before
9) Added a button for cleaning the screen
10) changed the timeline to auto switch to lock and back is not scored it all.


Video of the adviser working in the tester:

To get an adviser on a real account, please contact us by email

209.6 KiB