In my study, I calculate the difference between an RSI(2) and a calculated RSI. For some bars, the RSI(2) is not plotted. I have overlayed a RSI to verify this.
This picture shows the problem.
How does one fix this? Should I call the RSI a different way? I have tried also calling it as a series object and as retrieving single values.
I have found the following section of code that if taken out allows the RSI2 to plot correctly.
This picture shows the problem.
How does one fix this? Should I call the RSI a different way? I have tried also calling it as a series object and as retrieving single values.
I have found the following section of code that if taken out allows the RSI2 to plot correctly.
PHP Code:
var vtemp=0;
var vtemp_1=0;
var vtemp2=0;
var vtemp2_1=0;
// this section cause rsi to boobooooooooooooooooooooooooooooooooooooooo
for (i=fromIndex; i < barC+1; i++)
{
nn =i-barC;
var vchg = close(nn)-close(nn-1);
vtemp_1 = vtemp;
vtemp2_1 = vtemp2;
if (isNaN( vchg ) == true) { vchg = 0; }
vtemp = scaleVal*vchg + (1-scaleVal)*vtemp_1;
var vabsChg = Math.abs(vchg);
vtemp2= scaleVal*vabsChg + (1-scaleVal)*vtemp2_1;
}
//////////////////////////////////////to here
vnetChgAvg= vtemp;
vtotChgAvg = vtemp2;
if ((vnetChgAvg)!=0 && (vtotChgAvg)!=0)
{
rsiPO= 50*(vnetChgAvg/ vtotChgAvg+1);
}
else { rsiPO= rsiPO_1; }
if (bExpired)
{
rsiPO=50;
}
vbss = Math.abs(rsi(2,0)-rsiPO);
return Array(rsiPO, rsi(2),vbss);
}
Comment