- RSI EA code help
- EURGBP easy and profitable EA
- Icwr
Hi everyone. I have created EA which enters a long trade when RSI is above 70 and a short trade when RSI below 30. However, sometimes it enters either a short trade when RSI is above 30, and a long trade when RSI is below 70 which contradicts my if statement. In program, I have specified if(RSI[0]<30) enters a short, and when if(RSI[0]>70) enters a long. I have attached screenshot to see. Thanks
Hi, Thanks for suggestion. But I have figured out that current RSI value [0] can actually cross 70 for a second so the open trade is triggered, but right after that RSI value falls below 70 and never crosses it back. So the problem is that current value does not close above 70 it just crosses it for a second.
Place a "if (TimeCurrent()>= D'20210902 03:57') DebugBreak(); in OnTick right before the relevant variables are set and check it - it is made for this.
Hi, Thanks for suggestion. But I have figured out that current RSI value [0] can actually cross 70 for a second so the open trade is triggered, but right after that RSI value falls below 70 and never crosses it back. So the problem is that current value does not close above 70 it just crosses it for a second.
And you, in this case, start checking the signal on bar # 1.
it looks like repainting, the RSI value was once met the requirement when the bar has not closed, but then end without meeting your requirement when the bar closed
you can set iRSI on the last bar closed instead of the current bar to solve this
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use