Got invalid RSI value

 

Hi, could you please help me understand the problem?


I'm trying to get the values of MACD main and signal lines, and RSI line of a last closed candle and a candle before it.
I managed to get the right values for MACD lines, but not for RSI...

rsiHandle 	= iRSI(_Symbol, PERIOD_CURRENT, inpRsiPeriod, inpRsiPrice);
macdHandle	= iMACD(_Symbol, PERIOD_CURRENT, inpMacdFastPeriod, inpMacdSlowPeriod, inpMacdSignPeriod, inpMacdPrice);

int dig = _Digits + 1;

double _macdMain[];
double _macdSignal[];
double _rsi[];

CopyBuffer(macdHandle,  0, 0, 3, _macdMain);
CopyBuffer(macdHandle,  1, 0, 3, _macdSignal);
CopyBuffer(rsiHandle,   2, 0, 3, _rsi);

ArraySetAsSeries(_macdMain,   true);
ArraySetAsSeries(_macdSignal, true);
ArraySetAsSeries(_rsi,        true);

macdMain             = NormalizeDouble(_macdMain[1],     dig); //Valid data
macdMainPrevious     = NormalizeDouble(_macdMain[2],     dig); //Valid data

macdSignal           = NormalizeDouble(_macdSignal[1],   dig); //Valid data
macdSignalPrevious   = NormalizeDouble(_macdSignal[2],   dig); //Valid data

rsi                  = NormalizeDouble(_rsi[1],          dig); //Invalid data: always returns 0
rsiPrevious          = NormalizeDouble(_rsi[2],          dig); //Invalid data: always returns 0


I didn't described somehow the buffer numbers in CopyBuffer (0 for main MACD, 1 for signal MACD, 2 for RSI). Should I?

If if change _rsi[1] to _rsi[0] some data appeared then, but it doesn't match to what I see on a chart. I mean 32.97 and 47.13 - a big difference.

 
llaabbss:

Hi, could you please help me understand the problem?


I'm trying to get the values of MACD main and signal lines, and RSI line of a last closed candle and a candle before it.
I managed to get the right values for MACD lines, but not for RSI...

I didn't described somehow the buffer numbers in CopyBuffer (0 for main MACD, 1 for signal MACD, 2 for RSI). Should I?

If if change _rsi[1] to _rsi[0] some data appeared then, but it doesn't match to what I see on a chart. I mean 32.97 and 47.13 - a big difference.

Please read the documentation. What value is returned by CopyBuffer() ?

What is buffer 2 of RSI ?

 
Alain Verleyen:

Please read the documentation. What value is returned by CopyBuffer() ?

What is buffer 2 of RSI ?

Dear Alain,

I thought the buffers should be enumerated somehow. In documentation it is not clear exactly what is the buffer and what it consist of (specifically for iRSI).

That's why I supposed these buffers should be unique. But I was wrong, replacing the number of buffer 2 with 0 solves the problem.


Thank you for paying attention even to such dumb questions )))

Reason: