Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=2
- study(title="T3MA Ribbon R2 by JustUncleL", shorttitle="T3RIBBON R2", overlay = true)
- //
- // Revision: R1
- // Revision Author: JustUncleL
- //
- // Description:
- // This study draws a T3 Moving average Coloured Ribbon based on a Fast and Slow T3 MAs.
- //
- // References:
- // - https://www.forexstrategiesresources.com/binary-options-trading-strategies/84-winner-binary-system/
- // =======
- // - T3 Average by HPotter v1.0 21/05/2014
- // This indicator plots the moving average described in the January, 1998 issue
- // of S&C, p.57, "Smoothing Techniques for More Accurate Signals", by Tim Tillson.
- // This indicator plots T3 moving average presented in Figure 4 in the article.
- // T3 indicator is a moving average which is calculated according to formula:
- // T3(n) = GD(GD(GD(n))),
- // where GD - generalized DEMA (Double EMA) and calculating according to this:
- // GD(n,v) = EMA(n) * (1+v)-EMA(EMA(n)) * v,
- // where "v" is volume factor, which determines how hot the moving average’s response
- // to linear trends will be. The author advises to use v=0.7.
- // When v = 0, GD = EMA, and when v = 1, GD = DEMA. In between, GD is a less aggressive
- // version of DEMA. By using a value for v less than1, trader cure the multiple DEMA
- // overshoot problem but at the cost of accepting some additional phase delay.
- // In filter theory terminology, T3 is a six-pole nonlinear Kalman filter. Kalman
- // filters are ones that use the error — in this case, (time series - EMA(n)) —
- // to correct themselves. In the realm of technical analysis, these are called adaptive
- // moving averages; they track the time series more aggres-sively when it is making large
- // moves. Tim Tillson is a software project manager at Hewlett-Packard, with degrees in
- // mathematics and computer science. He has privately traded options and equities for 15 years.
- // =======
- //
- // Modifications:
- // R1 - Original
- // R2 - Added optional Bar colouring
- // - Added option to Anchor chart to a higher Time Frame (1440 max)
- //
- // Use Alternate Anchor TF for MAs
- anchor = input(0,minval=0,maxval=1440,title="Use Alternate Anchor TimeFrame (0=none, max=1440mins)")
- Length1_ = input(9, minval=1,title="Fast T3 MA length")
- VolFactor1 = input(0.7,minval=0.0,maxval=1.0,title="Fast T3 Volume Factor")
- Length2__ = input(12, minval=2,title="Slow T3 MA length")
- VolFactor2 = input(0.6,minval=0.0,maxval=1.0,title="Slow T3 Volume Factor")
- sBars = input(false, title="Show Coloured Trend Bars")
- // Make sure we have minimum channel spread.
- Length2_ = (Length2__-Length1_)<1?Length1_+1:Length2__
- // If this is 5min or less Time Frame select EMAs
- mult = not isintraday or anchor==0 or interval<=0 or interval>=anchor? 1 : round(anchor/interval)>1? round(anchor/interval) : 1
- Length1 = mult==1 ? Length1_ : (Length1_-1)*mult
- Length2 = mult==1 ? Length2_ : (Length2_-1)*mult
- // T3 Moving Average Calculation Function.
- T3MA(src, Length, VolFactor) =>
- xe1 = ema(src, Length)
- xe2 = ema(xe1, Length)
- xe3 = ema(xe2, Length)
- xe4 = ema(xe3, Length)
- xe5 = ema(xe4, Length)
- xe6 = ema(xe5, Length)
- b = VolFactor
- c1 = -b*b*b
- c2 = 3*b*b+3*b*b*b
- c3 = -6*b*b-3*b-3*b*b*b
- c4 = 1+3*b+b*b*b+3*b*b
- c1 * xe6 + c2 * xe5 + c3 * xe4 + c4 * xe3
- // Get the two T3MAs
- t3ma1 = T3MA(close, Length1, VolFactor1)
- t3ma2 = T3MA(close, Length2, VolFactor2)
- //Plot the Ribbon
- ma1=plot( t3ma1,color=rising(t3ma1,2)?green:red,linewidth=2,transp=20,title="t3ma1")
- ma2=plot( t3ma2,color=rising(t3ma2,2)?green:red,linewidth=2,transp=20,title="t3ma2")
- fcolor = t3ma1>t3ma2?green:red
- fill(ma1,ma2,color=fcolor,transp=80)
- bc = not sBars? na : close>t3ma1 and close>t3ma2? green: close<t3ma1 and close<t3ma2? red : yellow
- barcolor(bc,title="Bar Colours")
- //eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement