Docs

ta.sar

Trail a stop that flips sides when price reverses through it.

itm
ta.sar(start, increment, maximum, bars)

Parabolic stop and reverse, Wilder's method. Per bar, in this order: step the stop toward the extreme point by the acceleration factor. If the stop has been touched, reverse: the new stop is the extreme of this bar and the old extreme point, the new extreme point is this bar's other extreme, and the factor resets to start. Otherwise widen the factor by increment, capped at maximum, if and only if this bar set a new extreme. Finally clamp the stop outside the previous two bars' range so it never sits inside the bars it trails. The trend is seeded on the second bar from the direction of the close, with the stop at the first bar's low for an uptrend or its high for a downtrend. Bars are read from bars. There is no direction output. The stop is below price in an uptrend and above it in a downtrend, so close > ta.sar() is the test.

Parameters

A series parameter takes a value on every bar. A constant parameter must be known before the first bar, such as a number or an input.

NameKindTypeUnitDefaultRangeDescription
startConstantnumber-0.020.000001 to 1The acceleration factor the trend starts at after every reversal.
incrementConstantnumber-0.020 to 1How much the acceleration factor widens on each new extreme.
maximumConstantnumber-0.20.000001 to 1The ceiling the acceleration factor may widen to.
barsConstantbarsbarsna-Which bars to read: a declared series, or na for the chart's own.

Output

NameTypeUnit
valuenumber-

Warm-up and missing values

Warm-up
2 bars.
Missing values
na on the first bar (the trend is seeded from the first close-to-close direction, which needs two bars) and na while bars has no bar available. A bar that cannot be read leaves the state where it was. The stop stands and the next usable bar carries on without re-seeding.

Example

itm
ta.sar(0.02, 0.02, 0.2)
itm
plot(ta.sar(0.02, 0.02, 0.2), "Stop and reverse")