/*[[ Name := ROC Author := SPECULATOR Link := WWW.TIMEBENDS.COM Notes := Separate Window := yes First Color := LimeGreen First Draw Type := Line First Symbol := 217 Use Second Data := no Second Color := Red Second Draw Type := Line Second Symbol := 218 ]]*/ input: vPeriod(10); var: shift(0),loopbegin(0),ROC(0); var: first(True),prevbars(0),Box(0); SetLoopCount(0); //*********************************************************************************** // check for additional bars loading or total reloading If Bars < prevbars or Bars-prevbars>1 Then first = True; prevbars = Bars; // loopbegin1 prevent couning of counted bars exclude current If first Then Begin loopbegin = Bars-vPeriod-2; If loopbegin < 0 Then Exit; // not enough bars for counting first = False; // this block is to be evaluated once only End; //*********************************************************************************** loopbegin = loopbegin+1; // current bar is to be recounted too for shift = loopbegin downto 0 { ROC= ((Close[shift]-Close[shift+vPeriod])/Close[shift+vPeriod])*100+0.0001;// /Close[shift+vPeriod] SetIndexValue(shift, ROC); loopbegin = loopbegin-1; };