OPEN-SOURCE SCRIPT
%ATR + ΔClose Highlight

Script Overview
This indicator displays on your chart:
Table of the last N bars that passed the ATR-based range filter:
Columns: Bar #, High, Range (High–Low), Low
Summary row: ATR(N), suggested Stop-Loss (SL = X % of ATR), and the current bar’s range as a percentage of ATR
Red badge on the most recent bar showing ΔClose% (the absolute difference between today’s and yesterday’s close, expressed as % of ATR)
Background highlights:
Blue fill under the most recent bar that met the filter
Yellow fill under bars that failed the filter
Hidden plots of ATR, %ATR, and ΔClose% (for use in strategies or alerts)
All table elements, fills, and plots can be toggled off with a single switch so that only the red ΔClose% badge remains visible.
Inputs
Setting Description Default
Length (bars) Lookback period for ATR and range filter (bars) 5
Upper deviation (%) Upper filter threshold (% of average ATR) 150%
Lower deviation (%) Lower filter threshold (% of average ATR) 50%
SL as % of ATR Stop-loss distance (% of ATR) 10%
Label position Table position relative to bar (“above” or “below”) above
Vertical offset (×ATR) Vertical spacing from the bar in ATR units 2.0
Show table & ATR plots Show or hide table, background highlights, and plots true
How It Works
ATR Calculation & Filtering
Computes average True Range over the last N bars.
Marks bars whose daily range falls within the specified upper/lower deviation band.
Table Construction
Gathers up to N most recent bars that passed the filter (or backfills from the most recent pass).
Formats each bar’s High, Low, and Range into fixed-width columns for neat alignment.
Stop-Loss & Percent Metrics
Calculates a recommended SL distance as a percentage of ATR.
Computes today’s bar range and ΔClose (absolute change in close) as % of ATR.
Chart Display
Table: Shows detailed per-bar data and summary metrics.
Background fills: Blue for the latest valid bar, yellow for invalid bars.
Hidden plots: ATR, %ATR, and ΔClose% (useful for backtesting).
Red badge: Always visible on the right side of the last bar, displaying ΔClose%.
Tips
Disable the table & ATR plots to reduce chart clutter—leave only the red ΔClose% badge for a minimalist volatility alert.
Use the hidden ATR fields (plot outputs) in TradingView Strategies or Alerts to automate volatility-based entries/exits.
Adjust the deviation band to capture “normal” intraday moves vs. outsized volatility spikes.
Load this script on any US market chart (stocks, futures, crypto, etc.) to instantly visualize recent volatility structure, set dynamic SL levels, and highlight today’s price change relative to average true range.
This indicator displays on your chart:
Table of the last N bars that passed the ATR-based range filter:
Columns: Bar #, High, Range (High–Low), Low
Summary row: ATR(N), suggested Stop-Loss (SL = X % of ATR), and the current bar’s range as a percentage of ATR
Red badge on the most recent bar showing ΔClose% (the absolute difference between today’s and yesterday’s close, expressed as % of ATR)
Background highlights:
Blue fill under the most recent bar that met the filter
Yellow fill under bars that failed the filter
Hidden plots of ATR, %ATR, and ΔClose% (for use in strategies or alerts)
All table elements, fills, and plots can be toggled off with a single switch so that only the red ΔClose% badge remains visible.
Inputs
Setting Description Default
Length (bars) Lookback period for ATR and range filter (bars) 5
Upper deviation (%) Upper filter threshold (% of average ATR) 150%
Lower deviation (%) Lower filter threshold (% of average ATR) 50%
SL as % of ATR Stop-loss distance (% of ATR) 10%
Label position Table position relative to bar (“above” or “below”) above
Vertical offset (×ATR) Vertical spacing from the bar in ATR units 2.0
Show table & ATR plots Show or hide table, background highlights, and plots true
How It Works
ATR Calculation & Filtering
Computes average True Range over the last N bars.
Marks bars whose daily range falls within the specified upper/lower deviation band.
Table Construction
Gathers up to N most recent bars that passed the filter (or backfills from the most recent pass).
Formats each bar’s High, Low, and Range into fixed-width columns for neat alignment.
Stop-Loss & Percent Metrics
Calculates a recommended SL distance as a percentage of ATR.
Computes today’s bar range and ΔClose (absolute change in close) as % of ATR.
Chart Display
Table: Shows detailed per-bar data and summary metrics.
Background fills: Blue for the latest valid bar, yellow for invalid bars.
Hidden plots: ATR, %ATR, and ΔClose% (useful for backtesting).
Red badge: Always visible on the right side of the last bar, displaying ΔClose%.
Tips
Disable the table & ATR plots to reduce chart clutter—leave only the red ΔClose% badge for a minimalist volatility alert.
Use the hidden ATR fields (plot outputs) in TradingView Strategies or Alerts to automate volatility-based entries/exits.
Adjust the deviation band to capture “normal” intraday moves vs. outsized volatility spikes.
Load this script on any US market chart (stocks, futures, crypto, etc.) to instantly visualize recent volatility structure, set dynamic SL levels, and highlight today’s price change relative to average true range.
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。