Advertisement
JustUncleL

T3MA Ribbon

Feb 7th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. //@version=2
  2.  
  3. study(title="T3MA Ribbon by JustUncleL", shorttitle="T3RIBBON", overlay = true)
  4.  
  5. //
  6. ////////////////////////////////////////////////////////////
  7. // Copyright by HPotter v1.0 21/05/2014
  8. // This indicator plots the moving average described in the January, 1998 issue
  9. // of S&C, p.57, "Smoothing Techniques for More Accurate Signals", by Tim Tillson.
  10. // This indicator plots T3 moving average presented in Figure 4 in the article.
  11. // T3 indicator is a moving average which is calculated according to formula:
  12. // T3(n) = GD(GD(GD(n))),
  13. // where GD - generalized DEMA (Double EMA) and calculating according to this:
  14. // GD(n,v) = EMA(n) * (1+v)-EMA(EMA(n)) * v,
  15. // where "v" is volume factor, which determines how hot the moving average’s response
  16. // to linear trends will be. The author advises to use v=0.7.
  17. // When v = 0, GD = EMA, and when v = 1, GD = DEMA. In between, GD is a less aggressive
  18. // version of DEMA. By using a value for v less than1, trader cure the multiple DEMA
  19. // overshoot problem but at the cost of accepting some additional phase delay.
  20. // In filter theory terminology, T3 is a six-pole nonlinear Kalman filter. Kalman
  21. // filters are ones that use the error — in this case, (time series - EMA(n)) —
  22. // to correct themselves. In the realm of technical analysis, these are called adaptive
  23. // moving averages; they track the time series more aggres-sively when it is making large
  24. // moves. Tim Tillson is a software project manager at Hewlett-Packard, with degrees in
  25. // mathematics and computer science. He has privately traded options and equities for 15 years.
  26. //
  27. // Reference:
  28. // - T3 Average by HPotter
  29. //
  30. ////////////////////////////////////////////////////////////
  31.  
  32. Length1 = input(5, minval=1)
  33. VolFactor1 = input(1.0,minval=0.0,maxval=1.0)
  34. Length2_ = input(21, minval=13)
  35. VolFactor2 = input(0.4,minval=0.0,maxval=1.0)
  36. Length2 = (Length2_-Length1)<8?Length1+2:Length2_
  37. //
  38. T3MA(src, Length, VolFactor) =>
  39. xe1 = ema(src, Length)
  40. xe2 = ema(xe1, Length)
  41. xe3 = ema(xe2, Length)
  42. xe4 = ema(xe3, Length)
  43. xe5 = ema(xe4, Length)
  44. xe6 = ema(xe5, Length)
  45. b = VolFactor
  46. c1 = -b*b*b
  47. c2 = 3*b*b+3*b*b*b
  48. c3 = -6*b*b-3*b-3*b*b*b
  49. c4 = 1+3*b+b*b*b+3*b*b
  50. c1 * xe6 + c2 * xe5 + c3 * xe4 + c4 * xe3
  51.  
  52.  
  53. t3ma1 = T3MA(close, Length1, VolFactor1)
  54. t3ma2 = T3MA(close, Length2, VolFactor2)
  55.  
  56. ma1=plot( t3ma1,color=green,linewidth=2,transp=20,title="t3ma1")
  57. ma2=plot( t3ma2,color=rising(t3ma2,2)?green:red,linewidth=2,transp=20,title="t3ma2")
  58. fcolor = t3ma1>t3ma2?green:red
  59. fill(ma1,ma2,color=fcolor,transp=80)
  60. //eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement