Sidechair

ta.sar()

Browse the reference

Returns the Parabolic SAR: a stop-and-reverse level that accelerates toward price while a trend lasts and flips when price touches it.

Try it in the editor

ta.sar starts an acceleration factor at start. Each time the trend sets a new extreme, the factor grows by inc up to max, and the SAR moves that fraction of the way toward the extreme. When price touches the SAR, the trend flips and the factor resets.

The SAR is clamped so it never sits inside the highs or lows of the previous two bars. The first value appears on bar number 2, with the direction taken from the first two closes.

Syntax

Pine Script
ta.sar(start: simple int/float, inc: simple int/float, max: simple int/float) -> series float

Arguments

NameTypeDefaultDescription
startsimple int/floatrequiredInitial acceleration factor, applied after each reversal. Typical value 0.02.
incsimple int/floatrequiredIncrement added to the factor on each new extreme. Typical value 0.02.
maxsimple int/floatrequiredCap for the acceleration factor. Typical value 0.2.

Returns

series float: the stop-and-reverse price level for the current bar.

Remarks

  • Plot it as dots with style = plot.style_circles to match the usual look.
  • The level depends on the chart's first bars, because the first trend direction is a guess from two closes.

Example

Pine ScriptParabolic SAR dotsOpen in editor
//@version=6
indicator("Parabolic SAR", overlay = true)
sar = ta.sar(0.02, 0.02, 0.2)
plot(sar, "SAR", color = close > sar ? color.green : color.red, style = plot.style_circles)

See also

Runs on Sidechair