OPEN-SOURCE SCRIPT
SWING ATR Based V2 - Weekly + Daily

What does this indicator do?
This is a dual-timeframe extension of the original SGE script. It runs the same structural logic on Weekly (macro filter) and Daily (tactical trigger) simultaneously, with a new Price Discovery detection layer.
1. It identifies Market Swings on two timeframes
The script monitors price action on both the Weekly and the Daily charts at the same time. Each timeframe has its own ATR-based volatility filter, its own range threshold (kRange), and its own confirmation logic requiring at least two significant candles to validate a directional change. The Weekly is fetched via request.security; the Daily runs natively on the chart's bars.
2. It plots Support and Resistance zones for each timeframe
Weekly levels: solid lines, brighter colors (green/red by default).
Daily levels: dashed lines, accent colors (blue/orange by default), tagged with ▲D / ▼D markers.
Auto-cleaning: once a level is broken by a close, the line turns gray and stops extending. Only unbroken levels remain active.
3. It calculates two SGE Scores with a new Price Discovery layer
Each timeframe has its own score (-2 / 0 / +2), with the same one-candle delay as before. The new logic:
Breaking a support/resistance with other levels still standing → score goes to ±2 directly, or to 0 if the previous score was the opposite extreme (smooth transition).
Breaking the last support or the last resistance → Price Discovery mode: the score jumps directly to ±2 regardless of previous state, signaling that the structure has run out of opposing levels.
4. It simplifies visual reading
Each timeframe shows only its N closest unbroken levels (configurable per TF).
The chart candles are colored by the Weekly score (Weekly is treated as the dominant macro filter). If Weekly is disabled, the candles stay neutral.
5. Dashboard (top-right)
A side-by-side panel showing both timeframes:
Current SGE Score (-2 / 0 / +2)
Price Discovery state (UP / DOWN / Non)
Number of active supports
Number of active resistances
Number of levels currently displayed
Summary: A dual-timeframe structural detector. Weekly defines the dominant context; Daily provides faster signals within that context. The Price Discovery flag highlights moments when the market has broken all opposing structure — typically the highest-conviction zones for trend continuation.
Recommended Settings:
kRange: 1.3 / 1.4 (both TFs)
ATR Mult: 0.3 to 0.5
Trade ideas: take Daily entries only when Weekly score agrees (or is in Price Discovery in the same direction).
Script created with Claude AI.
This is a dual-timeframe extension of the original SGE script. It runs the same structural logic on Weekly (macro filter) and Daily (tactical trigger) simultaneously, with a new Price Discovery detection layer.
1. It identifies Market Swings on two timeframes
The script monitors price action on both the Weekly and the Daily charts at the same time. Each timeframe has its own ATR-based volatility filter, its own range threshold (kRange), and its own confirmation logic requiring at least two significant candles to validate a directional change. The Weekly is fetched via request.security; the Daily runs natively on the chart's bars.
2. It plots Support and Resistance zones for each timeframe
Weekly levels: solid lines, brighter colors (green/red by default).
Daily levels: dashed lines, accent colors (blue/orange by default), tagged with ▲D / ▼D markers.
Auto-cleaning: once a level is broken by a close, the line turns gray and stops extending. Only unbroken levels remain active.
3. It calculates two SGE Scores with a new Price Discovery layer
Each timeframe has its own score (-2 / 0 / +2), with the same one-candle delay as before. The new logic:
Breaking a support/resistance with other levels still standing → score goes to ±2 directly, or to 0 if the previous score was the opposite extreme (smooth transition).
Breaking the last support or the last resistance → Price Discovery mode: the score jumps directly to ±2 regardless of previous state, signaling that the structure has run out of opposing levels.
4. It simplifies visual reading
Each timeframe shows only its N closest unbroken levels (configurable per TF).
The chart candles are colored by the Weekly score (Weekly is treated as the dominant macro filter). If Weekly is disabled, the candles stay neutral.
5. Dashboard (top-right)
A side-by-side panel showing both timeframes:
Current SGE Score (-2 / 0 / +2)
Price Discovery state (UP / DOWN / Non)
Number of active supports
Number of active resistances
Number of levels currently displayed
Summary: A dual-timeframe structural detector. Weekly defines the dominant context; Daily provides faster signals within that context. The Price Discovery flag highlights moments when the market has broken all opposing structure — typically the highest-conviction zones for trend continuation.
Recommended Settings:
kRange: 1.3 / 1.4 (both TFs)
ATR Mult: 0.3 to 0.5
Trade ideas: take Daily entries only when Weekly score agrees (or is in Price Discovery in the same direction).
Script created with Claude AI.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。