Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- indicator('Periodic Channel', overlay=false)
- order = input(500)
- invert = input(false)
- //
- y = bar_index
- z = (y - ta.cum(y) / bar_index) / (ta.cum(math.abs(y - ta.cum(y) / bar_index)) / bar_index)
- //
- s = bar_index * math.sign(ta.cum(ta.correlation(close, bar_index, 2)))
- sin = invert ? math.sin(s / order) * -1 : math.sin(s / order)
- zs = (sin - ta.cum(sin) / bar_index) / (ta.cum(math.abs(sin - ta.cum(sin) / bar_index)) / bar_index)
- k = ta.cum(close) / bar_index + (z + zs) * (ta.cum(math.abs(close - ta.cum(close) / bar_index)) / bar_index)
- //
- os = ta.cum(math.abs(close - k)) / bar_index
- ap = k + os
- bp = ap + os
- cp = bp + os
- al = k - os
- bl = al - os
- cl = bl - os
- //
- plot(cp, color=color.new(color.red, 0), linewidth=2)
- plot(bp, color=color.new(color.orange, 0), linewidth=1)
- plot(ap, color=color.new(color.orange, 0), linewidth=0)
- plot(k, color=color.new(color.aqua, 0))
- plot(al, color=color.new(color.green, 0), linewidth=0)
- plot(bl, color=color.new(color.green, 0), linewidth=1)
- plot(cl, color=color.new(color.lime, 0), linewidth=2)
Add Comment
Please, Sign In to add comment