TradingView indicator calculations

Central pivot range indicator: calculate and sort the three lines

The central pivot range indicator plots a pivot and two surrounding levels from the high, low, and close of a reference period. Calculate Pivot = (H + L + C) / 3, raw BC = (H + L) / 2, and raw TC = 2 × Pivot - raw BC. Sort the two outer values before labeling the lower line BC and the upper line TC. A narrow CPR describes this geometry; it does not guarantee a trending session.

Build a CPR calculation

Calculate first, then assign the upper and lower labels

Zerodha documents the HLC formulas; Frank Ochoa explicitly notes that their TC and BC results can exchange positions. Keep raw values during debugging, then assign chart labels by numerical order. The pivot is halfway between the two outer levels. If both outer values are equal, all three lines coincide.

ValueCalculationMeaning
Pivot(H + L + C) / 3Central line
Raw BC(H + L) / 2Midpoint of the reference high and low
Raw TC2 × Pivot - raw BCReflection of raw BC across Pivot
Displayed BCmin(raw BC, raw TC)Lower boundary
Displayed TCmax(raw BC, raw TC)Upper boundary
WidthDisplayed TC - displayed BCNonnegative distance between boundaries

Three hypothetical closes show why sorting matters

Assume a completed reference session has H = 110 and L = 90, in price points. Change only its closing price. Keep full precision internally and round for display. These invented inputs test arithmetic; they do not describe a traded instrument.

  • For C = 97: Pivot = (110 + 90 + 97) / 3 = 99; raw TC = 198 - 100 = 98. Plotting raw TC as the upper boundary would invert the range.
  • For C = 100.30: Pivot = 300.30 / 3 = 100.10. The next-session band is 100.00 to 100.20, despite the reference session having a 20-point high-low range.
ClosePivotRaw BCRaw TCDisplayed BC / TCWidth
103101100102100 / 1022
97991009898 / 1002
100.30100.10100100.20100 / 100.200.20

A narrow CPR does not measure the whole price path

Let M = (H + L) / 2. Substitution gives width = abs(2 × Pivot - 2 × M) = (2 / 3) × abs(C - M). This is an algebraic consequence of the formulas. A close at M creates zero width even if the high-low range is large. CPR alone cannot establish how much time price spent consolidating or which direction the next session will take.

  • Ochoa describes unusually narrow ranges as a guide to potential trending behavior and warns that the method can fail. Treat that as a hypothesis to test, not an implication of the formula.
  • Define narrow before inspecting outcomes. For a research test, one possible rule is width below the 20th percentile of the previous 60 completed widths. That is a proposed definition, not an established best setting.
  • Keep the symbol, reference period, and session policy consistent in that comparison. Width alone supplies neither a direction nor an entry price.

An opening move above the band can fail immediately

Continue the third calculation: BC = 100.00, Pivot = 100.10, TC = 100.20. Assume a session starting at 09:30 and standard five-minute bars. Before the open, define this observation rule: an open above TC starts an upward hypothesis; the first completed bar closing at or below TC cancels it for that session. This is a demonstration rule, not a trade recommendation.

  • The narrow band remains exactly 0.20 wide throughout this path. Its arithmetic has not failed; the opening continuation hypothesis has.
  • A wick-based cancellation would occur at a different time. Record whether the rule uses intrabar touches or completed closes before comparing alerts.
  • Canceling an observation is not a simulated stop fill. A strategy still needs order timing, exits, sizing, fees, and slippage before any profit or loss can be calculated.
Observation timeHypothetical priceRule status
09:30 open100.60Above TC by 0.40; upward hypothesis starts
09:35 first bar close100.35Still above TC; hypothesis remains active
09:40 second bar close99.90Below TC and BC; hypothesis is canceled
09:45 third bar close100.10Inside CPR; no restart under the stated rule

Check the reference period on TradingView

For a daily CPR on an intraday chart, use the prior completed daily HLC and make the resulting levels available when the next daily period begins. A weekly CPR requires the prior completed week. The chart interval and reference interval are separate choices; inspect the selected script rather than assuming all CPR indicators use the same defaults.

  • TradingView documents that unconfirmed higher-timeframe data can change during live bars. A developing CPR based on the current day is a different calculation and should be labeled separately.
  • When reviewing Pine higher-timeframe requests, check that they retrieve confirmed prior values with consistent historical and live timing. Do not expose the final high, low, or close before that source period has finished.
  • Reload the chart and compare saved values around a period boundary. Stable arithmetic does not compensate for a different data source or a history-versus-live timing mismatch.
CheckExpected behavior for a fixed daily CPR
Source candleH, L, and C all come from the same completed daily candle
Session and feedRecord the symbol, feed, session selection, and source daily candle boundaries
During the next dayThe three reference levels stay fixed; live prices change their relationship to the band
New reference periodLevels update from the newly completed source candle
Missing source candleShow unavailable and suppress dependent alerts; do not substitute zero

Turn the calculation into a Pineify implementation request

Give the Pine Script AI Coding Agent the source period, session policy, raw formulas, sorted plot labels, and alert confirmation rule. Ask it to expose H, L, C, raw BC, raw TC, Pivot, and sorted boundaries so that you can compare its output with the table above.

  • Use the C = 97 row to check inverted raw boundaries and the C = 100.30 row to check a narrow band. Also test a midpoint close, missing data, and the first bar of a new reference period.
  • Request a fixed prior-period indicator first. Check the generated source and syntax result, then verify bar values and alert timestamps on TradingView.
  • Only after those checks, define entries, exits, sizing, and costs for a separate strategy test. The three plotted levels do not determine those choices.
Where Pineify fits

Pine Script AI Coding Agent

Draft a CPR indicator from explicit input and confirmation rules, then inspect the generated Pine Script and compare its values with a manual calculation.

Build a CPR calculation

Frequently asked questions

Educational calculations, not investment advice. All prices and the opening sequence are hypothetical. No backtest or trading return is claimed; CPR does not guarantee that support, resistance, or a trend will persist.

Sources and verification

Published by Pineify. Pineify is an independent product and is not affiliated with TradingView. Sources support the technical explanations; examples do not establish trading performance.