The signal for opening an order is the RSI intersection of the upper or lower level.
Levels are set in parameters.
extern ENUM_TIMEFRAMES timeframe_RSI = 60;
extern int period_RSI = 14;
extern int level_buy = 30;
extern int level_sell = 70;
extern int MinStep = 20;
extern double Lot = 0.1;
extern double K_Lot = 1.5;
extern int Takeprofit = 50;
extern int Magic = 0;
extern int DigitsLot = 2;
extern int slippage = 3;
If the indicator crosses the level level_buy = 30 from bottom to top, then the buy position is opened. If the price did not reach TP and a new buy signal arrived, the adviser checks the current price level and, if the price is lower on MinStep, it opens a second trade.
TP of both trades is averaged and set from the point of their total breakeven. The same happens with the positions for sale.
The parameters in the advisor must be selected for each tool separately. This is easiest to do in the terminal optimizer. If you have questions, ask.
Below is an example of the work of the adviser. EA RSI Averange hands first – opening the first position manually. The rest are already opened by the adviser.