OPEN-SOURCE SCRIPT
Pivot Trendlines • Strength • Breakout

Pivot Trendlines • Strength • Breakout (closed-source)
Purpose. Draws support/resistance lines by connecting confirmed swing pivots, evaluates their strength (touches + relative volume), and marks breakouts. It’s a visual decision aid: it does not place orders or claim performance.
How it works — calculations & rules
1) Confirmed pivots
Pivots use ta.pivothigh/ta.pivotlow with equal left/right lengths (lenHigh, lenLow). They confirm after length bars, which reduces repaint compared to using raw highs/lows.
2) Candidate line between two pivots
For a pivot pair (b1, p1) → (b2, p2) (bar index, price), the line is:
m = (p2 - p1) / (b2 - b1)
c = p1 - m * b1
y(x) = m * x + c
3) Integrity check (between pivots)
For every bar j between b1 and b2, the price must stay within a tolerance:
tol(j) = |y(j)| * (integrityTolPct / 100)
Resistance (pivot highs): violations when high(j) > y(j) + tol(j)
Support (pivot lows): violations when low(j) < y(j) - tol(j)
The line is accepted only if violations ≤ maxCrosses.
Optional slope rule: Resistance requires p2 ≤ p1, Support requires p2 ≥ p1.
4) Strength score → width/color
Touches: Each time current price is within a touch tolerance of the line:
tolTouchNow = |yNow| * (touchTolPct / 100)
touches are counted.
Relative volume factor:
volFactor = (avg volume at the two pivots) / SMA(volume, volLen)
Score: score = wTouches * touches + wVolume * volFactor
The score maps to line width (clamped to maxWidth) and optionally to color intensity, so stronger levels visually stand out.
5) Breakout detection & signals
Compute the live line value yNow = y(bar_index) and thresholds with an optional buffer %:
Resistance: longThresh = yNow * (1 + breakBufPct/100)
Support: shortThresh = yNow * (1 - breakBufPct/100)
A breakout is when price/close crosses the respective threshold; you can confirm on bar close.
Signals can be drawn as triangles (four fixed sizes) or as labels.
6) Line management
To avoid clutter, the script keeps only the most recent N resistance lines and N support lines. After a breakout, lines can be extended for extraBars.
(Implementation specifics like series/array management are proprietary; the above formulas and decision rules disclose the functioning clearly so traders and moderators can understand and evaluate it.)
Why this is original & useful
Integrity-checked levels: Lines must pass tolerance, max-cross and (optionally) slope checks before drawing—reduces noisy, arbitrary lines.
Quantified emphasis: Levels are emphasized by a numeric strength score combining market interaction (touches) and participation (relative volume).
Actionable signaling: Optional buffer & close-confirmation provide practical breakout markers aligned with how discretionary traders validate breaks.
How to use
Start with default pivot lengths (e.g., 50/50) and enable the slope rule.
Tune Integrity Tolerance % and Max Crosses to your instrument/TF (tighter for scalps, looser for swings).
Adjust wTouches / wVolume to emphasize interaction vs. participation; cap visual noise with Max Line Width and line counts.
For breakouts, use a small buffer % and Confirm on close to reduce false signals.
Use the triangle size or labels to match your visual preference.
Inputs (overview)
Pivot Detection: lenHigh, lenLow.
Trendline Integrity (Filters): integrityTolPct, maxCrosses, minBarsBetweenPivots, enforceSlope.
Drawing / Management: showHighs, showLows, extraBars, touchTolPct.
Strength Scoring: maxWidth, volLen, wTouches, wVolume, useColorByStrength.
Breakout Trigger: breakBufPct, confirmClose.
Signal Display: showSignals, signalStyle, sigSize.
Notes & limitations
Pivots confirm after length bars; before confirmation, potential pivots can change (normal for pivot logic).
Indicator = not a strategy; no orders are executed and no performance is implied.
Always forward-test and apply independent risk management.
Purpose. Draws support/resistance lines by connecting confirmed swing pivots, evaluates their strength (touches + relative volume), and marks breakouts. It’s a visual decision aid: it does not place orders or claim performance.
How it works — calculations & rules
1) Confirmed pivots
Pivots use ta.pivothigh/ta.pivotlow with equal left/right lengths (lenHigh, lenLow). They confirm after length bars, which reduces repaint compared to using raw highs/lows.
2) Candidate line between two pivots
For a pivot pair (b1, p1) → (b2, p2) (bar index, price), the line is:
m = (p2 - p1) / (b2 - b1)
c = p1 - m * b1
y(x) = m * x + c
3) Integrity check (between pivots)
For every bar j between b1 and b2, the price must stay within a tolerance:
tol(j) = |y(j)| * (integrityTolPct / 100)
Resistance (pivot highs): violations when high(j) > y(j) + tol(j)
Support (pivot lows): violations when low(j) < y(j) - tol(j)
The line is accepted only if violations ≤ maxCrosses.
Optional slope rule: Resistance requires p2 ≤ p1, Support requires p2 ≥ p1.
4) Strength score → width/color
Touches: Each time current price is within a touch tolerance of the line:
tolTouchNow = |yNow| * (touchTolPct / 100)
touches are counted.
Relative volume factor:
volFactor = (avg volume at the two pivots) / SMA(volume, volLen)
Score: score = wTouches * touches + wVolume * volFactor
The score maps to line width (clamped to maxWidth) and optionally to color intensity, so stronger levels visually stand out.
5) Breakout detection & signals
Compute the live line value yNow = y(bar_index) and thresholds with an optional buffer %:
Resistance: longThresh = yNow * (1 + breakBufPct/100)
Support: shortThresh = yNow * (1 - breakBufPct/100)
A breakout is when price/close crosses the respective threshold; you can confirm on bar close.
Signals can be drawn as triangles (four fixed sizes) or as labels.
6) Line management
To avoid clutter, the script keeps only the most recent N resistance lines and N support lines. After a breakout, lines can be extended for extraBars.
(Implementation specifics like series/array management are proprietary; the above formulas and decision rules disclose the functioning clearly so traders and moderators can understand and evaluate it.)
Why this is original & useful
Integrity-checked levels: Lines must pass tolerance, max-cross and (optionally) slope checks before drawing—reduces noisy, arbitrary lines.
Quantified emphasis: Levels are emphasized by a numeric strength score combining market interaction (touches) and participation (relative volume).
Actionable signaling: Optional buffer & close-confirmation provide practical breakout markers aligned with how discretionary traders validate breaks.
How to use
Start with default pivot lengths (e.g., 50/50) and enable the slope rule.
Tune Integrity Tolerance % and Max Crosses to your instrument/TF (tighter for scalps, looser for swings).
Adjust wTouches / wVolume to emphasize interaction vs. participation; cap visual noise with Max Line Width and line counts.
For breakouts, use a small buffer % and Confirm on close to reduce false signals.
Use the triangle size or labels to match your visual preference.
Inputs (overview)
Pivot Detection: lenHigh, lenLow.
Trendline Integrity (Filters): integrityTolPct, maxCrosses, minBarsBetweenPivots, enforceSlope.
Drawing / Management: showHighs, showLows, extraBars, touchTolPct.
Strength Scoring: maxWidth, volLen, wTouches, wVolume, useColorByStrength.
Breakout Trigger: breakBufPct, confirmClose.
Signal Display: showSignals, signalStyle, sigSize.
Notes & limitations
Pivots confirm after length bars; before confirmation, potential pivots can change (normal for pivot logic).
Indicator = not a strategy; no orders are executed and no performance is implied.
Always forward-test and apply independent risk management.
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。