Indicator · Pine Script v6 · On the chart

Pivot Points

by roshaneforde

The Pivot Points indicator plots horizontal lines on the price chart to mark bullish and bearish pivot points.

View on GitHub

GitHub stars3on the repository
Pine versionv6current
Lines of code63
Settings9inputs
LicenceMIT
Last update1 year ago9 Jan 2025

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

63 lines of Pine Script v6 from PivotPoints.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

PivotPoints.pine
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © roshaneforde

//@version=6
indicator("Pivot Points", overlay=true)

// Inputs
lastSetOfCandles = input.int(100, "Number of candles to draw lines on")
drawBuyLine = input.bool(true, "Draw Buy Line")
buyLineColor = input.color(color.blue, "Buy Line Color")
buyLineStyle = input.string("Dashed", title="Line Style", options=["Solid", "Dashed", "Dotted"])
buyLineWidth = input.int(1, "Buy Line Width")

drawSellLine = input.bool(true, "Draw Sell Line")
sellLineColor = input.color(color.red, "Sell Line Color")
sellLineStyle = input.string("Dashed", title="Line Style", options=["Solid", "Dashed", "Dotted"])
sellLineWidth = input.int(1, "Sell Line Width")

// Loop through the last set of candles
for i = 0 to lastSetOfCandles
    // Line prices
    float buyLinePrice = 0
    float sellLinePrice = 0

    // Bullish pivot point
    if (open[i + 1] < close[i + 1] and open[i] > close[i])
        buyLinePrice := close[i + 1]

    // Bearish pivot point
    if (open[i + 1] > close[i + 1] and open[i] < close[i])
        sellLinePrice := close[i + 1]

    // Buy line
    if (buyLinePrice > 0 and drawBuyLine)
        buyLine = line.new(x1=bar_index[i + 1], y1=close[i + 1], x2=bar_index, y2=close[i + 1], color=buyLineColor, width=1)

        for j = 0 to i
            if (close[j] > buyLinePrice)
                line.set_x2(buyLine, bar_index[j])

        if (buyLineStyle == "Dashed")
            line.set_style(buyLine, line.style_dashed)
        else if (buyLineStyle == "Dotted")
            line.set_style(buyLine, line.style_dotted)

        line.set_width(buyLine, buyLineWidth)

    // Sell line
    if (sellLinePrice > 0 and drawSellLine)
        sellLine = line.new(x1=bar_index[i + 1], y1=close[i + 1], x2=bar_index, y2=close[i + 1], color=sellLineColor, width=1)

        for j = 0 to i
            if (close[j] < sellLinePrice)
                line.set_x2(sellLine, bar_index[j])

        if (sellLineStyle == "Dashed")
            line.set_style(sellLine, line.style_dashed)
        else if (sellLineStyle == "Dotted")
            line.set_style(sellLine, line.style_dotted)

        line.set_width(sellLine, sellLineWidth)

plot(close)

Overview

Pivot Points identifies shifts from bullish to bearish or vice versa by scanning the last 100 candles by default. Buy lines appear in blue and sell lines in red, with options for dashed or dotted styles and adjustable widths. Lines extend leftward until a higher high or lower low breaks them, highlighting potential reversals or trend continuations. It draws directly on the chart and works on any timeframe. Recommended setup includes a line chart, candlestick chart, SMA filter, and RSI for confirmation. Lines are drawn at candle close levels and can be toggled on or off.

Details

Published by

roshaneforde on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Support & resistance, Trend, Candlestick patterns

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

forexmetatradermql5trading

Settings

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

SettingTypeDefaultVariable
Number of candles to draw lines onint100lastSetOfCandles
Draw Buy LinebooltruedrawBuyLine
Buy Line Colorcolorcolor.bluebuyLineColor
Line StylestringDashedbuyLineStyle
Buy Line Widthint1buyLineWidth
Draw Sell LinebooltruedrawSellLine
Sell Line Colorcolorcolor.redsellLineColor
Line StylestringDashedsellLineStyle
Sell Line Widthint1sellLineWidth
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

Reversal Breakout System

by TamaraKGreen
46 stars

This indicator detects inside candles inside larger parent candles on the price chart. It plots colored boxes around inside and parent candles, fills them with user-adjustable transparency, draws Fibonacci retracement lines and mother candle range lines, and d

Indicator v6 Candlestick patternsBreakout
Updated 7 weeks ago · None stated GitHub repository of Reversal Breakout System

Pro Pattern Al-Sat

by MeridianAlgo
9 stars

This overlay indicator marks bullish and bearish chart patterns on the price chart and can hide either side. Optional filters require agreement from fast and slow EMAs, Supertrend, and ADX, plus volume, RSI, nearby pivot support or resistance, and a user-defin

Indicator v6 Candlestick patternsTrend
Updated 4 months ago · MIT GitHub repository of Pro Pattern Al-Sat

This overlay indicator detects tweezer tops and bottoms and kangaroo-tail pin bars, then draws supply and demand zones from those patterns. It scores each zone, decays freshness, merges overlapping zones, and can invalidate a zone after a close-through or afte

Indicator v6 Candlestick patternsSupport & resistance
Updated yesterday · MIT GitHub repository of Tweezer & Kangaroo Zones [WavesUnchained]
7 stars

This indicator plots Smart Money Concepts and price action components directly on the price chart. It highlights bullish and bearish order blocks, multi-timeframe pivot points, market structure swings with key Fibonacci retracement levels (0.618 and 0.786), zo

Indicator v5 SMC / ICT / price actionSupport & resistance Repaints
Updated 3 months ago · None stated GitHub repository of Cryptokazancev Strategy Pack

TheStrat Suite

by 345-strategies
5 stars

This indicator implements Rob Smith's TheStrat price action methodology across up to six configurable timeframes. It classifies candles into inside, directional, and outside bars, identifies patterns like hammers, shooters, and failed 2s, and calculates magnit

Indicator v6 Candlestick patternsSupport & resistance Repaints
Updated 2 days ago · MPL-2.0 GitHub repository of TheStrat Suite

Hercules Rewrite

by g-moe
3 stars

Hercules Rewrite is a signal and visual trade management indicator that overlays entry setups directly on the price chart. It detects candle setups based on minimum tick movement and engulfing patterns, filtering entries through parameters like moving averages

Indicator v5 Candlestick patternsTrend
Updated 5 months ago · None stated GitHub repository of Hercules Rewrite

More indicators

Trade Your Charts With a Regulated Broker

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

Compare brokers