Is there any reason why a custom indicator can't reference any bars back before [1]?
This is my first try at coding an indicator...I took the default CCI indicator and gutted it (it was the most basic) and started experimenting with things. I was working on calculations involving the last three bars, and trial and error revealed that once I added the third bar back, I got a blank panel. I eliminated everything else and just tried to plot the RSI of three bars ago and still got a blank panel
This is probably very obvious to veteran indicator coders out there, but I'm stumped.
if (CurrentBar == 0)
Value.Set(0);
else
{
double mean = 0;
for (int idx = Math.Min(CurrentBar, Period - 1); idx >= 0; idx--)
mean += Math.Abs(Typical[idx] - SMA(Typical, Period)[0]);
//Value.Set((Typical[0] - SMA(Typical, Period)[0]) / (mean == 0 ? 1 : (0.015 * (mean / Math.Min(Period, CurrentBar + 1)))));
Value.Set(RSI(14,3)[2]);
}

Comment