Indicator · Pine Script v6 · On the chart

Traditional Pivot Points

by shubhamtaywade82

Calculates daily pivot levels from the previous day's high, low and close and draws them on the price chart as lines with price labels.

View on GitHub

Archived by its author

GitHub stars1on the repository
Pine versionv6current
Lines of code121
Settings8inputs
LicenceNone statedfile: MPL-2.0
Last update5 months ago31 May 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

121 lines of Pine Script v6 from indicators/agent-examples/pivot-points-traditional.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

pivot-points-traditional.pine
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Ported from pinescript-agents/examples/simple/pivot-points-traditional.pine for local testing in pinescripts-collections.

//@version=6
indicator("Traditional Pivot Points [Agent Example]", "Pivots · AE", overlay=true, max_lines_count=500, max_labels_count=500)

pivot_type = input.string("Traditional", "Pivot Type", options=["Traditional", "Fibonacci", "Camarilla"], group="Settings")
show_labels = input.bool(true, "Show Labels", group="Display")
show_levels = input.bool(true, "Show Levels", group="Display")
line_extend = input.int(20, "Line Extension", minval=5, maxval=100, group="Display")
extend_left = input.bool(true, "Extend Lines Left", group="Display")

pivot_color = input.color(color.new(#ffd166, 0), "Pivot Color", group="Colors")
support_color = input.color(#089981, "Support Color", group="Colors")
resistance_color = input.color(#f23645, "Resistance Color", group="Colors")

var line[] pivot_lines = array.new<line>()
var label[] pivot_labels = array.new<label>()

get_prev_ohlc() =>
    prev_high = request.security(syminfo.tickerid, "1D", high[1], lookahead=barmerge.lookahead_off)
    prev_low = request.security(syminfo.tickerid, "1D", low[1], lookahead=barmerge.lookahead_off)
    prev_close = request.security(syminfo.tickerid, "1D", close[1], lookahead=barmerge.lookahead_off)
    [prev_high, prev_low, prev_close]

calculate_pivots(high_prev, low_prev, close_prev, pivot_type_) =>
    pivot_point = (high_prev + low_prev + close_prev) / 3
    if pivot_type_ == "Traditional"
        r1 = 2 * pivot_point - low_prev
        s1 = 2 * pivot_point - high_prev
        r2 = pivot_point + (high_prev - low_prev)
        s2 = pivot_point - (high_prev - low_prev)
        r3 = high_prev + 2 * (pivot_point - low_prev)
        s3 = low_prev - 2 * (high_prev - pivot_point)
        [pivot_point, r1, r2, r3, s1, s2, s3]
    else if pivot_type_ == "Fibonacci"
        r1 = pivot_point + 0.382 * (high_prev - low_prev)
        s1 = pivot_point - 0.382 * (high_prev - low_prev)
        r2 = pivot_point + 0.618 * (high_prev - low_prev)
        s2 = pivot_point - 0.618 * (high_prev - low_prev)
        r3 = pivot_point + (high_prev - low_prev)
        s3 = pivot_point - (high_prev - low_prev)
        [pivot_point, r1, r2, r3, s1, s2, s3]
    else
        range_ = high_prev - low_prev
        r1 = close_prev + range_ * 0.0916
        s1 = close_prev - range_ * 0.0916
        r2 = close_prev + range_ * 0.183
        s2 = close_prev - range_ * 0.183
        r3 = close_prev + range_ * 0.275
        s3 = close_prev - range_ * 0.275
        [close_prev, r1, r2, r3, s1, s2, s3]

draw_pivot_line(price, line_color, line_style, label_text) =>
    start_bar = bar_index - line_extend
    end_bar = extend_left ? bar_index : bar_index + line_extend
    line_extend_mode = extend_left ? extend.left : extend.none
    if show_levels
        pivot_line = line.new(start_bar, price, end_bar, price, color=line_color, width=1, style=line_style, extend=line_extend_mode)
        array.push(pivot_lines, pivot_line)
    if show_labels
        label_with_price = label_text + " " + str.tostring(price, "#.##")
        pivot_label = label.new(end_bar, price, text=label_with_price, color=line_color, textcolor=color.white, size=size.small, style=label.style_label_left)
        array.push(pivot_labels, pivot_label)

clear_drawings() =>
    while array.size(pivot_lines) > 0
        line.delete(array.pop(pivot_lines))
    array.clear(pivot_lines)
    while array.size(pivot_labels) > 0
        label.delete(array.pop(pivot_labels))
    array.clear(pivot_labels)

live_levels(pt) =>
    [h, l, c] = get_prev_ohlc()
    if not na(h) and not na(l) and not na(c)
        calculate_pivots(h, l, c, pt)
    else
        [na, na, na, na, na, na, na]

[pp_live, r1_live, r2_unused, r3_unused, s1_live, s2_unused, s3_unused] = live_levels(pivot_type)

if timeframe.change("1D") or barstate.isfirst or barstate.islast
    clear_drawings()
    [prev_high, prev_low, prev_close] = get_prev_ohlc()
    if not na(prev_high) and not na(prev_low) and not na(prev_close)
        [pp, r1, r2, r3, s1, s2, s3] = calculate_pivots(prev_high, prev_low, prev_close, pivot_type)
        draw_pivot_line(pp, pivot_color, line.style_solid, "PP")
        draw_pivot_line(r1, resistance_color, line.style_solid, "R1")
        draw_pivot_line(r2, resistance_color, line.style_dashed, "R2")
        draw_pivot_line(r3, resistance_color, line.style_dotted, "R3")
        draw_pivot_line(s1, support_color, line.style_solid, "S1")
        draw_pivot_line(s2, support_color, line.style_dashed, "S2")
        draw_pivot_line(s3, support_color, line.style_dotted, "S3")

var table pivot_table = table.new(position.top_right, 2, 8, bgcolor=color.new(#0b0e14, 25), border_width=1, border_color=color.new(#2a2e39, 40))
if barstate.islast
    [prev_high_t, prev_low_t, prev_close_t] = get_prev_ohlc()
    if not na(prev_high_t) and not na(prev_low_t) and not na(prev_close_t)
        [pp_t, r1_t, r2_t, r3_t, s1_t, s2_t, s3_t] = calculate_pivots(prev_high_t, prev_low_t, prev_close_t, pivot_type)
        table.cell(pivot_table, 0, 0, "Pivot Levels", text_color=color.white, text_size=size.small)
        table.cell(pivot_table, 1, 0, "Price", text_color=color.white, text_size=size.small)
        table.cell(pivot_table, 0, 1, "R3", text_color=color.red, text_size=size.small)
        table.cell(pivot_table, 1, 1, str.tostring(r3_t, "#.####"), text_color=color.white, text_size=size.small)
        table.cell(pivot_table, 0, 2, "R2", text_color=color.red, text_size=size.small)
        table.cell(pivot_table, 1, 2, str.tostring(r2_t, "#.####"), text_color=color.white, text_size=size.small)
        table.cell(pivot_table, 0, 3, "R1", text_color=color.red, text_size=size.small)
        table.cell(pivot_table, 1, 3, str.tostring(r1_t, "#.####"), text_color=color.white, text_size=size.small)
        table.cell(pivot_table, 0, 4, "PP", text_color=pivot_color, text_size=size.small)
        table.cell(pivot_table, 1, 4, str.tostring(pp_t, "#.####"), text_color=color.white, text_size=size.small)
        table.cell(pivot_table, 0, 5, "S1", text_color=color.green, text_size=size.small)
        table.cell(pivot_table, 1, 5, str.tostring(s1_t, "#.####"), text_color=color.white, text_size=size.small)
        table.cell(pivot_table, 0, 6, "S2", text_color=color.green, text_size=size.small)
        table.cell(pivot_table, 1, 6, str.tostring(s2_t, "#.####"), text_color=color.white, text_size=size.small)
        table.cell(pivot_table, 0, 7, "S3", text_color=color.green, text_size=size.small)
        table.cell(pivot_table, 1, 7, str.tostring(s3_t, "#.####"), text_color=color.white, text_size=size.small)

alertcondition(ta.crossover(close, pp_live), "PP Break Up", "Price crossed above Pivot Point")
alertcondition(ta.crossunder(close, pp_live), "PP Break Down", "Price crossed below Pivot Point")
alertcondition(ta.crossover(close, r1_live), "R1 Break", "Price crossed above R1")
alertcondition(ta.crossunder(close, s1_live), "S1 Break", "Price crossed below S1")

Overview

The pivot type can be Traditional, Fibonacci or Camarilla, each giving a central level plus three supports and three resistances. Settings control labels, line extension, extending lines left and colours. Daily data is requested without lookahead, so the levels do not use the current day.

Details

Published by

shubhamtaywade82 on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Support & resistance

Markets

Any symbol

Timeframes

M15-H1

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.

Settings

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

SettingTypeDefaultVariable
Pivot TypestringTraditionalpivot_type
Show Labelsbooltrueshow_labels
Show Levelsbooltrueshow_levels
Line Extensionint20line_extend
Extend Lines Leftbooltrueextend_left
Pivot Colorcolorcolor.new(#ffd166, 0)pivot_color
Support Colorcolor#089981support_color
Resistance Colorcolor#f23645resistance_color
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

947 stars

Moving Average Channel plots separate simple moving averages for upper and lower bands on the price chart. It fills the space between bands with semi-transparent color and colors bars green above the upper band, red below the lower band, or gray in between. Us

Indicator v4 Moving averagesSupport & resistance
Updated 11 days ago · GPL-3.0 GitHub repository of Moving Average Channel

ICT Equal Highs and Lows

by ArunKBhaskar
575 stars

This overlay indicator finds pivot highs and lows on the price chart and compares the last two highs and the last two lows. When the percentage difference between a pair is below the Equal HL threshold, it treats them as equal levels and draws a box. Left and

Indicator v5 SMC / ICT / price actionSupport & resistance
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Equal Highs and Lows
330 stars

This indicator monitors multiple cryptocurrency symbols for trading signals. It calculates and plots entry prices, take profit, and stop loss levels for each symbol including BTCUSDT, ETHUSDT, BNBUSDT and others. Price crossovers trigger buy, sell or close ale

Indicator v5 Support & resistanceScreeners & dashboards
Updated 2 months ago · None stated GitHub repository of Multi Alert Long/Short [Alorse]

This overlay indicator draws a fixed-range volume profile on the price chart, splitting traded activity into up and down volume at each price level. It also plots a sentiment profile, a developing point of control, and value-area high and low around a configur

Indicator v5 VolumeSupport & resistance
Updated 2 months ago · MIT GitHub repository of Volume Profile and Indicator by DGT

BZ-tracker

by Allen1212
303 stars

The BZ-tracker indicator marks ARK Invest buy and sell transactions on stock charts with labels. It plots green labels for purchases and red labels for sales, each annotated with a multiplier such as X1 or X2 to show the number of ARK ETFs trading the stock on

Indicator v4 Support & resistanceScreeners & dashboards
Updated 2 years ago · None stated GitHub repository of BZ-tracker

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 4 years ago · None stated GitHub repository of Function - Linear Regression

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