Pivot Points in Pine Script
Seven horizontal levels computed from yesterday's high, low and close: a central pivot with three resistances above and three supports below, fixed for the whole day.
Definition
Pivot points are horizontal levels computed from the previous period's high, low and close by a fixed formula. They belong to the formula-levels family: nothing is drawn by eye, and every trader who uses the same formula gets the same lines. The central pivot (PP) is the average of the three prices. Above it sit three resistance levels, R1 to R3, and below it three support levels, S1 to S3, each set a multiple of the previous day's range away from the pivot.
The levels work for two reasons. Yesterday's range is the best simple estimate of today's, so levels projected from it land near where today's extremes tend to fall. And because the formula is public and has not changed in decades, a large number of traders watch the same prices, place orders around them and react when they are reached. The pivot itself acts as the day's bias line: trade above it and the session leans long, below it and the session leans short.
The formulas come from the exchange floors, where traders needed a few reference prices before the open and could work them out from the previous settlement without a chart. That is why the classic set is called floor pivots. The standard period is daily, with the levels refreshed at each new session; swing traders run the same formula on the previous week or month. Variants change the arithmetic: Woodie weights the close, Camarilla places tighter levels for fading, and the Fibonacci version scales the range by 0.382 and 0.618.
On the chart the lines are flat for the whole day and step to new values at the open. A normal day trades between S1 and R1 and tests the pivot at least once. A trend day breaks R1 or S1 early, runs to R2 or S2 and rarely comes back through the pivot. R3 and S3 are reached on the widest days only. The first touch of any level usually produces at least a pause, which is what makes them useful for entries, targets and stops.
Reading the chart
The levels are given, so identification is about choosing the right period and reading how price behaves at each line.
- Choose the period. Daily pivots from the previous session suit intraday charts from 1 to 60 minutes; weekly pivots suit 4-hour and daily charts; the period should be several times the chart's timeframe.
- Check which session the formula uses. For stocks the regular-hours high and low differ from the extended-hours ones, and on 24-hour markets the day boundary decides every level.
- Locate the open relative to the pivot. An open above PP with price holding there sets a long bias; an open below it sets a short bias; an open on the pivot says wait for the first break.
- Watch the first test of each level. A rejection wick and a close back on the near side is a hold; a close through it and a retest from the other side is a break.
- Use the next level as the target. From a hold at S1 the natural target is PP, then R1; from a break of R1 the target is R2, and the broken level becomes the stop reference.
- Mark confluence. A pivot that coincides with the previous day's high or low, a round number or the developing VWAP is a stronger level than a pivot in empty space.
The maths
The classic pivot is the average of the previous period's high, low and close, and the other six levels are projected from it using the previous range.
The implementation takes the previous completed day from a daily request with lookahead switched off, so the levels never repaint and are drawn on intraday and daily charts only.
R1 and S1 mirror the previous high and low around the pivot. If the day closed at its high, the pivot sits high in the range and the whole structure shifts upwards.
Weekly and monthly pivots use the same formulas with the previous week's or month's prices. The levels are further apart and hold for the whole period.
Variants: Woodie uses (H + L + 2 × C) / 4 for the pivot, Camarilla places levels at fractions of the range around the close, and Fibonacci pivots scale the range by 0.382, 0.618 and 1.
Inputs that matter
| Input | Typical | What changing it does |
|---|---|---|
| Period | daily | Weekly or monthly pivots spread the levels wider and keep them for the whole period; the chart timeframe should be several times shorter than the period. |
| Formula | classic (floor) | Camarilla levels sit closer to the close and suit fading; Fibonacci pivots space the levels by ratio; Woodie leans the pivot towards the close. |
| Session | the exchange day | For stocks the regular-hours range and the full-day range give different numbers; for futures and crypto the day boundary of the data feed decides the levels. |
In practice
- As a bias line: above the pivot the rule looks for longs on pullbacks to it, below it for shorts on rallies to it. The script marks a long when the close crosses above PP and a short when it crosses below.
- As targets for intraday trades: a long from a hold at S1 aims at PP, then R1; a breakout above R1 aims at R2. The next level is the target and the last one is the stop reference.
- As a range map: on a quiet day the S1 to R1 band contains most of the action and fades at the edges fit; once R2 or S2 is reached the day has become a trend day.
- As confluence for other tools: a pivot that lines up with the previous day's high or low, a round number or a retracement level gets priority over either reference alone.
- As a swing-trade frame: weekly pivots on a 4-hour chart give the week's likely extremes and a central level to judge each day's close against.
- As alert levels: the lines are known before the open, so alerts at R1, S1 and the pivot can be set once and left for the whole session.
Where it goes wrong
- Using the wrong session's range. Extended-hours highs and lows give different levels from the regular session; pick the range that the traders you trade against are watching.
- Treating each line as an exact price. Reactions happen in a zone of a few ticks around the level; give it a small buffer for entries and a wider one for stops.
- Trading every touch. A level on a trend day gets run through; check the bias from the pivot and the open first, and fade only when the day is ranging.
- Mixing periods on one chart. Daily pivots on a 1-minute chart are fine; monthly pivots there are meaningless; keep the period several times longer than the timeframe.
Compared with
Previous Day High & Low. The previous day's high and low are the actual extremes of yesterday's auction; pivots are a formula that projects new levels from them. The two coincide only when the close sits at a particular place in the range, which is why traders draw both.
Support & Resistance. Hand-drawn support and resistance come from where price actually reversed and can be days or months old; pivots are recomputed every session from a formula and carry no memory beyond yesterday. Pivots are objective, drawn levels are specific.
Fibonacci Retracement. A retracement divides a swing you choose by fixed ratios; pivots divide the previous day's range by a fixed formula. Both are ratio levels, but a retracement depends on the swing selection and pivots depend only on yesterday's prices.
VWAP. VWAP moves with every print and depends on the session's volume; pivots are fixed before the open and ignore volume entirely. A pivot test that coincides with the developing VWAP is a stronger zone than either alone.
Build it in Quant
Type one of these in the Quant desk, or click it. A request that fits a checked template is assembled on the spot without a credit; anything beyond the blanks goes to the copilot, which edits on top of the checked script.
Questions
Which pivot formula should I use?
The classic floor formula, unless you have a reason to change it. It is the most widely watched, which is part of why it works. Camarilla suits traders who fade the day's extremes, Fibonacci pivots suit those who already think in ratios, and Woodie's pivot leans towards the close. Test one variant at a time.
Do pivot points work on crypto?
They do, with one decision: which 24 hours count as the day. Most crypto traders use the UTC day, so the levels refresh at midnight UTC, but a different data feed may cut the day elsewhere. The levels only mean something if a large number of traders compute them the same way.
Why does price react at these levels?
Partly because yesterday's range is a fair estimate of today's, so the levels land near where extremes tend to fall, and partly because the formula is public and unchanged, so many participants place orders and set targets at the same prices. The reaction is real, but it is a pause, not a guaranteed reversal.
What timeframe should I put daily pivots on?
Intraday charts from 1 to 60 minutes. The levels come from the previous daily bar and hold for the whole day, so a chart that shows the day in 20 to 200 bars lets you see each test. On a daily chart the lines apply to the current bar only, which is usable but shows nothing of the test.
How is a break of R1 read?
A break rule waits for a close above R1, with R2 as the next level and R1 as the reference for the stop. A retest of R1 that holds from above is the later entry. If price closes back below R1 within a few bars, the break failed and the level is resistance again.
Do the levels repaint?
No. They are computed from the previous completed day, so they are known at the first bar of the session and never change until the next one. The implementation requests the previous day's prices with lookahead switched off, which is what keeps the historical levels honest in a backtest.