This Expert Advisor is rewritten from MQL4 and was originally published here /en/code/7756 by its author George-on-Don.
First, the price channel is determined (maximum High (MaxH) and minimum Low (MinL) over the period specified in the parameters). The obtained values are then used to calculate the reference level (MaxH+MinL+Close)/3.
Signals for opening a position appear as follows: if the bar closing price is below the upper limit of the channel and above the reference level, we get a Sell signal. If the bar closing price is above the lower limit of the channel and below the reference level, we get a Buy signal.
Signals for closing a position appear as follows: if the High price of the closed bar is equal to the upper limit of the channel and the upper limit value of the channel is equal to the value on the previous bar, we get a signal for closing a Buy position. If the Low price of the closed bar is equal to the lower limit of the channel and the lower limit value of the channel is equal to the value on the previous bar, we get a signal for closing a Sell position. These conditions can very rarely be satisfied so in addition to the above closing options, the Expert Advisor also uses Stop Loss. The Stop Loss value is determined using the ATR indicator, whereby the level is calculated from the channel limits: from the lower limit when buying and from the upper limit when selling.
The Expert Advisor takes profit using a trailing stop function.
The image below shows the Expert Advisor performance in the strategy tester's visual mode.

The original version has the isFloatLots parameter that switches between the variables Lots and MaxR. In this version, it is replaced by the Lots parameter. If Lots is 0, the MaxR parameter is used.
Translated from Russian by MetaQuotes Ltd.
Original code: /ru/code/1049
Gann_Multi_Trend
The indicator of the Micro, Middle and Main Trends
MultiRVISignal
MultiRVISignal displays information on current trends using values of the four RVI indicators obtained from different time frames.
MA2CCI
Expert Advisor that operates based on two МАs and CCI
Fast Trading Panel
Fast Trading Panel - the panel for fast trading