Skip to main content

Module sar

Module sar 

Source
Expand description

§Parabolic SAR (Stop and Reverse)

Classic Welles Wilder trailing stop:

SAR_t = SAR_{t−1} + AF * (EP − SAR_{t−1})

with acceleration factor AF starting at start, stepping by increment up to maximum when EP makes new extremes, and flipping long/short when price crosses SAR.

Default: (0.02, 0.02, 0.20) (SarParams::standard).

First bar is warm-up (None); SAR starts at bar 1.


§Trading perspective

ReadingHabit (classic)
SAR below price (dir +1)Long / trail under
SAR above price (dir −1)Short / trail over
FlipStop-and-reverse system signal

SAR is aggressive in chop (many flips). Often filtered by ADX or a slow MA.

§vs Supertrend

SARSupertrend
MechanismAF toward extreme pointATR bands around mid
FeelCan hug price tightlySmoother ATR trail
Choppy marketsWhipsaws moreMult tuning helps

Many desks pick one primary trail (SAR or Supertrend), not both as simultaneous entry signals.

§Pairs well with

  • ADX — only reverse with SAR when ADX shows trend (or only enter with SAR + ADX).
  • RSI — avoid long SAR flips into overbought extremes without confirmation.
  • ATR — independent stop size check (SAR distance ≠ risk budget).

§Engineering

SarParamssar / SarStatesar_solution. Batch via state.
Initial long/short seed uses a simple first-bar extreme heuristic (documented convention; platforms differ slightly on the very first flip).

Structs§

SarBarOutput
SarParams
Parabolic SAR acceleration parameters.
SarSeries
SarSolution
SarState
Incremental Parabolic SAR.
ValidatedSar

Functions§

sar
sar_solution
Examples