/*[[ Name := T3 smoothed double ROC 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 ]]*/ /// Double ROC Inputs : ROCPeriod(12), ROCDuration(15), UpperBand(1.0025), LowerBand(0.9975); Variables : shift(0), loopbegin(0), prevbars(0); Variables : ROCValue(0), ROCValue2(0), ROCValueHigh(0), ROCValueHigher(0), ROCValueHighest(0), ROCValueLow(0), ROCValueLower(0), ROCValueLowest(0), ROCValuePrev(0), ROCValuePrevPrev(0), ROCValueDelta(0), DurationAbove(0), DurationAbovePrev(0), DurationAboveLast(0), DurationBelow(0), DurationBelowPrev(0), DurationBelowLast(0), DurationAbove2(0), DurationAbovePrev2(0), DurationAboveLast2(0), DurationBelow2(0), DurationBelowPrev2(0), DurationBelowLast2(0); /// T3 two seperate ones long period for ROC1 short period for ROC2 Input : T3_period(7), T3_period_2(5); Variable : ROC_T3(0), ROC_T3_2(0); Variable : e1(0),e2(0),e3(0),e4(0),e5(0),e6(0),c1(0),c2(0),c3(0),c4(0); Variable : n(0),w1(0),w2(0),b(0),b2(0),b3(0); Variable : e1_2(0),e2_2(0),e3_2(0),e4_2(0),e5_2(0),e6_2(0),c1_2(0),c2_2(0),c3_2(0),c4_2(0); Variable : n_2(0), w1_2(0),w2_2(0),b_2(0), b2_2(0),b3_2(0); b=0.7; b2=b*b; b3=b2*b; c1=-b3; c2=(3*(b2+b3)); c3=-3*(2*b2+b+b3); c4=(1+3*b+b3+3*b2); n=T3_period; if n<1 then n=1; n = 1 + 0.5*(n-1); w1 = 2 / (n + 1); w2 = 1 - w1; // 2nd T3 b_2=0.7; b2_2=b_2*b_2; b3_2=b2_2*b_2; c1_2=-b3_2; c2_2=(3*(b2_2+b3_2)); c3_2=-3*(2*b2_2+b_2+b3_2); c4_2=(1+3*b_2+b3_2+3*b2_2); n_2=T3_period_2; if n_2<1 then n_2=1; n_2 = 1 + 0.5*(n_2-1); w1_2 = 2 / (n_2 + 1); w2_2 = 1 - w1_2; // Everything is ready... Now Begin the Loop SetLoopCount(0); For shift = Bars-1 Downto 0 Begin // Double ROC Code: ROCValue = Close[shift] / Close[shift+ROCPeriod]; ROCValueHigh = High[shift] / Close[shift+ROCPeriod]; ROCValueHigher = ( High[shift] + Close[shift] ) / ( Low[shift+ROCPeriod] * 2); ROCValueHighest = High[shift] / Low[shift+ROCPeriod]; ROCValueLow = Low[shift] / Close[shift+ROCPeriod]; ROCValueLower = ( Low[shift] + Close[shift] ) / ( High[shift+ROCPeriod] * 2); ROCValueLowest = Low[shift] / High[shift+ROCPeriod]; ROCValueDelta = ROCValue - ROCValuePrev; ROCValue2 = ROCValue; // Use regular ROC Value unless particular conditions are met /* 8 possible values for ROC2 High, (High+Higher)/2, Higher, (Higher+Highest)/2, Highest more articulation of overbought/oversold activity */ If ROCValue > 1 and ROCValue < ROCValuePrev and ROCValuePrev < ROCValuePrevPrev then ROCValue2 = ROCValueHigh*0.995; If ROCValue > 1 and ROCValue < ROCValuePrev then ROCValue2 = ROCValueHigh*0.999; If ROCValue > 1 and ROCValue < ROCValuePrev and ROCValue >= ROCValuePrevPrev then ROCValue2 = ROCValueHigh*0.9995; If ROCValue > 1 and ROCValue >= ROCValuePrev then ROCValue2 = (ROCValueHigh + ROCValueHigher)/2; If ROCValue > 1.0025 and ROCValue >= ROCValuePrev then ROCValue2 = ROCValueHigher; If ROCValue > 1.0025 and ROCValue < ROCValuePrev then ROCValue2 = (ROCValueHigher + ROCValueHighest)/2; If ROCValue > 1.025 then ROCValue2 = ROCValueHighest; If ROCValue > 1.025 and ROCValue < ROCValuePrev then ROCValue2 = (ROCValueHigher + ROCValueHighest)/2; If ROCValue < 1 and ROCValue > ROCValuePrev and ROCValuePrev > ROCValuePrevPrev then ROCValue2 = ROCValueLow*0.995; If ROCValue < 1 and ROCValue > ROCValuePrev then ROCValue2 = ROCValueLow*0.999; If ROCValue < 1 and ROCValue > ROCValuePrev and ROCValue <= ROCValuePrevPrev then ROCValue2 = ROCValueLow*0.9995; If ROCValue < 1 and ROCValue <= ROCValuePrev then ROCValue2 = (ROCValueLow+ROCValueLower)/2; If ROCValue < 0.9975 and ROCValue <= ROCValuePrev then ROCValue2 = ROCValueLower; If ROCValue < 0.9975 and ROCValue > ROCValuePrev then ROCValue2 = (ROCValueLower+ROCValueLowest)/2; If ROCValue < 0.975 then ROCValue2 = ROCValueLowest; If ROCValue < 0.975 and ROCValue > ROCValuePrev then ROCValue2 = (ROCValueLower+ROCValueLowest)/2; ROCValuePrevPrev = ROCValuePrev; ROCValuePrev = ROCValue; Comment("ROC1:",ROCValue," ROC2:",ROCValue2," - Last ROC1 Move:",ROCValueDelta); // T3 Code: // SetIndexValue(shift, 0); e1 = w1*ROCValue + w2*e1; e2 = w1*e1 + w2*e2; e3 = w1*e2 + w2*e3; e4 = w1*e3 + w2*e4; e5 = w1*e4 + w2*e5; e6 = w1*e5 + w2*e6; ROC_T3 = c1*e6 + c2*e5 + c3*e4 + c4*e3; SetIndexValue(shift, ROC_T3); e1_2 = w1_2*ROCValue2 + w2_2*e1_2; e2_2 = w1_2*e1_2 + w2_2*e2_2; e3_2 = w1_2*e2_2 + w2_2*e3_2; e4_2 = w1_2*e3_2 + w2_2*e4_2; e5_2 = w1_2*e4_2 + w2_2*e5_2; e6_2 = w1_2*e5_2 + w2_2*e6_2; ROC_T3_2 = c1_2*e6_2 + c2_2*e5_2 + c3_2*e4_2 + c4_2*e3_2; SetIndexValue2(shift, ROC_T3_2); // do duration analysis for ROC1 if ROC_T3 < UpperBand and ROC_T3 > LowerBand and DurationAbovePrev = 0 then DurationAbove = 0; if ROC_T3 < UpperBand and ROC_T3 > LowerBand and DurationAbovePrev > 0 then Begin DurationAboveLast = DurationAbove; DurationAbove = 0; end; if ROC_T3 >= UpperBand then DurationAbove = DurationAbove+1; if ROC_T3 > LowerBand and ROC_T3 < UpperBand and DurationBelowPrev = 0 then DurationBelow = 0; if ROC_T3 > LowerBand and ROC_T3 < UpperBand and DurationBelowPrev > 0 then Begin DurationBelowLast = DurationBelow; DurationBelow = 0; end; if ROC_T3 <= LowerBand then DurationBelow = DurationBelow+1; // and now duration analysis for ROC2 if ROC_T3_2 < UpperBand and ROC_T3_2 > LowerBand and DurationAbovePrev2 = 0 then DurationAbove2 = 0; if ROC_T3_2 < UpperBand and ROC_T3_2 > LowerBand and DurationAbovePrev2 > 0 then Begin DurationAboveLast2 = DurationAbove2; DurationAbove2 = 0; end; if ROC_T3_2 >= UpperBand then DurationAbove2 = DurationAbove2+1; if ROC_T3_2 > LowerBand and ROC_T3_2 < UpperBand and DurationBelowPrev2 = 0 then DurationBelow2 = 0; if ROC_T3_2 > LowerBand and ROC_T3_2 < UpperBand and DurationBelowPrev2 > 0 then Begin DurationBelowLast2 = DurationBelow2; DurationBelow2 = 0; end; if ROC_T3_2 <= LowerBand then DurationBelow2 = DurationBelow2+1; Comment("ROC1 - Above Band - Now: ",DurationAbove," Prev: ",DurationAbovePrev," Last: ",DurationAboveLast, "\nROC2 - Above Band - Now: ",DurationAbove2," Prev: ",DurationAbovePrev2," Last: ",DurationAboveLast2, "\nROC1 - Below Band - Now: ",DurationBelow," Prev: ",DurationBelowPrev," Last: ",DurationBelowLast, "\nROC2 - Below Band - Now: ",DurationBelow2," Prev: ",DurationBelowPrev2," Last: ",DurationBelowLast2); DurationAbovePrev = DurationAbove; DurationAbovePrev2 = DurationAbove2; DurationBelowPrev = DurationBelow; DurationBelowPrev2 = DurationBelow2; End;