This advisor is similar in idea to martingale, but not quite martingale. At first, I wanted to hide its logic, but I will introduce the fact that I will still have to partially disclose its characteristics with the settings and in one place I will have to specify its parameters so that buyers do not have confusion in logic, since programmers, in my opinion, differ slightly from ordinary people in their logic of thinking. and, for this reason, personally, I will try to reveal more about the work of this adviser in the description.
To begin with, I have set a limit on the full amount of the account balance for this adviser, and the adviser will open trades only until this amount of the established limit is sufficient for him to trade. Here you need to know that the margin call limit itself will not save you if the ADVISER goes into drawdown and does not open orders, but since he will incur a loss on his open trades, the adviser will eventually drain all the capital of your account anyway. And for this reason, there are situations in which it is better to provide an adviser to trade. You can disable the limit if you specify Limit - 1.0 (one) in the Advisor settings. The Limit parameter is the division of your account balance by the specified number. Let's say you have a balance of $10,000 in your account and if you specify the number 10.0 in the Limit field, the ADVISER will open its trades for $ 1,000, the rest of your account amount will serve as insurance for drawdown, since everyone knows that the price returns to where it was before and after a while everything will return to circles will return to normal and everything will work as it should. Patience.
Now why is the advisor not quite martingale? Because he has violated the original logic of this conclusion, and the adviser in his work has a completely different and purposeful logic. That is, if a martingale opens deals and increases its bet when a position is lost, then this ADVISER does the same, but after opening a deal, let's say to buy and without reaching the intended profit specified in the settings as the closeall parameter, where it will be necessary to specify the amount of profit, upon reaching which the adviser will close all transactions opened by the adviser and after going into a loss, into a drawdown, the adviser will wait for the following instructions specified in the settings, according to which everything that is specified as (Buy) will actually refer to sell orders - SELL, as the Adviser will try to close a previously opened buy order by opening sell orders, and the adviser will apply the martingale method to them. (By the way, this martingale parameter can also be disabled if you specify 1 unit in the specified parameters in the Adviser's settings, and then the adviser will open all orders with one lot specified in the settings). This is his basic logic. That is, if the adviser leaves at a loss on a previously opened order, for example, to buy, then in order to close this buy order with a profit, the adviser will try to open sell orders and the amount of sell orders must exceed the amount of the open buy order and its drawdown. And so, to close a buy order, the ADVISER uses a martingale by opening opposite orders to the first open order. There is another little-noticed logical detail here, that two open BUY and SELL orders will always interfere with each other when the current price fluctuates, and this is not always a bad thing, since if one order goes to a loss, let's say to buy, then the other sell order will go to profit and prevent the buy order from catching margincol. And this advisor uses this help for his own purposes. And you can use it yourself, for example, specify lot 0.5, specify another parameter of the opposite order 0.5, and specify the martingale as 2.0. What will happen then? And the following will happen: The first buy order will be opened with lot 0.5 and if the current price creeps up, then according to the profit specified in the settings, the adviser will close orders with profit and open them again. Here it should be added that the Expert Advisor works on time, the parameters of which are also available in the settings. And if you specify the ADVISER's working time from 0 o'clock to 10 o'clock and the price creeps up during this time, then all orders for the purchase of lot 0.5 will be closed with the profit specified in the settings. However, if, after opening a buy order, the current price does not reach the specified profit and turns around and begins its downward movement, then a sell order will be opened according to the specified parameters in the settings to close the buy order with a profit. In this situation, the sell order will be opened with a smaller lot than the first buy order was opened, which is bad, since we do not expect the buy order to close and an open sell order with a smaller lot will not close the buy order with a larger lot. So you need a martingale. Or at least a network of orders opened with one lot, but so that the amount of open sell orders is greater than the amount of an open buy order plus a drawdown. And then a sell order will open with a lot of 0.25 and if you specify 1 (unit) in order for a network of orders to open, and sell orders to open in the direction of the first open buy order, in any case, make a large distance between the first open buy order and the subsequent sell order that will try to close it. Also, if we open this sell order in a small lot, then in the worst case, we will need a network of orders, and subsequent sell orders will open above the first open sell order, and this also indicates a long distance... although everything will depend on the case of circumstances. Although, I must admit that currency pairs have price fluctuations and this is like a guide in the settings. That is, if you find fluctuations in the currency pair using the adviser's settings, then the adviser will always work for profit for plus minutes and a good broker will always warn you when a critical situation for the account comes and will offer to replenish the balance, as this circumstance is in his interests too. And, with this setup of the adviser, there is a possibility that the second open opposite order with a smaller lot will turn into a profit, and the drawdown of the first one will increase and the price will not be able to return for a very long time and start building a network of orders to close all orders with a profit. So everything is at the discretion of the owner of this advisor.
Then, what else do you need to know in the Advisor settings? That in terms of time, only the opening of the first order and the second opposite order works for him. That the close all parameter affects the closing distance of orders. This is a kind of profit. P.S.: There are logos-screenshots with the EURUSD currency pair with the H1 period, there are two logos: one with moderate settings of the Expert Advisor, and the other with more aggressive settings. You can look at them, compare them and come to some conclusions.
extern double Lots = 0.2; lot (price) at which the order will be opened
extern int TakeProfit = 300; this parameter does not work
extern int Slippage = 50; slippage
extern int Magic = 7777; the magic number of orders
extern int Magic2 = 7778; the magic number of orders
extern double closeall = 10.0; closing orders with profit
extern int morningBuy = 0; the time when the first buy order will be opened and if the current price
is If it turns around and goes into a drawdown, the Expert Advisor will
try to open opposite sell order to close the buy order
extern int eveningBuy = 10; the time before which two buy and sell orders will be opened
extern int morningSell = 0; the time when the first sell order will be opened and if the current
price is If it turns around and goes into a drawdown, the Expert Advisor
will try to open opposite buy order to close the sell order
extern int eveningSell = 10; the time before which two sell and buy orders will be opened
extern int StopDistanceBuy = 350; the distance of opening the second sell order from the opening price
the first purchase order
extern int StopDistanceSell = 1000; the distance of the opening of the second buy order from the opening
price the first sell order
extern int GridPitchBuy = 100; the distance from the last price of an open sell order,
if the first buy order is open
extern int GridPitchSell = 50; the distance from the last price of an open buy order
if the first sell order is open
extern double PowerClosureBuy = 2.0; increase in the lot of the second open sell order if
the first order was opened for purchase, then it is his lot that will
be increased by the specified number
extern double PowerClosureSell = 2.0; increase in the lot of the second open purchase order if
the first order was opened for sale, then it is his lot that will be
increased by the specified number
extern double IncreaseBuy = 2.0; increase of the third and subsequent sell orders if
The first order was opened to buy
extern double IncreaseSell = 2.0; an increase in the third and subsequent buy orders if
the first order was opened for sale
extern double Limit = 10; the number by which the account balance and the amount received will be
divided It will be provided to the Expert Advisor for trading. It should
be noted here, that the lower the specified number, the amount provided
There will be more Expert Advisor for trading. Let's say the number 2
will be indicate what will be provided to the Expert Advisor for trading
half of the open account balance. To disable this option
it is necessary to specify - 1 (unit)
P.S.: In the last screenshot, the EURUSD pair, with a period of H1, is indicated at the top in the settings of the adviser how you can manipulate the price setting... There, when I was checking the Expert Advisor in the strategy tester, I noticed that sell orders are closed late with one order or a network of buy orders, and here I increased the PowerClosureSell parameter to 3.0, that is, this parameter increases the lot of the second opposite order in order to try to close the first order with an increased lot. Here, the first sell order is Sell with lot 0.1, which means Buy purchase will be opened with lot 0.3... What happened in this case? What happened is that we shortened the distance to achieve the set goal and reduced the trend distance for ourselves, since we assume and do not assume that the upward trend will be long, it is better to close the orders earlier - before the upward trend changes to a downward trend and then we will have to open a network of orders to try to close this first one a sell order.