OPEN-SOURCE SCRIPT
SPY ATR Bands

An all-in-one overlay that combines ATR-based deviation bands, all-time-high levels, and a weekly-EMA trend filter into a single clean tool. Built for swing dip-buying on SPY, but works on any symbol.
Features
• Multi-timeframe ATR bands (D / 4H / 1H) — Keltner-family bands built from an RMA centerline ± ATR × multiplier, with three depths each (narrow ×0.6 / main / wide ×1.5). Because they scale with ATR, a touch of the wide band means a statistically significant move relative to current volatility, not a fixed %. Lines are smoothed between higher-TF updates. Color-coded by TF (D / 4H / 1H), with optional narrow/wide layers.
• Intersection markers — A bubble is dropped at the deepest band touched within each incursion (narrow > main > wide), per timeframe. Instantly shows where price is interacting with each TF's volatility envelope.
• ATH line + pullback levels — Running all-time-high line plus −3 / −4 / −5 / −10 / −15 / −20 / −25% pullback levels (labels only). The ATH label shows price, days since the last ATH, and current trend-leg %. A live "Now" label shows price and exact % distance from the ATH (candle-colored).
• W EMA20 proxy (trend filter) — Approximates the weekly EMA20 on any timeframe (1H/Daily proxies, down to intraday) so you always see the higher-TF trend line. The line turns green when the last daily candle closes above it and red when it closes below — a clean bull/bear read. Includes a tolerance zone, an intersection marker, and an optional interpolation mode for a smooth line down to 5-minute charts.
• Built-in alerts — "Any intersection marker", "Lower-band touch (dip)", and "W EMA20 touch".
How to use
Watch for price tapping a lower band (oversold) while well below the ATH and above the W EMA20 line (trend intact). The deeper the band and the further from the ATH, the higher-conviction the pullback. The W EMA20 color tells you whether the broader regime is bullish or bearish.
Most colors, widths, tolerances and toggles are fully configurable in settings.
Not financial advice — for educational / technical-analysis use.
Features
• Multi-timeframe ATR bands (D / 4H / 1H) — Keltner-family bands built from an RMA centerline ± ATR × multiplier, with three depths each (narrow ×0.6 / main / wide ×1.5). Because they scale with ATR, a touch of the wide band means a statistically significant move relative to current volatility, not a fixed %. Lines are smoothed between higher-TF updates. Color-coded by TF (D / 4H / 1H), with optional narrow/wide layers.
• Intersection markers — A bubble is dropped at the deepest band touched within each incursion (narrow > main > wide), per timeframe. Instantly shows where price is interacting with each TF's volatility envelope.
• ATH line + pullback levels — Running all-time-high line plus −3 / −4 / −5 / −10 / −15 / −20 / −25% pullback levels (labels only). The ATH label shows price, days since the last ATH, and current trend-leg %. A live "Now" label shows price and exact % distance from the ATH (candle-colored).
• W EMA20 proxy (trend filter) — Approximates the weekly EMA20 on any timeframe (1H/Daily proxies, down to intraday) so you always see the higher-TF trend line. The line turns green when the last daily candle closes above it and red when it closes below — a clean bull/bear read. Includes a tolerance zone, an intersection marker, and an optional interpolation mode for a smooth line down to 5-minute charts.
• Built-in alerts — "Any intersection marker", "Lower-band touch (dip)", and "W EMA20 touch".
How to use
Watch for price tapping a lower band (oversold) while well below the ATH and above the W EMA20 line (trend intact). The deeper the band and the further from the ATH, the higher-conviction the pullback. The W EMA20 color tells you whether the broader regime is bullish or bearish.
Most colors, widths, tolerances and toggles are fully configurable in settings.
Not financial advice — for educational / technical-analysis use.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.