Hi everybody,
Im developing an EA, but i' having trouble at understanding how I can get the value of the RSI at the current Tick.
Im using the iRSI function , and I'm able to get values out of it. The problem is that I need the RSI value of the current tick and not of the last closed bar. Do you know if there any way to get it?
Thanks!
Just ask for the iRSI indicator values from the current bar - at each moment in time, the indicator on the current bar will show the latest value.
An example of an Expert Advisor based on RSI: How to start with MQL5
Forum on trading, automated trading systems and testing trading strategies
Vladimir Karputov, 2020.03.13 11:16
iRSI simple advisor, version1.006
This is how the adviser works now: we check the signal ONLY AT THE MOMENT OF THE BIRTH OF A NEW BAR. The new bar has index # 0, we call the new bar "Current Bar". Example of a BUY signal: if the two previous bars (bar # 1 and bar # 2) are below the '30' line, this is a BUY signal:
Pic. 1. iRSI simple advisor, version1.006
The code:
//+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- we work only at the time of the birth of new bar datetime time_0=iTime(Symbol(),Period(),0); if(time_0==m_prev_bars) return; m_prev_bars=time_0; //--- double rsi_2=iRSIGet(2); double rsi_1=iRSIGet(1); if(rsi_2==EMPTY_VALUE || rsi_1==EMPTY_VALUE) return; //--- if(rsi_2>Inp_RSI_Level_UP && rsi_1>Inp_RSI_Level_UP) m_trade.Sell(1.0); else if(rsi_2<Inp_RSI_Level_DOWN && rsi_1<Inp_RSI_Level_DOWN) m_trade.Buy(1.0); }
- 2020.03.12
- www.mql5.com
Thank you! Works like a charm!
Have a good day!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi everybody,
Im developing an EA, but i' having trouble at understanding how I can get the value of the RSI at the current Tick.
Im using the iRSI function, and I'm able to get values out of it. The problem is that I need the RSI value of the current tick and not of the last closed bar. Do you know if there any way to get it?
Thanks!