OPEN-SOURCE SCRIPT
Trend & Pullback %

Trend & Pullback %
This indicator breaks price action into a simple sequence of legs — trend moves and pullbacks — and labels the percentage size of each one directly on the chart, so you can see at a glance how far the market ran before it corrected, and how far it corrected before resuming.
How it works
The script tracks consecutive candle direction to identify when a trend leg (green candles) is building and when it flips into a pullback leg (red candles).
When direction reverses, the leg that just ended is closed out and labeled with its % move — measured from where that leg started to its extreme (the high for a trend leg, the low for a pullback).
Each new leg always starts exactly where the previous one finished, so a pullback is measured from the prior trend's top, and the next trend leg is measured from that pullback's bottom — giving you a continuous, non-overlapping read of the swing structure.
A live label on the current bar shows the running % of whatever leg is still forming.
Separately, whenever N consecutive same-colored candles occur (default: 5, adjustable), a "Run" label shows the total % move across just that streak — useful for spotting momentum bursts independent of the broader swing.
Inputs
Consecutive candle count for run labels
Toggle leg labels, run labels, and the live running-% label
Minimum leg % filter (hides small/noisy legs)
Custom colors for trend vs. pullback legs
Notes
Works on any symbol and timeframe.
This is a visual/analytical tool for reading trend and pullback structure, not a buy/sell signal generator — use it alongside your own strategy and risk management.
This indicator breaks price action into a simple sequence of legs — trend moves and pullbacks — and labels the percentage size of each one directly on the chart, so you can see at a glance how far the market ran before it corrected, and how far it corrected before resuming.
How it works
The script tracks consecutive candle direction to identify when a trend leg (green candles) is building and when it flips into a pullback leg (red candles).
When direction reverses, the leg that just ended is closed out and labeled with its % move — measured from where that leg started to its extreme (the high for a trend leg, the low for a pullback).
Each new leg always starts exactly where the previous one finished, so a pullback is measured from the prior trend's top, and the next trend leg is measured from that pullback's bottom — giving you a continuous, non-overlapping read of the swing structure.
A live label on the current bar shows the running % of whatever leg is still forming.
Separately, whenever N consecutive same-colored candles occur (default: 5, adjustable), a "Run" label shows the total % move across just that streak — useful for spotting momentum bursts independent of the broader swing.
Inputs
Consecutive candle count for run labels
Toggle leg labels, run labels, and the live running-% label
Minimum leg % filter (hides small/noisy legs)
Custom colors for trend vs. pullback legs
Notes
Works on any symbol and timeframe.
This is a visual/analytical tool for reading trend and pullback structure, not a buy/sell signal generator — use it alongside your own strategy and risk management.
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。