Download MetaTrader 5

MQL5 RSI crossing threshold

To add comments, please log in or register
How to test a program before buying?
chera
86
chera 2015.04.01 04:05 

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[].

InvestSoft
8594
Janusz Trojca 2015.04.01 10:54  

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);
}
To add comments, please log in or register