Awesome Oscillator (ao)

The Awesome Oscillator compares the recent level of a series with its longer-term level. It calculates the difference between two simple moving averages of the same source: a fast average that responds more readily to the latest values, and a slow average that changes more gradually. The result is a momentum measure based on the gap between those two averages.

The output is an unbounded series centered on zero. It is positive when the fast average is above the slow average, negative when it is below, and zero when the two coincide. The larger its absolute value, the farther apart the averages are. fast and slow set the two horizons being compared without changing this interpretation.

Block declaration

A strategy can contain multiple [[ao]] blocks. Each block produces one numeric series, identified by its id field.

Examples

Minimal setup

This block computes AO from the default hl2 source. Since fast and slow are omitted, the block uses the default lengths 5 and 34.

[[ao]]
id = "ao"

Custom fixed setup

This block uses the close as its source and custom lengths.

[[ao]]
id     = "ao"
source = "close"
fast   = 3
slow   = 10

Searching for the optimal lengths

This block explores several fast / slow pairs. Combinations where fast is not strictly lower than slow are ignored by the grid.

[[ao]]
id         = "ao"
fast.start = 3
fast.stop  = 15
slow.start = 20
slow.stop  = 50
slow.step  = 5

Momentum filter

This example uses AO as a confirmation filter. The condition becomes true only when the oscillator remains above zero.

[[ao]]
id = "ao"

[[condition]]
id            = "positive_momentum"
condition     = "ao > 0"
next_block_id = "..."

Parameters

ParameterDescription
id
 String
 Required
Unique name for the AO series.
source
 String
 or Array
 Optional
Input series used for the calculation.
Accepted forms: source = "hl2" or source = ["close", "hl2"].
Each value can be either a standard price source (open, close, high, low, hl2, hlc3, ohlc4, hlcc4, volume) or the id of another indicator.
Default value: "hl2"
fast
 Integer
 Optional
Length of the fast moving average; must be ≥ 1.
Default value: 5.

Usage:
• Fixed: fast = value
• Grid search:
 – fast.start = min_value
 – fast.stop = max_value
 – fast.step = value (optional, default 1)
slow
 Integer
 Optional
Length of the slow moving average; must be ≥ 1 and greater than fast for at least one generated combination.
Default value: 34.

Usage:
• Fixed: slow = value
• Grid search:
 – slow.start = min_value
 – slow.stop = max_value
 – slow.step = value (optional, default 1)
symbol
 String
 or Array
 Optional
Market symbol(s) used when source only consists of standard prices (open, close, high, low, hl2, hlc3, ohlc4, hlcc4, volume).
If source mixes standard prices and indicator ids, symbol is applied only to combinations based on standard prices.
If source contains only indicator ids, symbol is ignored.
If symbol is omitted, the block inherits the symbol defined in [backtest].
For symbol format, arrays, and alignment rules, see Exchanges, Symbols and Timeframes.
timeframe
 String
 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.

For fast and slow ranges, the configuration must generate at least one pair where fast < slow. Not every possible pair has to satisfy that relationship: invalid combinations are simply excluded from the grid.

Available variables

Use the identifiers below directly in your expressions. The AO block exposes one numeric series, both lengths in use, plus the input source, symbol, and timeframe.

Assume the block is configured as:

[[ao]]
id = "ao"

Then:

VariableDescription
ao or ao[0]
Decimal
Current AO value.
ao[n]
Decimal
AO value from n candles ago.
ao.fast
Decimal
Fast moving average length.
ao.slow
Decimal
Slow moving average length.
ao.source
String
Input series name.
ao.symbol
String
Symbol used.
ao.timeframe
String
Timeframe used.

Notes

  • Numeric variables support arithmetic, comparisons, and logical operators.
  • Text variables are strings intended for equality/inequality checks only.