Indicator · Pine Script v4 · On the chart

Extrapolated Pivot Connector

by theonetrade· code credited to alexgrover

Extrapolated Pivot Connector identifies pivot highs and pivot lows over a configurable length and draws extended lines through selected pivot points directly on the price chart.

View on GitHub

Repaints

GitHub stars34on the repository
Pine versionv4older, still runs
Lines of code38
Settings7inputs
LicenceMIT
Last update2 weeks ago8 Nov 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

38 lines of Pine Script v4 from assets/indicator/bit-exact/extrapolated_pivot_connector_lets_make_support_and_resistances_CtjX82Hp.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

extrapolated_pivot_connector_lets_make_support_and_resistances_CtjX82Hp.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © alexgrover
//@version=4
study("Extrapolated Pivot Connector",overlay=true,max_bars_back=5000)
//----
length = input(100)
astart = input(1,"A-High Position"),aend = input(0,"B-High Position")
bstart = input(1,"A-Low Position"),bend = input(0,"B-Low Position")
csrc = input(false,"Use Custom Source ?"),src = input(close,"Custom Source")
//----
up = pivothigh(iff(csrc,src,high),length,length)
dn = pivotlow(iff(csrc,src,low),length,length)
//----
n = bar_index
a1 = valuewhen(not na(up),n,astart)
b1 = valuewhen(not na(dn),n,bstart)
a2 = valuewhen(not na(up),n,aend)
b2 = valuewhen(not na(dn),n,bend)
//----
line upper = line.new(n[n - a1 + length],up[n - a1],n[n - a2 + length],up[n - a2],
  extend=extend.right,color=color.blue,width=2)
line lower = line.new(n[n - b1 + length],dn[n - b1],n[n - b2 + length],dn[n - b2],
  extend=extend.right,color=color.orange,width=2)
line.delete(upper[1])
line.delete(lower[1])
//----
label ahigh = label.new(n[n - a1 + length],up[n - a1],"A-High",
  color=color.blue,style=label.style_labeldown,textcolor=color.white,size=size.small)
label bhigh = label.new(n[n - a2 + length],up[n - a2],"B-High",
  color=color.blue,style=label.style_labeldown,textcolor=color.white,size=size.small)
label alow = label.new(n[n - b1 + length],dn[n - b1],"A-Low",
  color=color.orange,style=label.style_labelup,textcolor=color.white,size=size.small)
label blow = label.new(n[n - b2 + length],dn[n - b2],"B-Low",
  color=color.orange,style=label.style_labelup,textcolor=color.white,size=size.small)
label.delete(ahigh[1]),label.delete(bhigh[1]),label.delete(alow[1]),label.delete(blow[1])
//----
plot(up,"Pivot High's",color.blue,4,style=plot.style_circles,transp=0,offset=-length,join=true)
plot(dn,"Pivot Low's",color.orange,4,style=plot.style_circles,transp=0,offset=-length,join=true)

Overview

Users can select specific past pivot positions for highs and lows to project trendlines into the future as dynamic support and resistance. It also provides an option to run pivot detection on a custom price source rather than standard high and low prices. Because pivot confirmation relies on future bars equal to the length setting, historical pivot markers and lines update retroactively.

Details

Published by

theonetrade on GitHub

Code credit

alexgrover, as written in the script's header

Type

Indicator, Pine Script v4

Draws

On the price chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)

Topics

algorithmic-tradingbacktestingbitcoinccxtcrypto-tradingllm-agentoffline-backtestingopen-source-tradingpine-scriptpine-to-pythonpinescriptpynecorepythonquantquantitative-financestrategy-backtestingtechnical-analysistrading-indicatorstrading-strategiestradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
lengthint100length
A-High Positionint1astart
B-High Positionint0aend
A-Low Positionint1bstart
B-Low Positionint0bend
Use Custom Source ?boolfalsecsrc
Custom Sourcesourceclosesrc
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

575 stars

This indicator detects equal highs and lows by comparing prices within user-defined left and right bars using a tolerance percentage. It plots horizontal lines on the price chart for equal highs in one color and lows in another. A screener allows input of mult

Indicator v5 Support & resistanceTrend
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Equal Highs and Lows with Screener

Swing labels

by tradoor-terminal
320 stars

Calculates swing highs and swing lows on the price chart using pivot high and pivot low detection over a specified length. It places labels above pivot highs and below pivot lows to highlight key structural swing points. The indicator measures and displays the

Indicator v6 Support & resistanceTrend
Updated 3 days ago · AGPL-3.0 GitHub repository of Swing labels

Function - Linear Regression

by ricardosantos79
261 stars

This indicator fits a linear regression through stored pivot highs and lows and draws the resulting channel on the price chart. A function returns predicted values, maximum and minimum deviations, and the average absolute deviation. Confirmed two-bar pivots up

Indicator v5 TrendSupport & resistance
Updated 5 years ago · None stated GitHub repository of Function - Linear Regression

AI Trend

by dearvn
257 stars

AI Trend is an indicator that plots pivot points, trend lines, and support and resistance levels directly on the price chart. It marks high and low pivots based on user-defined length, draws trend lines that check for violations at specified points, and identi

Indicator v5 TrendSupport & resistance
Updated 2 months ago · None stated GitHub repository of AI Trend

Dynamic Linear Regression

by TradersPost
228 stars

Dynamic Linear Regression calculates and plots linear regression trendlines and standard deviation channels directly on the price chart over a user-selected time period. Traders can configure static channels locked at the end time, dynamic channels that contin

Indicator v6 TrendSupport & resistance
Updated 4 months ago · None stated GitHub repository of Dynamic Linear Regression

Ichimoku Cloud

by harryguiacorn
220 stars

This indicator plots Ichimoku Cloud elements on the price chart, including Tenkan-sen, Kijun-sen, Senkou Span A and B lines with optional Chikou Span. It signals trend changes via Tenkan-sen and Kijun-sen crosses and places arrows at Kijun-sen direction shifts

Indicator v5 TrendMoving averages
Updated 1 year ago · None stated GitHub repository of Ichimoku Cloud

More Support & resistance scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers