OPEN-SOURCE SCRIPT

TRAPPER TRENDLINES — PRICE

138
Draws dynamic trendlines on price by connecting the two most recent confirmed swing points (highs to highs for resistance, lows to lows for support). Swings are defined with a symmetric left/right pivot window. Old anchors are ignored so lines stay attached to current structure. Optional break alerts are included.

How it works (plain language)

Pivots: A bar is a swing high (or low) only if it’s the most extreme point compared with a set number of bars on the left and the right.

Lines:

Support connects the last two confirmed swing lows.

Resistance connects the last two confirmed swing highs.

Lines can be extended right only or both left & right (toggle).

Recency filter: Only swings within the last N bars are kept. This avoids anchoring to very old pivots far from current price.

Alerts: Optional alerts fire when price closes above resistance or below support.

Inputs

Auto Settings

Auto pivot size by chart timeframe: When ON, the script picks a pivot size suitable for the current timeframe (you can scale it with Auto pivot multiplier). When OFF, the manual left/right inputs are used.

Auto pivot multiplier: Scales the auto pivot size (e.g., 1.5 makes pivots stricter).

Manual Pivots

Pivot Left / Pivot Right: Bars to the left/right required to confirm a swing. Example: Left=50 & Right=50 keeps only major swings.

Recency Filter

Use last N bars for pivots: Swings older than this window are discarded so trendlines stay relevant to current price.

Style

Support/Resistance color: Line colors.

Extend Left & Right: When ON, both endpoints extend; when OFF, lines extend to the right only.

Alerts

Enable Break Alerts: When ON, alert conditions are exposed:

Price: Break Up — close above resistance.

Price: Break Down — close below support.

Suggested settings

Higher timeframes (4H / 1D / 1W):

Manual: Pivot Left = 50, Pivot Right = 50, Use last N bars = 400–800.

Or enable Auto with Auto pivot multiplier = 1.0–1.5.

Intraday (15m / 30m / 1H):

Manual: Pivot Left = 30, Pivot Right = 30, Use last N bars = 300–500.

Or enable Auto with multiplier ≈ 1.0–1.2.

Pairing with RSI for confluence/divergence

This tool is designed to pair with a companion TRAPPER TRENDLINES — RSI (or any RSI trendline script):

To mirror swings, set RSI Pivot Lookback equal to the price Pivot Left/Right you use here.

Example: Price = 50/50 → RSI Pivot Lookback = 50.

Keep RSI at Length 14 with 70/30 channel for clarity.

Confluence: Price holds/rejects at a trendline while RSI trendline agrees.

Divergence: Price prints a higher high (resistance line rising) while RSI prints a lower high (RSI resistance line falling), or vice-versa for lows. Matching pivot windows makes these relationships clear and reduces false signals.

Reading the signals

Trendline touch/hold: Potential reaction area; wait for follow-through.

Break Up / Break Down (alerts): Close beyond the line. Consider retest behavior, higher-timeframe context, and volume/RSI confirmation.

Notes & limitations

Pivots require future bars to confirm (by design). Lines update as pivots confirm.

“Use last N bars” purposely ignores very old swings. Increase this value if you need legacy structure.

Lines are based on two most recent confirmed pivots per side; rapidly changing markets can replace anchors as new swings confirm.

This is a visual/analytical tool. No strategy entries/exits or performance claims are provided.

Compliance

This script is for educational purposes only and does not constitute financial advice. Trading involves risk. Past results do not guarantee future outcomes. No promises of profit, accuracy, or performance are made.

Alerts (titles/messages)

Price: Break Up — “Price broke above resistance trendline.”

Price: Break Down — “Price broke below support trendline.”

Quick start

Add the indicator to your chart.

Choose Auto or set Pivot Left/Right manually.

Set Use last N bars for how far back to consider swings.

Toggle Extend Left & Right to your preference.

(Optional) Add your RSI trendline indicator and match Pivot Lookback with your price pivot size for clean confluence/divergence.

Enable alerts if you want notifications on breaks.

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。