Skip to content

Instantly share code, notes, and snippets.

@iCodeForBananas
Created November 18, 2021 18:35
Show Gist options
  • Select an option

  • Save iCodeForBananas/aefea8349c1d0dcaa78cf79f642b88d9 to your computer and use it in GitHub Desktop.

Select an option

Save iCodeForBananas/aefea8349c1d0dcaa78cf79f642b88d9 to your computer and use it in GitHub Desktop.
//@version=5
// Based off of Oliver Velez's concept of moving averages being zones
// or magnets that pull and bend price. Like leaning into a fence.
indicator(title="Moving Average Zone", shorttitle="MA Zone", overlay=true, timeframe="", timeframe_gaps=true)
ma_len = input.int(20, minval=1, title="Moving average length")
center_line_width = input(1, title="Center line width")
center_line_color = input.color(color.new(color.blue, 50), "Center line color")
center_line_src = input(close, title="Center line source")
zone_width = input(15, title="Zone width")
zone_color = input.color(color.new(color.blue, 80), "Zone color")
zone_src = input(close, title="Zone source")
center_line_out = ta.sma(center_line_src, ma_len)
plot(center_line_out, color=center_line_color, title="MA 1", linewidth=center_line_width)
zone_out = ta.sma(zone_src, ma_len)
plot(zone_out, color=zone_color, title="MA 2", linewidth=zone_width)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment