RSI current Tick value

 

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!

 
fraccaman :

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

How to start with MQL5

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:

iRSI simple advisor 1.006

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);
  }

How to start with MQL5
How to start with MQL5
  • 2020.03.12
  • www.mql5.com
This thread discusses MQL5 code examples. There will be examples of how to get data from indicators, how to program advisors...
 

Thank you! Works like a charm! 

Have a good day!

 

Hello,

I need this please but when I tried it I got iRSIGet function not defined, please advice 

Reason: