Parabolic SAR (sar)
[[sar]] computes the Parabolic SAR (Stop and Reverse), a trailing level represented as a numeric series around price. During an upward phase it moves below price; during a downward phase it moves above price. When price crosses the calculated level, SAR switches sides and a new phase begins.
The level accelerates as the phase reaches new extremes. start sets the initial acceleration, increment increases it at each new extreme, and max_value caps its growth. This makes the level close the gap to price more quickly as the move continues. When SAR switches sides, the acceleration resets to its initial value.
Block declaration
A strategy can contain multiple [[sar]] blocks. Each block outputs one numeric series named by id.
The [[sar]] block has no source parameter: it is always computed from the candle high, low, and close prices of the selected symbol and timeframe.
Examples
Minimal setup
This block uses the default parameters: start = 0.02, increment = 0.02, and max_value = 0.2.
[[sar]]
id = "sar"Custom fixed setup
This block uses a more reactive SAR than the default setup.
[[sar]]
id = "sar"
start = 0.03
increment = 0.04
max_value = 0.3Search for optimal parameters
This block explores several starting values and acceleration caps while keeping the increment fixed.
[[sar]]
id = "sar"
start.start = 0.01
start.stop = 0.04
start.step = 0.01
increment = 0.02
max_value.start = 0.1
max_value.stop = 0.3
max_value.step = 0.05Bullish context filter
This example uses SAR as a trend filter and optimizes max_value to test several levels of reactivity. The strategy only moves to the next block when the closing price is above SAR, which usually corresponds to a bullish context.
[[sar]]
id = "sar"
start = 0.02
increment = 0.02
max_value.start = 0.1
max_value.stop = 0.3
max_value.step = 0.05
[[condition]]
id = "price_above_sar"
condition = "close > sar"
next_block_id = "..."Dedicated symbol and timeframe
This block computes SAR from the daily candles of BINANCE:ETHUSDT. The high, low, and close prices come from this symbol and timeframe, independently of the primary symbol and timeframe defined in [backtest]. See Exchanges, Symbols and Timeframes for alignment rules.
[[sar]]
id = "sar"
symbol = "BINANCE:ETHUSDT"
timeframe = "D"Parameters
| Parameter | Description |
|---|---|
idString Required | Unique name identifying the SAR series; the block exposes one numeric series with this identifier. |
startDecimal Optional | Initial value of the acceleration factor; must be strictly greater than 0 when specified.If start is omitted, the default value is 0.02.Usage: • Fixed: start = value• Grid search: – start.start = min_value– start.stop = max_value– start.step = value (optional, default 1.0) |
incrementDecimal Optional | Increment added to the acceleration factor when the trend makes a new extreme point; must be strictly greater than 0 when specified.If increment is omitted, the default value is 0.02.Usage: • Fixed: increment = value• Grid search: – increment.start = min_value– increment.stop = max_value– increment.step = value (optional, default 1.0) |
max_valueDecimal Optional | Maximum value of the acceleration factor; must be strictly greater than 0 when specified.If max_value is omitted, the default value is 0.2.max_value may be lower than start; Whale-E accepts this configuration.Usage: • Fixed: max_value = value• Grid search: – max_value.start = min_value– max_value.stop = upper_value– max_value.step = value (optional, default 1.0) |
symbolString or Array Optional | Market symbol from which SAR reads its candles (high, low, and close prices). For symbol format and alignment rules, see Exchanges, Symbols and Timeframes. |
timeframeString or Array Optional | Timeframe on which this indicator is computed. If timeframe is omitted, the computation uses the grid’s main timeframe defined in [backtest].For accepted formats and timeframe alignment rules, see Exchanges, Symbols and Timeframes. |
Available variables
The SAR block exposes one numeric series and its parameters, along with its input sources, symbol, and timeframe.
Assume the block is configured as:
[[sar]]
id = "sar"Then:
| Variable | Description |
|---|---|
sar or sar[0]Decimal | Current SAR value. |
sar[n]Decimal | SAR value from n candles ago. |
sar.startDecimal | Initial acceleration factor used for sar. |
sar.incrementDecimal | Acceleration factor increment used for sar. |
sar.max_valueDecimal | Acceleration factor cap used for sar. |
sar.high_sourcesar.low_sourcesar.close_sourceString | Names of the high, low, and close input series used by the SAR series. |
sar.symbolString | Symbol used by the SAR series. |
sar.timeframeString | Timeframe used by the SAR series. |
Notes
- Numeric variables support arithmetic, comparisons, and logical operators.
- Text variables are strings intended for equality/inequality checks only.