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提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。