Skip to content
ChartTailor
WorkServicesPricingField NotesAbout Start a build
← Pine Discoveries

A pivot's plotted location is not when the script discovered it

Pine pivot functions can plot on the pivot bar with an offset, but confirmation happens only after the right-side bars exist.

Pivot logic is a classic source of chart confusion. A pivot high appears above the exact candle where the turn happened, so it feels as if the script knew about it there. In reality, a pivot needs bars to the right before it can be confirmed. The marker can be plotted back on the pivot bar, but the discovery happened later.

I started keeping a note on this because pivot offsets are visually useful and semantically dangerous. They make charts readable. They also make signals look earlier than they were if the author does not explain the timing.

Why this catches people

Where people usually go wrong is to use a pivot as an entry signal on the bar where it is drawn. If ta.pivothigh() uses three right bars, the script did not confirm that pivot until three bars after the pivot candle. Plotting with offset = -rightBars places the marker where the pivot occurred. It does not move the script’s knowledge backward in time.

This is not repainting in the malicious sense when it is done honestly. It is delayed confirmation displayed at the source candle. The problem is when the visual offset is mistaken for signal timing.

The Pine bit

The code should keep both moments available: the pivot price and the confirmation bar. The pivot price belongs to the older bar. The signal event belongs to the current bar when the function returns a value. Alerts, strategy entries, and automation should use the confirmation moment unless the script is explicitly doing something else.

I like to name the right-side length in the input panel because it is not just a style setting. It is the delay. Increasing it may make pivots cleaner, but it also makes them later.

rightBars = input.int(3, "Pivot confirmation bars", minval = 1)
ph = ta.pivothigh(high, 3, rightBars)

plotshape(not na(ph), offset = -rightBars, style = shape.triangledown)
alertNow = not na(ph) and barstate.isconfirmed

How I handle it in builds

For visual swing tools, I am comfortable plotting the marker on the pivot candle because that is where the structure belongs. For alerts and strategies, I keep the timing separate. The alert message should not imply that the user could have acted on the pivot candle before the right-side bars existed.

This also matters across timeframes. A higher-timeframe pivot requested on a lower-timeframe chart has both pivot confirmation delay and request timing to consider. The marker may be visually elegant while the tradable signal is much later.

Where this shows up

A helpful display pattern is to show the pivot marker at the pivot candle and the confirmation marker at the confirmation candle during development. The final tool may only need the elegant pivot marker, but the two-marker version is excellent for verifying that alerts and strategies are using the correct bar.

This distinction also matters for screenshots. A user may point to a pivot marker and ask why there was no alert there. The answer is that the marker was drawn there after the fact. If the script can show or explain the confirmation delay, the support conversation becomes much easier.

I avoid using the word “repaint” too loosely around pivots. A confirmed pivot plotted back with an offset is delayed information displayed at its structural location. That is different from a live signal that appears and disappears. Both can confuse users, but they need different explanations and different alert rules.

How I test it

I test repainting claims by separating location from knowledge. A marker can be drawn on an earlier bar for readability, but an alert or strategy can only act when the information is actually known. I test that difference around live bars, offsets, and higher-timeframe transitions.

Checks before I trust it

  • Treat the right-side pivot length as signal delay.
  • Plot the pivot location and alert the confirmation moment separately.
  • Do not backtest entries as if the pivot were known on the pivot bar.
  • Label pivot tools clearly when users will trade from them.
  • Review multi-timeframe pivots for both pivot delay and request timing.

The practical takeaway is that offsets can make a chart easier to read and easier to misunderstand. A pivot’s location and discovery time are different facts.