//input parameters
TCLen = 10
MA1 = 23
MA2 = 50
Once Factor = 0.5
if barindex>MA2 then
//{Calculate a MACD Line}
XMAC = ExponentialAverage[MA1](Close) - ExponentialAverage[MA2](Close)
//{1st Stochastic: Calculate Stochastic of a MACD}
Value1 = Lowest[TCLen](XMAC)
Value2 = Highest[TCLen](XMAC) - Value1
//{%Fast K of MACD}
if Value2 > 0 then
Frac1 = ((XMAC - Value1)/Value2) * 100
else
Frac1 = Frac1[1]
endif
//{Smoothed Calculation for % Fast D of MACD}
PF = PF[1] + (Factor * (Frac1 - PF[1]))
//{2nd Stochastic: DCalculate Stochastic of smoothed Percent Fast D, 'PF', above}
Value3 = Lowest[TCLen](PF)
Value4 = Highest[TCLen](PF) - Value3
//{% of Fast K of PF}
if Value4 > 0 then
Frac2 = ((PF - Value3)/Value4) * 100
else
Frac2 = Frac2[1]
endif
//{Smoothed Calculation for %Fast D of PF}
PFF = PFF[1] + (Factor * (Frac2 - PFF[1]))
endif
RETURN PFF, 75 coloured(0,0,255) as "level 75", 25 coloured(0,0,255) as "level 25"