OPEN-SOURCE SCRIPT
更新済 Trend Structure & Untested Levels

Trend Structure & Tested Levels
Draws the swing trend as a zigzag, turns every swing into a support/resistance level, and tracks whether price has closed through it ("tested") or not ("untested").
Overview
A market-structure tool. It connects confirmed swing highs and lows into a clean zigzag trend line, then projects a horizontal level from each swing. Every level is classified by state — untested until a candle closes through it, after which the most recent break in each direction is flagged as Last Gained or Last Lost. The result is an at-a-glance map of the active structure and which levels are still in play.
What it does
Swing trend (zigzag). Connects confirmed pivot highs/lows into a trend line. A live, provisional leg always runs from the last confirmed pivot to the current price, so the structure reaches the current bar.
Automatic levels. Each swing high/low becomes a horizontal level — highs above price act as resistance, lows below price as support.
Tested vs untested. A level stays untested until a candle closes through it; a wick touch alone does not count.
Last Gained / Last Lost. The most recent resistance price closed above is tagged Last Gained (bullish break of structure); the most recent support price closed below is tagged Last Lost (bearish break).
Multi-timeframe
Levels — and the zigzag, in follow mode — can be drawn from the chart timeframe or any higher timeframe (e.g. D / W / M), labelled with a suffix such as (W). Higher-timeframe pivots are read without repainting forward-filled values and are anchored at the real pivot time, so an HTF level sits where it actually formed and runs horizontally across the whole chart.
Key settings
Pivot length — the master sensitivity control. Lower = a finer zigzag and more, smaller levels; higher = only the major structure.
Swing source — wicks (high/low) or candle bodies (open/close) to ignore wick spikes.
Zigzag follows levels timeframe — keep trend line and levels on one structure, or decouple the zigzag onto the chart timeframe.
Independent colours, line styles, widths, and a per-side cap on untested levels.
Notes
This is a visualisation of structure, not a signal or strategy — it says nothing about profitability; validate separately.
Repainting. Swings confirm pivot length bars after the fact, and the live leg moves with price until a new pivot confirms.
Not financial advice.
Draws the swing trend as a zigzag, turns every swing into a support/resistance level, and tracks whether price has closed through it ("tested") or not ("untested").
Overview
A market-structure tool. It connects confirmed swing highs and lows into a clean zigzag trend line, then projects a horizontal level from each swing. Every level is classified by state — untested until a candle closes through it, after which the most recent break in each direction is flagged as Last Gained or Last Lost. The result is an at-a-glance map of the active structure and which levels are still in play.
What it does
Swing trend (zigzag). Connects confirmed pivot highs/lows into a trend line. A live, provisional leg always runs from the last confirmed pivot to the current price, so the structure reaches the current bar.
Automatic levels. Each swing high/low becomes a horizontal level — highs above price act as resistance, lows below price as support.
Tested vs untested. A level stays untested until a candle closes through it; a wick touch alone does not count.
Last Gained / Last Lost. The most recent resistance price closed above is tagged Last Gained (bullish break of structure); the most recent support price closed below is tagged Last Lost (bearish break).
Multi-timeframe
Levels — and the zigzag, in follow mode — can be drawn from the chart timeframe or any higher timeframe (e.g. D / W / M), labelled with a suffix such as (W). Higher-timeframe pivots are read without repainting forward-filled values and are anchored at the real pivot time, so an HTF level sits where it actually formed and runs horizontally across the whole chart.
Key settings
Pivot length — the master sensitivity control. Lower = a finer zigzag and more, smaller levels; higher = only the major structure.
Swing source — wicks (high/low) or candle bodies (open/close) to ignore wick spikes.
Zigzag follows levels timeframe — keep trend line and levels on one structure, or decouple the zigzag onto the chart timeframe.
Independent colours, line styles, widths, and a per-side cap on untested levels.
Notes
This is a visualisation of structure, not a signal or strategy — it says nothing about profitability; validate separately.
Repainting. Swings confirm pivot length bars after the fact, and the live leg moves with price until a new pivot confirms.
Not financial advice.
リリースノート
Bug Fixes リリースノート
Better trend detection. Use Pivot length option to change sensitivityリリースノート
english settings リリースノート
Alerts on gained and lost levels オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。