I'm trying to "convert" the following code to NinjaScript. It correctly compiles however my debugging process indicates a problem that I believe is related to the following lines. I had hoped somebody might "see" something. Here's the "old" code:
K= 5; Pr = 5;
VarSto:= If(Barnum<Pr+(Pr*1.5),StK,MOV((((1-MyConst)*Ref(VarSto,-1))+(MyConst*Close)),2,s));
StVarK := Mov((((VarSto-LLV(VarSto,K ))/(HHV(VarSto,K )-LLV(VarSto,K)))*100),Sl,s);
Here's the code I've written/converted to NinjaScript:
if(CurrentBar < (Pr + (Pr * 1.5))){VarSto = StK;}
if(CurrentBar >= (Pr + (Pr * 1.5)))
{
myDataSeries2.Set(((1 - MyConst) * (VarStoSeries[1])) + (MyConst * Close[0]));
VarSto = SMA(myDataSeries2, 2)[0];
}
VarStoSeries.Set(VarSto);
myDataSeries.Set(((VarSto - Math.Min(VarSto, K)) / (Math.Max(VarSto, K) - Math.Min(VarSto, K))) * 100);
StVarK = SMA(myDataSeries, sl)[0];
I believe the problem I'm having is within this posted code...specifically the "myDataSeries.Set" calculation always equates to "100", which should not be the case. I wondered if somebody could point out the difference in my Ninja code compared to the original code...is there a problem with math, logic, or something else? Thank you in advance.
Comment