OPEN-SOURCE SCRIPT
Trendline Break Detector [TBD]

# Trendline Break Detector [TBD]
A structural analysis indicator that identifies pivot trendline breaks across three independent pivot tiers (Fast / Medium / Slow) and rates every break with a single 0–12 Break Strength score. The score summarises both the quality of the break itself and the broader trend context surrounding it.
This is a structural analysis tool, not a signal generator. It marks where pivot structures break and how cleanly. It does not place trades or suggest entries, exits, targets, stops, or position sizes. The arrows are descriptive annotations of market structure.
────────────────────────────────────
WHAT THE INDICATOR DRAWS
────────────────────────────────────
• Swing trendlines built from pivot points, at three configurable timescales (Fast / Medium / Slow tiers, default lengths 8 / 21 / 34) drawn simultaneously
• Direction arrow labels at the exact bar where each pivot trendline is broken, showing:
- The tier's pivot length (e.g. 21)
- The direction arrow (▲ upward break / ▼ downward break)
- The Break Strength score (e.g. ·9) in the range 0–12
• Confluence S/R zones (optional) — coloured boxes showing where multiple support/resistance sources cluster together, scored 0–10
• Status Panel — a compact 5-row overlay summarising active tiers, the most recent break, its score, current trend context (VWAP, ER, HTF), and how many filter gates are active
────────────────────────────────────
WHY FIBONACCI PIVOT LENGTHS (8 / 21 / 34)?
────────────────────────────────────
The three default tier lengths are not arbitrary — they are consecutive terms from the Fibonacci sequence (1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144 ...). Three properties of the Fibonacci sequence make it especially well suited to a multi-tier pivot indicator:
1. The ratio between consecutive terms approaches the golden ratio (φ ≈ 1.618).
8 → 21 is roughly 2.6× (skipping a term gives the φ² ratio of ~2.618), and 21 → 34 is roughly 1.62× (φ itself). This means each tier is meaningfully separated from the next on a logarithmic scale, so the three tiers detect genuinely different timescales of structure rather than near-duplicates. If you used 8 / 10 / 12 instead, all three tiers would fire on essentially the same pivots.
2. Fibonacci-spaced lookbacks produce naturally diverse signals.
A pivot of length N requires N bars on each side without a higher high (or lower low). Fibonacci spacing ensures that the bar requirement at each tier grows non-linearly: the Fast tier (8) reacts to short-term swings, the Medium tier (21) to swings roughly half an hour to a few hours apart on intraday charts, and the Slow tier (34) to the major intraday or multi-session structure.
3. Fibonacci numbers and ratios are deeply established in technical analysis literature.
Pivot lengths drawn from Fibonacci values are widely used because they produce repeatable, recognisable swing structures across many instruments. The 8 / 21 / 34 choice is a balanced midpoint of the sequence — small enough to catch intraday structure, large enough to filter out tick-level noise.
You can override the defaults. All three tier lengths are exposed as inputs (Pivot Lengths group). If you prefer Wilder's classic 14, a tighter set like 5 / 13 / 21, or a slower set like 13 / 34 / 89, simply change them.
────────────────────────────────────
MULTI-INSTANCE TECHNIQUE FOR HIGHER-TIMEFRAME CONTEXT
(RECOMMENDED FOR LOW TIMEFRAMES)
────────────────────────────────────
The indicator's three tiers cover roughly one decade of timescale separation (8 → 34 is ~4×). On very low timeframes — 1m, 3m, 5m — that single decade often is not enough to see the whole structural picture. The Fast tier (length 8 on 1m = ~8 minutes) and the Slow tier (length 34 on 1m = ~34 minutes) both live inside what a 15m or 1H trader would consider a single bar.
The cleanest way to get true multi-timeframe context without changing chart is to apply the indicator multiple times to the same chart with different pivot length sets, like this:
| Instance | Fast | Medium | Slow | What it captures (on a 1-minute chart) |
|---|---|---|---|---|
| 1 — Local | 8 | 21 | 34 | Sub-minute to ~30-minute structure |
| 2 — Intermediate | 21 | 34 | 55 | ~20-minute to ~1-hour structure |
| 3 — Context | 34 | 89 | 144 | ~30-minute to ~2.5-hour structure |
All three instances run on the same 1-minute chart, but each one sees a different timescale of structure. The lengths share consecutive Fibonacci values across instances (34 appears in all three; 21 in two; 55 in two), so the tiers chain together coherently rather than fighting each other.
How to read the stacked instances:
• When a high-score break fires on Instance 3 (slowest), you are seeing a major structural event on a higher timeframe — the kind of break that typically initiates trends.
• When a high-score break on Instance 1 (fastest) lines up with the direction of recent Instance 2 / Instance 3 breaks, the smaller break is occurring with-trend on the higher timeframe.
• When Instance 1 breaks against the established Instance 3 direction, treat it as a counter-trend or mean-reversion event.
Practical setup tips:
• Disable the Status Panel on two of the three instances (Settings → Status Panel → Show Status Panel) to avoid stacked panels. Keep it visible only on the most-watched instance.
• Use the Style settings to give each instance a slightly different colour so the labels remain distinguishable on the chart.
• Disable trendline drawing on the faster instances if the chart gets cluttered (Trendlines → Show Trendlines off) — you can still see the break arrows.
This stacking technique gives you genuine higher-timeframe structural context without ever switching timeframes, which is particularly useful for scalpers and intraday traders who want to read the higher-TF tape while watching execution-grade bars.
────────────────────────────────────
HOW TO INTERPRET THE BREAK STRENGTH SCORE (0–12)
────────────────────────────────────
The score is a descriptive summary of structural properties, not a probability of profit or a recommendation. Higher scores indicate that the break occurred with more of the supporting structural conditions in place (and earlier in the broader trend). They do not guarantee the move continues.
A useful way to read the score band by band:
| Score | Band | What it means structurally |
|---|---|---|
| 0–3 | Very Low | The break occurred without most supporting conditions — small magnitude, low volume, weak pivot, or strong intrabar rejection. Often these are wicks, false breaks, or last-leg moves in already-extended trends. Treat with caution. |
| 4–6 | Low | Some quality conditions met but several are missing. The break is real but unremarkable. Common in chop or transitional regimes. |
| 7–8 | Medium | The break meets most of the structural quality criteria — meaningful magnitude, decent participation, reasonable pivot height. The trend context is mixed (not strongly established yet, not absent). These are the bread-and-butter breaks. |
| 9–10 | High | Most Break Quality criteria are met AND the break occurs ahead of (or at) a structural inflection rather than late in an established trend. These tend to be the cleanest setups the indicator flags. |
| 11–12 | Very High | All-or-near-all Break Quality criteria fire AND the broader trend is not yet established in the break direction — i.e., the break itself is the structural turn. Rare. |
Important nuances about the score:
1. The score is path-dependent on which filter gates you have active.
If you turn off every filter, you will see every break the engine detects regardless of score. If you turn on stringent filters (Adaptive Trail Strict, VWAP Require-strong-aligned, Confluence Zone gate), you will only see breaks that already pass those gates, and the displayed scores will tend to skew higher. Pick a filter configuration and stick with it so the scores remain comparable across your charts.
2. Higher score ≠ better trade.
A high score means the break occurred with strong structural properties. Whether that creates a tradeable opportunity depends entirely on your strategy, risk management, position sizing, and the current market regime. A score of 10 in a choppy range is still a break in a choppy range.
3. The (5 − Trend Context) inversion deliberately penalises late breaks.
A perfectly clean break in an already-established trend will score lower than the same clean break at a fresh turning point. This is intentional: the indicator's design thesis is that quality breaks occur AT structural inflection points, not after them. If you prefer with-trend breakouts to count fully, disable the Trend Context component in the inputs and the score will become Break Quality alone (range 0–7).
4. The score is computed on bar close.
Mid-bar values shown intrabar may revise before close. Treat the displayed score as final only after the bar closes.
5. Compare scores within the same symbol and timeframe.
Because ATR and volume have different magnitudes across symbols and timeframes, comparing a score of 8 on EURUSD-1m to a score of 8 on BTCUSD-1h is not strictly apples-to-apples. The score is most informative as a relative measure within a single chart context.
6. Combine score with tier.
A score of 8 on the Slow tier represents a higher-significance structural event than a score of 8 on the Fast tier, because the Slow-tier trendline took longer to build and represents broader structure. When reading the chart, weight Slow-tier breaks more heavily than Fast-tier breaks at the same score.
7. Use the multi-instance technique to validate scores.
When using three stacked instances (as described above), the most informative situations are those where a high score on the slower instance (e.g. Context 34/89/144) lines up directionally with a high score on the faster instance (e.g. Local 8/21/34). Alignment across instances is a stronger signal than any single instance's score in isolation.
────────────────────────────────────
WHY THIS IS A MASHUP, AND WHY THE COMPONENTS BELONG TOGETHER
────────────────────────────────────
A trendline break, on its own, is a low-information event. The same break can be either a high-quality structural rupture from a long compressed base, or a meaningless poke through a noise-level pivot inside chop. To tell those apart in a reproducible way, you need to measure several independent properties of the break event AND the trend context surrounding it.
This script combines the components below for that single purpose. Each one answers a question the others cannot answer alone. Every one of them feeds into the final 0–12 Break Strength score.
1. Multi-tier swing pivot engine (three parallel tiers)
The core. Builds and tracks pivot-based trendlines at three configurable timescales simultaneously and detects when each is broken. Each tier runs an independent state machine. Three tiers exist because breaks of micro-structure, intermediate structure, and major structure carry very different meaning.
2. ATR (Average True Range)
The volatility yardstick. Used to normalise break magnitude, pivot height, and range expansion across symbols and timeframes. ATR shows up in four of the seven Break Quality components.
3. Kaufman Efficiency Ratio (ER)
Computed as:
|close − close[N]| / sum(|close − close[1]|, N)
Detects pre-break compression: low ER (chop) followed by rising ER (release) = coiled-spring break setup. Answers a question no other component answers — what was the market doing in the bars leading up to this break?
4. Volume vs 20-bar SMA
Confirms participation at the break. A break with above-average volume is structurally different from a break on dead volume.
5. Session VWAP gradient
Standard session-anchored VWAP, plus the slope of VWAP normalised to ATR units. A pivot break aligned with a strongly trending VWAP is occurring within an established VWAP-axis trend; one against it is counter-trend.
6. Adaptive trailing stop, multi-timeframe composite bias
An adaptive trailing stop whose ATR length is dynamically set using Kaufman's Efficiency Ratio (the same adaptation mechanism used in KAMA). The stop is computed on chart, 3×, 5×, and 15× timeframes; each contributes a weighted ±1 to a composite directional score in the range −10 to +10. One number summarises whether four timeframes agree.
7. Chandelier-style trailing stop, multi-timeframe convergence
A second, independent multi-timeframe trend check. Standard Chandelier stops on chart / 3× / 5× / 15× are computed; the standard deviation of those four stop prices is measured and normalised to ATR. Low dispersion = all timeframes agree. The adaptive composite (#6) and the Chandelier convergence (#7) cross-check the same question via two different mechanisms.
8. Higher-timeframe pivot structure (HH+HL / LH+LL on 3×, 5×, 15×)
Direct HTF market-structure read using ta.pivothigh / ta.pivotlow on the HTF series. Independent of any moving-average / stop / VWAP framework — purely pivot-sequence based.
9. Chart-timeframe pivot structure
The same pivot-sequence test on the chart timeframe itself, using its own configurable pivot length, independent of the trendline engine.
10. Confluence-based support/resistance zone engine
A zone builder that combines volume profile (POC, VAH, VAL), high-activity bars (top-percentile volume and range), native swing pivots, and multi-HTF pivots into clustered, scored zones. Available as a visual layer and as an optional filter gate.
────────────────────────────────────
HOW THEY COMPOSE INTO ONE NUMBER
────────────────────────────────────
Break Strength = Break Quality (0–7) + (5 − Trend Context) (0–5)
Range: 0–12
Break Quality (0–7) is the sum of seven independent properties of the break event itself:
| # | Component | What it measures |
|---|---|---|
| 1 | ER compression-then-release | Coiled-spring pre-break setup |
| 2 | Break magnitude ≥ N × ATR | Decisiveness of the break |
| 3 | Volume ≥ N × 20-bar SMA | Participation at the break |
| 4 | ≥ N bars since prior same-dir pivot | Trendline duration / base length |
| 5 | Pivot height ≥ N × ATR | Quality of the trendline being broken |
| 6 | Range expansion (TR > N×ATR, ATR rising) | Range-based expansion at break |
| 7 | Anti-Wick check | Close in favourable 30% of bar |
Trend Context (0–5) measures whether the broader trend is already established:
| # | Component | What it measures |
|---|---|---|
| 1 | Recent same-dir Slow tier signal | Slowest tier already confirmed direction |
| 2 | Adaptive Trail aligned | Multi-TF adaptive-stop framework agrees |
| 3 | VWAP gradient strongly aligned | Session VWAP slope agrees |
| 4 | Chandelier stop convergence high | All TFs agree on trend state |
| 5 | Chart-TF HH+HL aligned | Chart pivot sequence agrees |
Why Trend Context is INVERTED:
When the broader trend is already firmly established, the break is occurring late in the move and receives a lower bonus. When the context is mixed or transitioning, the bonus is higher. The thesis: quality breaks occur AT structural inflection points, not after them. If you prefer with-trend breakouts to count fully, disable Trend Context in inputs (the composite then becomes Break Quality alone, range 0–7).
────────────────────────────────────
HOW TO USE IT (PRACTICAL WORKFLOW)
────────────────────────────────────
1. Apply to any chart and timeframe.
All defaults are sensible.
2. Read the on-bar arrow labels:
Tier length + direction + Break Strength score. The Status Panel summarises the most recent break.
3. Start with default filters:
VWAP Gradient Filter ON, Adaptive / HTF / LTF / Volume / Confluence gates OFF. Add gates one at a time to suit your trading style.
4. Higher score = stronger structural break,
read alongside the score-band guide above. Do not treat any score as a buy/sell signal on its own.
5. For lower timeframes,
consider the multi-instance stacking technique described above (8/21/34, 21/34/55, 34/89/144) to add higher-TF context without leaving your execution chart.
6. Use the Confluence S/R zones (if enabled)
to see where breaks line up with major confluence levels. Breaks at strong zones behave differently from breaks in empty space.
────────────────────────────────────
FILTER GATE QUICK REFERENCE
────────────────────────────────────
| Gate | When to enable |
|---|---|
| VWAP Gradient Filter | Default ON. Suppresses breaks against a strongly trending session VWAP. |
| Adaptive Trail Bias Gate | Enable if you want to see only breaks aligned with multi-TF directional consensus. |
| HTF Anchor (HH+HL / LH+LL) | Enable to require recent pivot sequence confirmation. |
| LTF Pivot Break | Enable to require the close to clear the opposing pivot. |
| Volume Surge | Enable to require top-percentile volume on the break bar. |
| Confluence Zone Gate | Enable to require the break to occur near a strong S/R zone. |
Each filter, when enabled, suppresses arrow labels for breaks that do not meet that criterion. Filters compose multiplicatively — turning on three filters at once will significantly reduce the number of breaks displayed.
────────────────────────────────────
WHAT IS ORIGINAL ABOUT THIS INDICATOR
────────────────────────────────────
• The inverted-context composite score — Break Quality summed with (5 − Trend Context) — is the novel contribution. Most multi-component scorers reward aligned context as a bonus; this one penalises it on the explicit thesis that early breaks score higher than late breaks.
• The seven Break Quality components are designed to be independent — no component overlaps with another on the same surface, and none measures established trend (that is the job of the inverted Trend Context score).
• Three pivot tiers run in parallel with independent state machines, rather than the more common single-tier approach.
• Two independent multi-timeframe trend reads (adaptive-stop composite + Chandelier convergence) cross-check rather than relying on a single MTF mechanism.
• The confluence S/R engine combines volume profile, percentile-and-consensus-based high-activity bar detection, native pivots, and up to three HTF pivot streams into a single 0–10 zone-strength score.
────────────────────────────────────
TECHNICAL NOTES
────────────────────────────────────
• Pine Script v6
• Non-repainting: structural break events confirm at bar close
• No lookahead: barmerge.lookahead_off on all request.security calls
• HTF reads are one-way: chart-TF computations never depend on HTF state in a way that would change historical bars
• Max line / label / box counts set high to handle dense trendline tiers
• Compatible with TradingView's House Rules and Pine publishing standards
────────────────────────────────────
IMPORTANT RISK DISCLOSURE
────────────────────────────────────
This indicator is provided for educational and informational purposes only. It is not financial advice, investment advice, a trading system, or a recommendation to buy, sell, or hold any financial instrument.
Trading and investing involve substantial risk of loss, including the possible loss of all invested capital. The structural break events highlighted by this indicator are observations of market behaviour, not predictions of future price movement. The Break Strength score is a descriptive summary of structural properties, not an indication of profitability, win rate, expected return, or risk-adjusted performance.
No backtested or hypothetical performance is claimed or implied by any element of this indicator or its description. Past structural break events identified by the indicator are not indicative of future results. The arrows, scores, and zones are analytical annotations, not trade signals.
You are solely responsible for any trading decisions you make. Always conduct your own research, use appropriate risk management, size positions according to your own risk tolerance, and consider consulting a licensed financial advisor before making investment decisions. Do not trade with money you cannot afford to lose.
By using this indicator you acknowledge that the author bears no responsibility for any losses, missed gains, or other consequences arising from its use.
A structural analysis indicator that identifies pivot trendline breaks across three independent pivot tiers (Fast / Medium / Slow) and rates every break with a single 0–12 Break Strength score. The score summarises both the quality of the break itself and the broader trend context surrounding it.
This is a structural analysis tool, not a signal generator. It marks where pivot structures break and how cleanly. It does not place trades or suggest entries, exits, targets, stops, or position sizes. The arrows are descriptive annotations of market structure.
────────────────────────────────────
WHAT THE INDICATOR DRAWS
────────────────────────────────────
• Swing trendlines built from pivot points, at three configurable timescales (Fast / Medium / Slow tiers, default lengths 8 / 21 / 34) drawn simultaneously
• Direction arrow labels at the exact bar where each pivot trendline is broken, showing:
- The tier's pivot length (e.g. 21)
- The direction arrow (▲ upward break / ▼ downward break)
- The Break Strength score (e.g. ·9) in the range 0–12
• Confluence S/R zones (optional) — coloured boxes showing where multiple support/resistance sources cluster together, scored 0–10
• Status Panel — a compact 5-row overlay summarising active tiers, the most recent break, its score, current trend context (VWAP, ER, HTF), and how many filter gates are active
────────────────────────────────────
WHY FIBONACCI PIVOT LENGTHS (8 / 21 / 34)?
────────────────────────────────────
The three default tier lengths are not arbitrary — they are consecutive terms from the Fibonacci sequence (1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144 ...). Three properties of the Fibonacci sequence make it especially well suited to a multi-tier pivot indicator:
1. The ratio between consecutive terms approaches the golden ratio (φ ≈ 1.618).
8 → 21 is roughly 2.6× (skipping a term gives the φ² ratio of ~2.618), and 21 → 34 is roughly 1.62× (φ itself). This means each tier is meaningfully separated from the next on a logarithmic scale, so the three tiers detect genuinely different timescales of structure rather than near-duplicates. If you used 8 / 10 / 12 instead, all three tiers would fire on essentially the same pivots.
2. Fibonacci-spaced lookbacks produce naturally diverse signals.
A pivot of length N requires N bars on each side without a higher high (or lower low). Fibonacci spacing ensures that the bar requirement at each tier grows non-linearly: the Fast tier (8) reacts to short-term swings, the Medium tier (21) to swings roughly half an hour to a few hours apart on intraday charts, and the Slow tier (34) to the major intraday or multi-session structure.
3. Fibonacci numbers and ratios are deeply established in technical analysis literature.
Pivot lengths drawn from Fibonacci values are widely used because they produce repeatable, recognisable swing structures across many instruments. The 8 / 21 / 34 choice is a balanced midpoint of the sequence — small enough to catch intraday structure, large enough to filter out tick-level noise.
You can override the defaults. All three tier lengths are exposed as inputs (Pivot Lengths group). If you prefer Wilder's classic 14, a tighter set like 5 / 13 / 21, or a slower set like 13 / 34 / 89, simply change them.
────────────────────────────────────
MULTI-INSTANCE TECHNIQUE FOR HIGHER-TIMEFRAME CONTEXT
(RECOMMENDED FOR LOW TIMEFRAMES)
────────────────────────────────────
The indicator's three tiers cover roughly one decade of timescale separation (8 → 34 is ~4×). On very low timeframes — 1m, 3m, 5m — that single decade often is not enough to see the whole structural picture. The Fast tier (length 8 on 1m = ~8 minutes) and the Slow tier (length 34 on 1m = ~34 minutes) both live inside what a 15m or 1H trader would consider a single bar.
The cleanest way to get true multi-timeframe context without changing chart is to apply the indicator multiple times to the same chart with different pivot length sets, like this:
| Instance | Fast | Medium | Slow | What it captures (on a 1-minute chart) |
|---|---|---|---|---|
| 1 — Local | 8 | 21 | 34 | Sub-minute to ~30-minute structure |
| 2 — Intermediate | 21 | 34 | 55 | ~20-minute to ~1-hour structure |
| 3 — Context | 34 | 89 | 144 | ~30-minute to ~2.5-hour structure |
All three instances run on the same 1-minute chart, but each one sees a different timescale of structure. The lengths share consecutive Fibonacci values across instances (34 appears in all three; 21 in two; 55 in two), so the tiers chain together coherently rather than fighting each other.
How to read the stacked instances:
• When a high-score break fires on Instance 3 (slowest), you are seeing a major structural event on a higher timeframe — the kind of break that typically initiates trends.
• When a high-score break on Instance 1 (fastest) lines up with the direction of recent Instance 2 / Instance 3 breaks, the smaller break is occurring with-trend on the higher timeframe.
• When Instance 1 breaks against the established Instance 3 direction, treat it as a counter-trend or mean-reversion event.
Practical setup tips:
• Disable the Status Panel on two of the three instances (Settings → Status Panel → Show Status Panel) to avoid stacked panels. Keep it visible only on the most-watched instance.
• Use the Style settings to give each instance a slightly different colour so the labels remain distinguishable on the chart.
• Disable trendline drawing on the faster instances if the chart gets cluttered (Trendlines → Show Trendlines off) — you can still see the break arrows.
This stacking technique gives you genuine higher-timeframe structural context without ever switching timeframes, which is particularly useful for scalpers and intraday traders who want to read the higher-TF tape while watching execution-grade bars.
────────────────────────────────────
HOW TO INTERPRET THE BREAK STRENGTH SCORE (0–12)
────────────────────────────────────
The score is a descriptive summary of structural properties, not a probability of profit or a recommendation. Higher scores indicate that the break occurred with more of the supporting structural conditions in place (and earlier in the broader trend). They do not guarantee the move continues.
A useful way to read the score band by band:
| Score | Band | What it means structurally |
|---|---|---|
| 0–3 | Very Low | The break occurred without most supporting conditions — small magnitude, low volume, weak pivot, or strong intrabar rejection. Often these are wicks, false breaks, or last-leg moves in already-extended trends. Treat with caution. |
| 4–6 | Low | Some quality conditions met but several are missing. The break is real but unremarkable. Common in chop or transitional regimes. |
| 7–8 | Medium | The break meets most of the structural quality criteria — meaningful magnitude, decent participation, reasonable pivot height. The trend context is mixed (not strongly established yet, not absent). These are the bread-and-butter breaks. |
| 9–10 | High | Most Break Quality criteria are met AND the break occurs ahead of (or at) a structural inflection rather than late in an established trend. These tend to be the cleanest setups the indicator flags. |
| 11–12 | Very High | All-or-near-all Break Quality criteria fire AND the broader trend is not yet established in the break direction — i.e., the break itself is the structural turn. Rare. |
Important nuances about the score:
1. The score is path-dependent on which filter gates you have active.
If you turn off every filter, you will see every break the engine detects regardless of score. If you turn on stringent filters (Adaptive Trail Strict, VWAP Require-strong-aligned, Confluence Zone gate), you will only see breaks that already pass those gates, and the displayed scores will tend to skew higher. Pick a filter configuration and stick with it so the scores remain comparable across your charts.
2. Higher score ≠ better trade.
A high score means the break occurred with strong structural properties. Whether that creates a tradeable opportunity depends entirely on your strategy, risk management, position sizing, and the current market regime. A score of 10 in a choppy range is still a break in a choppy range.
3. The (5 − Trend Context) inversion deliberately penalises late breaks.
A perfectly clean break in an already-established trend will score lower than the same clean break at a fresh turning point. This is intentional: the indicator's design thesis is that quality breaks occur AT structural inflection points, not after them. If you prefer with-trend breakouts to count fully, disable the Trend Context component in the inputs and the score will become Break Quality alone (range 0–7).
4. The score is computed on bar close.
Mid-bar values shown intrabar may revise before close. Treat the displayed score as final only after the bar closes.
5. Compare scores within the same symbol and timeframe.
Because ATR and volume have different magnitudes across symbols and timeframes, comparing a score of 8 on EURUSD-1m to a score of 8 on BTCUSD-1h is not strictly apples-to-apples. The score is most informative as a relative measure within a single chart context.
6. Combine score with tier.
A score of 8 on the Slow tier represents a higher-significance structural event than a score of 8 on the Fast tier, because the Slow-tier trendline took longer to build and represents broader structure. When reading the chart, weight Slow-tier breaks more heavily than Fast-tier breaks at the same score.
7. Use the multi-instance technique to validate scores.
When using three stacked instances (as described above), the most informative situations are those where a high score on the slower instance (e.g. Context 34/89/144) lines up directionally with a high score on the faster instance (e.g. Local 8/21/34). Alignment across instances is a stronger signal than any single instance's score in isolation.
────────────────────────────────────
WHY THIS IS A MASHUP, AND WHY THE COMPONENTS BELONG TOGETHER
────────────────────────────────────
A trendline break, on its own, is a low-information event. The same break can be either a high-quality structural rupture from a long compressed base, or a meaningless poke through a noise-level pivot inside chop. To tell those apart in a reproducible way, you need to measure several independent properties of the break event AND the trend context surrounding it.
This script combines the components below for that single purpose. Each one answers a question the others cannot answer alone. Every one of them feeds into the final 0–12 Break Strength score.
1. Multi-tier swing pivot engine (three parallel tiers)
The core. Builds and tracks pivot-based trendlines at three configurable timescales simultaneously and detects when each is broken. Each tier runs an independent state machine. Three tiers exist because breaks of micro-structure, intermediate structure, and major structure carry very different meaning.
2. ATR (Average True Range)
The volatility yardstick. Used to normalise break magnitude, pivot height, and range expansion across symbols and timeframes. ATR shows up in four of the seven Break Quality components.
3. Kaufman Efficiency Ratio (ER)
Computed as:
|close − close[N]| / sum(|close − close[1]|, N)
Detects pre-break compression: low ER (chop) followed by rising ER (release) = coiled-spring break setup. Answers a question no other component answers — what was the market doing in the bars leading up to this break?
4. Volume vs 20-bar SMA
Confirms participation at the break. A break with above-average volume is structurally different from a break on dead volume.
5. Session VWAP gradient
Standard session-anchored VWAP, plus the slope of VWAP normalised to ATR units. A pivot break aligned with a strongly trending VWAP is occurring within an established VWAP-axis trend; one against it is counter-trend.
6. Adaptive trailing stop, multi-timeframe composite bias
An adaptive trailing stop whose ATR length is dynamically set using Kaufman's Efficiency Ratio (the same adaptation mechanism used in KAMA). The stop is computed on chart, 3×, 5×, and 15× timeframes; each contributes a weighted ±1 to a composite directional score in the range −10 to +10. One number summarises whether four timeframes agree.
7. Chandelier-style trailing stop, multi-timeframe convergence
A second, independent multi-timeframe trend check. Standard Chandelier stops on chart / 3× / 5× / 15× are computed; the standard deviation of those four stop prices is measured and normalised to ATR. Low dispersion = all timeframes agree. The adaptive composite (#6) and the Chandelier convergence (#7) cross-check the same question via two different mechanisms.
8. Higher-timeframe pivot structure (HH+HL / LH+LL on 3×, 5×, 15×)
Direct HTF market-structure read using ta.pivothigh / ta.pivotlow on the HTF series. Independent of any moving-average / stop / VWAP framework — purely pivot-sequence based.
9. Chart-timeframe pivot structure
The same pivot-sequence test on the chart timeframe itself, using its own configurable pivot length, independent of the trendline engine.
10. Confluence-based support/resistance zone engine
A zone builder that combines volume profile (POC, VAH, VAL), high-activity bars (top-percentile volume and range), native swing pivots, and multi-HTF pivots into clustered, scored zones. Available as a visual layer and as an optional filter gate.
────────────────────────────────────
HOW THEY COMPOSE INTO ONE NUMBER
────────────────────────────────────
Break Strength = Break Quality (0–7) + (5 − Trend Context) (0–5)
Range: 0–12
Break Quality (0–7) is the sum of seven independent properties of the break event itself:
| # | Component | What it measures |
|---|---|---|
| 1 | ER compression-then-release | Coiled-spring pre-break setup |
| 2 | Break magnitude ≥ N × ATR | Decisiveness of the break |
| 3 | Volume ≥ N × 20-bar SMA | Participation at the break |
| 4 | ≥ N bars since prior same-dir pivot | Trendline duration / base length |
| 5 | Pivot height ≥ N × ATR | Quality of the trendline being broken |
| 6 | Range expansion (TR > N×ATR, ATR rising) | Range-based expansion at break |
| 7 | Anti-Wick check | Close in favourable 30% of bar |
Trend Context (0–5) measures whether the broader trend is already established:
| # | Component | What it measures |
|---|---|---|
| 1 | Recent same-dir Slow tier signal | Slowest tier already confirmed direction |
| 2 | Adaptive Trail aligned | Multi-TF adaptive-stop framework agrees |
| 3 | VWAP gradient strongly aligned | Session VWAP slope agrees |
| 4 | Chandelier stop convergence high | All TFs agree on trend state |
| 5 | Chart-TF HH+HL aligned | Chart pivot sequence agrees |
Why Trend Context is INVERTED:
When the broader trend is already firmly established, the break is occurring late in the move and receives a lower bonus. When the context is mixed or transitioning, the bonus is higher. The thesis: quality breaks occur AT structural inflection points, not after them. If you prefer with-trend breakouts to count fully, disable Trend Context in inputs (the composite then becomes Break Quality alone, range 0–7).
────────────────────────────────────
HOW TO USE IT (PRACTICAL WORKFLOW)
────────────────────────────────────
1. Apply to any chart and timeframe.
All defaults are sensible.
2. Read the on-bar arrow labels:
Tier length + direction + Break Strength score. The Status Panel summarises the most recent break.
3. Start with default filters:
VWAP Gradient Filter ON, Adaptive / HTF / LTF / Volume / Confluence gates OFF. Add gates one at a time to suit your trading style.
4. Higher score = stronger structural break,
read alongside the score-band guide above. Do not treat any score as a buy/sell signal on its own.
5. For lower timeframes,
consider the multi-instance stacking technique described above (8/21/34, 21/34/55, 34/89/144) to add higher-TF context without leaving your execution chart.
6. Use the Confluence S/R zones (if enabled)
to see where breaks line up with major confluence levels. Breaks at strong zones behave differently from breaks in empty space.
────────────────────────────────────
FILTER GATE QUICK REFERENCE
────────────────────────────────────
| Gate | When to enable |
|---|---|
| VWAP Gradient Filter | Default ON. Suppresses breaks against a strongly trending session VWAP. |
| Adaptive Trail Bias Gate | Enable if you want to see only breaks aligned with multi-TF directional consensus. |
| HTF Anchor (HH+HL / LH+LL) | Enable to require recent pivot sequence confirmation. |
| LTF Pivot Break | Enable to require the close to clear the opposing pivot. |
| Volume Surge | Enable to require top-percentile volume on the break bar. |
| Confluence Zone Gate | Enable to require the break to occur near a strong S/R zone. |
Each filter, when enabled, suppresses arrow labels for breaks that do not meet that criterion. Filters compose multiplicatively — turning on three filters at once will significantly reduce the number of breaks displayed.
────────────────────────────────────
WHAT IS ORIGINAL ABOUT THIS INDICATOR
────────────────────────────────────
• The inverted-context composite score — Break Quality summed with (5 − Trend Context) — is the novel contribution. Most multi-component scorers reward aligned context as a bonus; this one penalises it on the explicit thesis that early breaks score higher than late breaks.
• The seven Break Quality components are designed to be independent — no component overlaps with another on the same surface, and none measures established trend (that is the job of the inverted Trend Context score).
• Three pivot tiers run in parallel with independent state machines, rather than the more common single-tier approach.
• Two independent multi-timeframe trend reads (adaptive-stop composite + Chandelier convergence) cross-check rather than relying on a single MTF mechanism.
• The confluence S/R engine combines volume profile, percentile-and-consensus-based high-activity bar detection, native pivots, and up to three HTF pivot streams into a single 0–10 zone-strength score.
────────────────────────────────────
TECHNICAL NOTES
────────────────────────────────────
• Pine Script v6
• Non-repainting: structural break events confirm at bar close
• No lookahead: barmerge.lookahead_off on all request.security calls
• HTF reads are one-way: chart-TF computations never depend on HTF state in a way that would change historical bars
• Max line / label / box counts set high to handle dense trendline tiers
• Compatible with TradingView's House Rules and Pine publishing standards
────────────────────────────────────
IMPORTANT RISK DISCLOSURE
────────────────────────────────────
This indicator is provided for educational and informational purposes only. It is not financial advice, investment advice, a trading system, or a recommendation to buy, sell, or hold any financial instrument.
Trading and investing involve substantial risk of loss, including the possible loss of all invested capital. The structural break events highlighted by this indicator are observations of market behaviour, not predictions of future price movement. The Break Strength score is a descriptive summary of structural properties, not an indication of profitability, win rate, expected return, or risk-adjusted performance.
No backtested or hypothetical performance is claimed or implied by any element of this indicator or its description. Past structural break events identified by the indicator are not indicative of future results. The arrows, scores, and zones are analytical annotations, not trade signals.
You are solely responsible for any trading decisions you make. Always conduct your own research, use appropriate risk management, size positions according to your own risk tolerance, and consider consulting a licensed financial advisor before making investment decisions. Do not trade with money you cannot afford to lose.
By using this indicator you acknowledge that the author bears no responsibility for any losses, missed gains, or other consequences arising from its use.
สคริปต์แบบโอเพนซอร์ส
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์แบบโอเพนซอร์ส
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน