Indicator TutorialPine Script v6

Pivot point indicator: formulas, periods and session data

Calculate reference levels from a completed period, then check when those levels become available.

A pivot point indicator converts prior-period prices into a central pivot and support/resistance levels. TradingView calls its built-in study Pivot Points Standard; Standard is the study name, not a single formula type. This example implements Traditional PP, R1 to R3 and S1 to S3. It does not identify swing turning points with ta.pivothigh() or ta.pivotlow().

Add Pivot Points Standard and choose the type

  1. Open Indicators on a TradingView chart and search for Pivot Points Standard.
  2. In Settings, select Traditional and an explicit daily, weekly or monthly Pivots Timeframe for this comparison.
  3. Keep Use Daily-based Values enabled when comparing with this page's higher-timeframe data request. Match the source symbol before comparing levels.

The built-in has Traditional, Fibonacci, Woodie, Classic, DM and Camarilla types. Traditional and Classic agree through R2/S2 but differ at R3/S3. Woodie uses the current period open; Camarilla offsets the prior close with its own range coefficients. Choose the type before judging a mismatch.

This tutorial and code are readable without a subscription. Product access is separate. The example is a partial Traditional ladder, not a replacement for every built-in type or its full drawing controls.

Why Traders Use This Indicator

  • Put a named, reproducible price reference on the chart.
  • Keep one period of reference levels available while examining smaller chart bars.
  • Describe an alert condition precisely enough to audit it.
ParameterDefaultDescription
Pivot typeTraditional in this examplePP and three support/resistance pairs. The built-in also offers other types and additional levels.
Pivot period1D; options 1W and 1MControls the source window. A weekly anchor uses last week, even on a 15-minute chart. This script requires the anchor to exceed the chart timeframe.
Source symbolChart symbolAn optional different symbol is for visual comparison only; its selection disables chart-price markers and alerts unless it matches the chart.
Daily-based dataHigher-timeframe feedThis example requests supplied daily, weekly or monthly OHLC. It does not aggregate a custom cash or extended session from intraday bars.
Display extrasOffOptional prior open and PP-to-R1/S1 midpoints are visual aids. Prior open is not an input to Traditional PP.

Calculate the ladder and audit one completed period

Let H, L and C be the previous completed anchor period's high, low and close. Let D = H - L.

  • PP = (H + L + C) / 3
  • R1 = 2 × PP - L; S1 = 2 × PP - H
  • R2 = PP + D; S2 = PP - D
  • Traditional R3 = H + 2 × (PP - L); S3 = L - 2 × (H - PP)

Hypothetical calculation: H = 110, L = 98, C = 107

These are invented inputs for arithmetic verification, not market observations or a backtest. The range is 12 and PP is 315 / 3 = 105.

LevelSubstitutionResult
PP(110 + 98 + 107) / 3105
R1 / S1210 - 98 / 210 - 110112 / 100
R2 / S2105 + 12 / 105 - 12117 / 93
R3 / S3110 + 2 × 7 / 98 - 2 × 5124 / 88

As a type check, Classic R3/S3 would be PP ± 2D, giving 129 and 81. A difference of 5 at R3 is therefore expected for these inputs when one chart uses Traditional and the other uses Classic.

Keep the period separate from the chart timeframe

For a daily example, treat these inputs as Monday's completed bar. Tuesday's first available intraday bar receives PP 105 and holds it for that daily period. Wednesday uses Tuesday's completed inputs. For a weekly or monthly example, replace Monday with the previous completed week or month. Holidays and closed sessions do not create imaginary bars.

The code requests each input with [1] inside request.security and uses barmerge.lookahead_on. The offset supplies already completed values at the next period's start; removing it would expose future historical values. With the offset retained, lookahead_off instead delays the historical update until the period's end. The snapshot table makes the three inputs inspectable.

Diagnose a session mismatch before changing formulas

Daily and intraday feeds can differ. Stock daily candles generally omit extended trades; futures daily closes can be settlement prices. For a concrete sensitivity check, keep H = 110 and L = 98 but change C from 107 to 104. PP falls from 105 to 104, R1 from 112 to 110, and S1 from 100 to 98. A close-source difference alone can explain the discrepancy.

This script uses the standard ticker's supplied anchor bars. It does not offer a timezone cutoff or reconstruct a chosen session. A different chart display timezone does not change Pine's exchange-defined bar boundaries. For a forex pivot point indicator, record the provider-qualified symbol and inspect its completed daily HLC instead of assuming every feed closes the day together.

Signal Interpretation

A close of 113 exceeds the example's R1 of 112 by one price unit. It establishes position relative to that reference; it does not establish that price will reach R2 at 117. The yellow marker means a confirmed chart bar's range contains PP. Several consecutive bars can qualify.

