I'm somewhat new to Ninjascript and have been trying to port the following TraderStudio code over to Ninjascript but so far it's not working. It's a lag adjusted TEMA. Here's the TraderStudio code:
Function ZL_TEMA(TEMA1 As BarArray, Length, OffSet) As BarArray
Dim TEMA2 As BarArray
Dim Diff
TEMA2 = TEMA(TEMA1, Length, OffSet)
Diff = TEMA1 - TEMA2
ZL_TEMA = MA_TEMA1 + Diff
End Function
Here's the relevant section of Ninjascript:
protected override void OnBarUpdate()
{
double ZL_Tema;
double Tema2;
double Diff;
int i;
if (CurrentBar < period) return;
for(i = 0; i < period; i++)
{
Tema1.Set( i, TEMA( period )[i] );
}
Tema2 = TEMA( Tema1, period )[0];
Diff = Tema1[0] - Tema2;
ZL_Tema = SMA(Tema1, period)[0] + Diff;
CenterLine.Set(ZL_Tema);
}
Nothing is showing up on the chart for the indicator even though it compiles fine. It's not clear to me how to debug indicator values with the Print() function, and I'm not even sure I have this code converted correctly.
Comment