/*[[ Name := Double ROC (Rate of Change) ver2 Author := Anthony K: anthonyanthony123@yahoo.com Separate Window := Yes First Color := Blue First Draw Type := Line First Symbol := 217 Use Second Data := Yes Second Color := Red Second Draw Type := Line Second Symbol := 218 ]]*/ Inputs : ROCPeriod(12), ROCDuration(16), UpperBand(102.5), LowerBand(97.5); Variables : shift(0), cnt(0), loopbegin(0), first(True), prevbars(0); Variables : sum(0), smconst(0), prev(0), weight(0), linear(0), MAstring(""); Variables : ROCValue(0), ROCValue2(0), ROCValueHigh(0), ROCValueHigher(0), ROCValueLow(0), ROCValueLower(0), ROCValuePrev(0), ROCValueDelta(0); SetLoopCount(0); // loop from first bar to current bar (with shift=0) For shift=Bars-1 Downto 0 Begin ROCValue = Close[shift] / Close[shift+ROCPeriod]; ROCValueHigh = High[shift] / Close[shift+ROCPeriod]; ROCValueHigher = High[shift] / Low[shift+ROCPeriod]; ROCValueLow = Low[shift] / Close[shift+ROCPeriod]; ROCValueLower = Low[shift] / High[shift+ROCPeriod]; SetIndexValue(shift, ROCValue); ROCValueDelta = ROCValue - ROCValuePrev; ROCValue2 = ROCValue; // Use regular ROC Value unless particular conditions are met If ROCValue > 1 and ROCValue > ROCValuePrev then ROCValue2 = ROCValueHigh; If ROCValue > 1.0025 and ROCValue > ROCValuePrev then ROCValue2 = ROCValueHigher; If ROCValue > 1.025 then ROCValue2 = ROCValueHigher; If ROCValue < 1 and ROCValue < ROCValuePrev then ROCValue2 = ROCValueLow; If ROCValue < 0.9975 then ROCValue2 = ROCValueLower; If ROCValue < 0.9975 and ROCValue < ROCValuePrev then ROCValue2 = ROCValueLower; If ROCValue < 0.975 then ROCValue2 = ROCValueLower; SetIndexValue2(shift, ROCValue2); ROCValuePrev = ROCValue; Comment("ROC1:",ROCValue," ROC2:",ROCValue2," - Last ROC1 Move:",ROCValueDelta); End;