The alerts require a confirmed close crossing R1 or S1 and skip the bar where the reference updates. This avoids treating a level jump alone as a breakout, but also skips genuine crosses on that first bar. A foreign source symbol disables these chart-price signals. Educational material only, not investment advice.

Combining with Other Indicators

If adding a trend or volume filter, record its exact inputs separately from the pivot settings. Test whether it changes the selected bars and costs before treating it as useful. A second indicator agreeing with PP is not evidence of a reliable reversal.

Use the Pine Script AI Coding Agent to request a specific variant, a custom session accumulator or an alert rule. Supply the worked inputs and expected outputs as acceptance checks. Review the resulting script before using it.

Writing Pine Script Manually

Challenges of Manual Coding

Keep the [1] offset in the requested context, not on the already merged chart series.

Restrict the anchor to a timeframe above the chart and compare standard price bars.

Check requested HLC before debugging the pivot arithmetic.

Separate a bar containing a level from a closing-price crossover.

Pine Script v6
//@version=6
indicator("Traditional Pivots: Completed Period", overlay=true, max_labels_count=50)

sourceSymbol = input.symbol("", "Source symbol (blank = chart)")
anchor = input.timeframe("1D", "Pivot period", options=["1D", "1W", "1M"])
showLabels = input.bool(true, "Label period starts")
showExtras = input.bool(false, "Show prior open and midpoints")

if not chart.is_standard
    runtime.error("Use a standard time-based chart.")
if timeframe.in_seconds() >= timeframe.in_seconds(anchor)
    runtime.error("Pivot period must be higher than chart timeframe.")

sourceId = ticker.standard(sourceSymbol == "" ? syminfo.tickerid : sourceSymbol)
[priorH, priorL, priorC, priorO, priorTime] = request.security(sourceId, anchor, [high[1], low[1], close[1], open[1], time[1]], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)

pp = (priorH + priorL + priorC) / 3.0
r1 = 2.0 * pp - priorL
s1 = 2.0 * pp - priorH
r2 = pp + priorH - priorL
s2 = pp - priorH + priorL
r3 = priorH + 2.0 * (pp - priorL)
s3 = priorL - 2.0 * (priorH - pp)
newPeriod = ta.change(priorTime) != 0
ready = not na(pp)

plot(pp, "PP", color.yellow, 2, plot.style_stepline)
plot(r1, "R1", color.new(color.red, 40), style=plot.style_stepline)
plot(r2, "R2", color.new(color.red, 20), style=plot.style_stepline)
plot(r3, "R3", color.red, style=plot.style_stepline)
plot(s1, "S1", color.new(color.teal, 40), style=plot.style_stepline)
plot(s2, "S2", color.new(color.teal, 20), style=plot.style_stepline)
plot(s3, "S3", color.teal, style=plot.style_stepline)
plot(showExtras ? priorO : na, "Prior open", color.gray, style=plot.style_circles)
plot(showExtras ? (pp + r1) / 2.0 : na, "PP-R1 midpoint", color.orange)
plot(showExtras ? (pp + s1) / 2.0 : na, "PP-S1 midpoint", color.blue)

// A foreign source is for visual comparison; chart-price alerts are disabled.
sameSymbol = sourceSymbol == "" or sourceId == ticker.standard(syminfo.tickerid)
touchPP = sameSymbol and ready and barstate.isconfirmed and low <= pp and high >= pp
plotshape(touchPP, "Bar contains PP", shape.circle, location.abovebar, color.yellow, size=size.tiny)
if newPeriod and ready and showLabels
    label.new(bar_index, pp, "PP", style=label.style_label_left, color=color.new(color.yellow, 80), textcolor=color.black, size=size.small)

var table snapshot = table.new(position.bottom_right, 2, 10, border_width=1)
if barstate.islast
    names = array.from("Prior H", "Prior L", "Prior C", "PP", "R1", "S1", "R2", "S2", "R3", "S3")
    values = array.from(priorH, priorL, priorC, pp, r1, s1, r2, s2, r3, s3)
    for row = 0 to 9
        table.cell(snapshot, 0, row, array.get(names, row), text_color=color.white, bgcolor=color.new(color.gray, 65))
        table.cell(snapshot, 1, row, str.tostring(array.get(values, row), "#.#####"), text_color=color.white, bgcolor=color.new(color.gray, 65))

crossAbove = ta.crossover(close, r1)
crossBelow = ta.crossunder(close, s1)
confirmed = sameSymbol and ready and barstate.isconfirmed and not newPeriod
alertcondition(confirmed and crossAbove, "Close above R1", "Chart close crossed above Traditional R1")
alertcondition(confirmed and crossBelow, "Close below S1", "Chart close crossed below Traditional S1")

