The idea behind this Expert Advisor comes from a simple mathematic formula. The Expert Advisor places two opposite orders. When the price moves in some direction, the former order will always have a positive result, and the latter order will have a little more (by the value of a spread) negative result.

If we average it, then the averaging orders are closed, excepting only the winning order, when the price goes in the opposite direction (for only a few spreads)!

You will receive a profit (due to which the Expert Advisor trades) from the winning order and, of course, the averaging orders (especially if you make use of rebate programs that repay a part of spread to you).

Parameters:

TF – a timeframe of a candlestick chart used to identify trend direction (it is set in minutes – 1, 5, 15, 30, 60, 240 …)

MinStep – minimum step between orders (the value is increased by 10 times, when using 5- and 3-digit trading terminals)

Lot – if it is equal to 0, then the lot size will be calculated as a percentage of free margin for risk %.

risk – percentage of free margin

K_Martin – a coefficient by which the lot size is multiplied for each subsequent trade (you can set the value to 1 to disable lot increase and reduce the load on deposit)

MA – MA filter (orders are placed based on MA: if the price is above the MA, then buy orders are placed and vice versa; if set to 0, then the filter is disabled)

Magic – unique order number of the given Expert Advisor

DrawInfo – displays information on the terminal screen

DigitsLot – lots of orders to be rounded: 1 – up to one decimal place (0.1), 2 – up to two decimal places (0.01)

slippage – slippage

MinProfit – minimum profit in points required to close all averaging orders

Set2 – if true, then two orders are placed without a signal; if false, then the Expert Advisor waits, until the candle closes above/below the previous one