xmd79

Periodic Channel

May 19th, 2023
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. //@version=5
  2. indicator('Periodic Channel', overlay=false)
  3. order = input(500)
  4. invert = input(false)
  5. //
  6. y = bar_index
  7. z = (y - ta.cum(y) / bar_index) / (ta.cum(math.abs(y - ta.cum(y) / bar_index)) / bar_index)
  8. //
  9. s = bar_index * math.sign(ta.cum(ta.correlation(close, bar_index, 2)))
  10. sin = invert ? math.sin(s / order) * -1 : math.sin(s / order)
  11. zs = (sin - ta.cum(sin) / bar_index) / (ta.cum(math.abs(sin - ta.cum(sin) / bar_index)) / bar_index)
  12. k = ta.cum(close) / bar_index + (z + zs) * (ta.cum(math.abs(close - ta.cum(close) / bar_index)) / bar_index)
  13. //
  14. os = ta.cum(math.abs(close - k)) / bar_index
  15. ap = k + os
  16. bp = ap + os
  17. cp = bp + os
  18. al = k - os
  19. bl = al - os
  20. cl = bl - os
  21. //
  22. plot(cp, color=color.new(color.red, 0), linewidth=2)
  23. plot(bp, color=color.new(color.orange, 0), linewidth=1)
  24. plot(ap, color=color.new(color.orange, 0), linewidth=0)
  25. plot(k, color=color.new(color.aqua, 0))
  26. plot(al, color=color.new(color.green, 0), linewidth=0)
  27. plot(bl, color=color.new(color.green, 0), linewidth=1)
  28. plot(cl, color=color.new(color.lime, 0), linewidth=2)
  29.  
  30.  
Add Comment
Please, Sign In to add comment