Maintenance Note: This example uses supplied higher-timeframe data and a Traditional seven-level subset. Check values on both sides of a period boundary and after reload. A successful syntax check does not prove feed equivalence or profitable signals. Initial history may lack a completed anchor bar.

Build with Pineify Visual Editor

Pineify lets you configure supported indicators and export Pine Script. Available settings and plan requirements vary by indicator. Compare the generated rules with the example before using its signals.

FeatureManual Pine ScriptPineify Visual Editor
SpecificationWrite the type, source, period and expected numbers.Provide the same specification as a coding request.
ReviewInspect the request offset, plots and alert conditions.Ask for an explanation, then inspect the generated source.
AcceptanceCompare the snapshot HLC and levels against the worked calculation.Use the same calculation to assess the output; generation does not replace verification.

Describe a custom session or pivot variant in a coding request.

Ask the agent to explain which bar supplies each input.

Iterate on labels and alerts while preserving the calculation checks.

Step-by-Step Tutorial

1

Open the Pine Script AI Coding Agent

Use the coding-agent link and state that you need an indicator, not an order-executing strategy.

2

Specify the inputs

Name Traditional, the source symbol, D/W/M anchor and the completed-period requirement.

3

Provide acceptance numbers

Use H 110, L 98 and C 107; require PP 105, R1 112 and S1 100.

4

Inspect the generated source

Check data timing, session handling and whether alerts compare the intended symbol.

5

Verify chart behavior

Compare each level across an anchor boundary and reload. Define entries, exits and trading costs separately if building a strategy.

Trading Strategies & Pro Tips

Reference-break hypothesis

For a test, record a confirmed close above R1 and define an entry on the following bar. Choose exit, stop, size and costs before evaluating results. The indicator itself places no orders.

Rejection hypothesis

A possible rule is high at or above R1 with close below R1. Log subsequent returns under a fixed exit rule; a touch alone is not proof of rejection.

Period comparison

Compare daily and weekly references on the same chart. Keep the evaluation window and execution assumptions identical so the anchor choice is the variable being tested.

Common Mistakes to Avoid

  • Comparing Traditional R3/S3 with Classic: confirm the Type setting first.
  • Using current-period HLC: values then develop as that period trades.
  • Removing [1] while keeping lookahead_on: this leaks future values into history.
  • Expecting a daily data request to reproduce a custom intraday session: compare the actual HLC inputs.
  • Treating every PP touch as a separate entry: repeated touches can occur without a directional move.
  • Assuming chart display timezone changes the source daily cutoff: inspect the feed and session definition.

Sources and calculation references

TradingView indicators

Frequently Asked Questions

It maps a period of price inputs to reference levels. In this Traditional example, the prior high, low and close produce PP and three support/resistance pairs. Swing pivots found with ta.pivothigh or ta.pivotlow solve a different problem: locating local turning points.

Add the built-in study from Indicators, then choose its Type and Pivots Timeframe. To compare with this script, use Traditional, an explicit D/W/M period, daily-based values and the same symbol. Check the input candle before comparing plotted levels.

For this verification exercise, use a 15-minute standard chart, a 1D anchor and the chart symbol. These are inspection settings, not an optimized trading recommendation. Move to 1W or 1M only when that longer reference matches the question you are testing.

Inspect the source symbol and completed HLC first. Then compare type, anchor period and daily-based versus intraday session data. In the example, changing only the close from 107 to 104 moves PP from 105 to 104; no formula error is needed to produce that difference.

Yes. Select 1W or 1M in this script while keeping the chart timeframe lower than the anchor. Its snapshot then shows the prior completed week or month. The pivot period determines the inputs; a smaller chart bar only changes how often you observe the resulting levels.

No. A crossing records a relationship between price and a computed reference. For the hypothetical inputs, closing above R1 at 112 does not guarantee a visit to R2 at 117. A trading rule still needs explicit execution, exit, size and cost assumptions.

Every requested price is offset by one anchor bar. That makes it a completed value available when the next period starts. The offset and merge setting belong together. Do not copy lookahead_on into a request for the developing high, low or close.

The arithmetic does not require a specific asset class. Verify the provider-qualified symbol and the anchor candle on that feed. A daily boundary is a data convention, so compare actual HLC rather than expecting different venues or forex providers to return identical levels.

Specify and verify your pivot script with Pineify

  • Request the exact formula type and completed-period inputs.
  • Include the seven expected values from the worked example.
  • Verify bar timing before adding strategy exits and costs.

Disclaimer: Trading involves significant risk. The indicators, code, and strategies provided are for educational purposes only and do not constitute financial advice. Past performance is not indicative of future results.