I'm trying to use ROC() on a per bar basis, but all I get is zero.
Abbreviated example below, but
- C[bar] works as expected.
- ROC(C) gives the same result for every bar (as expected)
- ROC(C[bar]) gives me Zero. I would expect this to give me ROC for that bar.
Is there a way to do that?
Thanks,
Ryan
SetCustomBacktestProc("");
if (Status("action") == actionPortfolio) {
barDates = DateTime();
bo = GetBacktesterObject();
bo.PreProcess();
for (bar = 0; bar < BarCount; bar++) {
barDate = barDates[bar];
for (sig = bo.GetFirstSignal(bar); sig; sig =
bo.GetNextSignal(bar)) {
if (sig.IsEntry() && sig.IsLong()) {
SetForeign("XLE");
//THIS NUMBER IS ALWAYS ZERO???
Var1 = ROC(C[bar]);
_TRACE(NumToStr(bar)+" "+NumToStr(C[bar])+"
"+NumToStr(Var1));
RestorePriceArrays();
}
}
bo.HandleStops(bar);
bo.UpdateStats(bar, 1);
bo.UpdateStats(bar, 2);
}
bo.PostProcess();
}
Buy = C > MA(C,300);
Sell = C < MA(C,300);