MQL5 RSI crossing threshold

 

Hi There,

Anyone could advise how to check RSI crossing overbought / oversold levels?

bool Buy_Condition_1=(RSI_val[0]<RSI_oversold && RSI_val[1]>=RSI_oversold);  

Stuck while inserting correct values to RSI_val[].

 

Hi,

You can use this code: 

double rsiBuffer[];
int rsiHandle;

int OnInit()
{
  ...
  ArraySetAsSeries(rsiBuffer,true);
  rsiHandle = iRSI(_Symbol, _Period, 12, PRICE_CLOSE);
  ...
}

void OnTick()
{
   ...   
   CopyBuffer(rsiHandle,0, 0, 2, rsiBuffer);
    
   bool Buy_Condition_1=(rsiBuffer[0]<RSI_oversold && rsiBuffer[1]>=RSI_oversold);
}
Reason: