Advertisement
JustUncleL

T3Ribbon R2

Mar 22nd, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.77 KB | None | 0 0
  1. //@version=2
  2.  
  3. study(title="T3MA Ribbon R2 by JustUncleL", shorttitle="T3RIBBON R2", overlay = true)
  4.  
  5. //
  6. // Revision: R1
  7. // Revision Author: JustUncleL
  8. //
  9. // Description:
  10. // This study draws a T3 Moving average Coloured Ribbon based on a Fast and Slow T3 MAs.
  11. //
  12. // References:
  13. // - https://www.forexstrategiesresources.com/binary-options-trading-strategies/84-winner-binary-system/
  14. // =======
  15. // - T3 Average by HPotter v1.0 21/05/2014
  16. // This indicator plots the moving average described in the January, 1998 issue
  17. // of S&C, p.57, "Smoothing Techniques for More Accurate Signals", by Tim Tillson.
  18. // This indicator plots T3 moving average presented in Figure 4 in the article.
  19. // T3 indicator is a moving average which is calculated according to formula:
  20. // T3(n) = GD(GD(GD(n))),
  21. // where GD - generalized DEMA (Double EMA) and calculating according to this:
  22. // GD(n,v) = EMA(n) * (1+v)-EMA(EMA(n)) * v,
  23. // where "v" is volume factor, which determines how hot the moving average’s response
  24. // to linear trends will be. The author advises to use v=0.7.
  25. // When v = 0, GD = EMA, and when v = 1, GD = DEMA. In between, GD is a less aggressive
  26. // version of DEMA. By using a value for v less than1, trader cure the multiple DEMA
  27. // overshoot problem but at the cost of accepting some additional phase delay.
  28. // In filter theory terminology, T3 is a six-pole nonlinear Kalman filter. Kalman
  29. // filters are ones that use the error — in this case, (time series - EMA(n)) —
  30. // to correct themselves. In the realm of technical analysis, these are called adaptive
  31. // moving averages; they track the time series more aggres-sively when it is making large
  32. // moves. Tim Tillson is a software project manager at Hewlett-Packard, with degrees in
  33. // mathematics and computer science. He has privately traded options and equities for 15 years.
  34. // =======
  35. //
  36. // Modifications:
  37. // R1 - Original
  38. // R2 - Added optional Bar colouring
  39. // - Added option to Anchor chart to a higher Time Frame (1440 max)
  40. //
  41.  
  42. // Use Alternate Anchor TF for MAs
  43. anchor = input(0,minval=0,maxval=1440,title="Use Alternate Anchor TimeFrame (0=none, max=1440mins)")
  44. Length1_ = input(9, minval=1,title="Fast T3 MA length")
  45. VolFactor1 = input(0.7,minval=0.0,maxval=1.0,title="Fast T3 Volume Factor")
  46. Length2__ = input(12, minval=2,title="Slow T3 MA length")
  47. VolFactor2 = input(0.6,minval=0.0,maxval=1.0,title="Slow T3 Volume Factor")
  48. sBars = input(false, title="Show Coloured Trend Bars")
  49.  
  50. // Make sure we have minimum channel spread.
  51. Length2_ = (Length2__-Length1_)<1?Length1_+1:Length2__
  52.  
  53. // If this is 5min or less Time Frame select EMAs
  54. mult = not isintraday or anchor==0 or interval<=0 or interval>=anchor? 1 : round(anchor/interval)>1? round(anchor/interval) : 1
  55. Length1 = mult==1 ? Length1_ : (Length1_-1)*mult
  56. Length2 = mult==1 ? Length2_ : (Length2_-1)*mult
  57.  
  58.  
  59. // T3 Moving Average Calculation Function.
  60. T3MA(src, Length, VolFactor) =>
  61. xe1 = ema(src, Length)
  62. xe2 = ema(xe1, Length)
  63. xe3 = ema(xe2, Length)
  64. xe4 = ema(xe3, Length)
  65. xe5 = ema(xe4, Length)
  66. xe6 = ema(xe5, Length)
  67. b = VolFactor
  68. c1 = -b*b*b
  69. c2 = 3*b*b+3*b*b*b
  70. c3 = -6*b*b-3*b-3*b*b*b
  71. c4 = 1+3*b+b*b*b+3*b*b
  72. c1 * xe6 + c2 * xe5 + c3 * xe4 + c4 * xe3
  73.  
  74. // Get the two T3MAs
  75. t3ma1 = T3MA(close, Length1, VolFactor1)
  76. t3ma2 = T3MA(close, Length2, VolFactor2)
  77.  
  78. //Plot the Ribbon
  79. ma1=plot( t3ma1,color=rising(t3ma1,2)?green:red,linewidth=2,transp=20,title="t3ma1")
  80. ma2=plot( t3ma2,color=rising(t3ma2,2)?green:red,linewidth=2,transp=20,title="t3ma2")
  81. fcolor = t3ma1>t3ma2?green:red
  82. fill(ma1,ma2,color=fcolor,transp=80)
  83.  
  84. bc = not sBars? na : close>t3ma1 and close>t3ma2? green: close<t3ma1 and close<t3ma2? red : yellow
  85. barcolor(bc,title="Bar Colours")
  86.  
  87. //eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement