OPEN-SOURCE SCRIPT
Live 1H ATR(1) & ATR(5) on Lower Timeframes

Synthetic 1-Hour ATR Indicator (on lower timeframe charts)
Reconstructs 1-hour candles on any lower timeframe (like 5m or 15m):
Tracks open, high, low, close for the current 1-hour period.
Updates high and low live as new lower timeframe bars arrive.
Tracks completed 1-hour True Ranges (TRs):
Stores TRs of past 1-hour bars in an array (tr_hist).
Keeps the last 50 completed hourly TRs for ATR calculation.
Computes the current (live) TR:
Calculates the TR of the in-progress 1-hour candle relative to the last completed hour’s close.
Updates on every lower timeframe bar, so ATR values reflect live volatility.
Calculates ATR(1) and ATR(5):
ATR(1) = most recent TR (current hour).
ATR(5) = average of the last 5 TRs (current + last 4 completed hours).
Plots ATR lines in a separate indicator pane:
Green line = ATR(1)
Orange line = ATR(5)
Background coloring for volatility detection:
Checks New York time using timestamp("America/New_York", ...).
Between 09:20 and 09:30 NY time, calculates ATR ratio = ATR(1)/ATR(5).
Turns the background red if ATR(1) is ≤ 65% or ≥ 165% of ATR(5).
Semi-transparent red (opacity=80) so it doesn’t block the chart.
Designed for lower timeframe charts:
Allows you to read 1-hour ATRs on a 5m chart.
Works live, updating with every lower timeframe bar.
Reconstructs 1-hour candles on any lower timeframe (like 5m or 15m):
Tracks open, high, low, close for the current 1-hour period.
Updates high and low live as new lower timeframe bars arrive.
Tracks completed 1-hour True Ranges (TRs):
Stores TRs of past 1-hour bars in an array (tr_hist).
Keeps the last 50 completed hourly TRs for ATR calculation.
Computes the current (live) TR:
Calculates the TR of the in-progress 1-hour candle relative to the last completed hour’s close.
Updates on every lower timeframe bar, so ATR values reflect live volatility.
Calculates ATR(1) and ATR(5):
ATR(1) = most recent TR (current hour).
ATR(5) = average of the last 5 TRs (current + last 4 completed hours).
Plots ATR lines in a separate indicator pane:
Green line = ATR(1)
Orange line = ATR(5)
Background coloring for volatility detection:
Checks New York time using timestamp("America/New_York", ...).
Between 09:20 and 09:30 NY time, calculates ATR ratio = ATR(1)/ATR(5).
Turns the background red if ATR(1) is ≤ 65% or ≥ 165% of ATR(5).
Semi-transparent red (opacity=80) so it doesn’t block the chart.
Designed for lower timeframe charts:
Allows you to read 1-hour ATRs on a 5m chart.
Works live, updating with every lower timeframe bar.
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.