AO (Awesome Oscillator)
The Awesome Oscillator compares a 5-period SMA to a 34-period SMA of the midpoint price (HL/2). It helps identify momentum shifts and trend strength.
Declaration
function init(ctx) { ctx.indicator('ao', 'AO', { fastPeriod: 5, slowPeriod: 34 }); }
Options
| Option | Type | Default | Description |
|---|---|---|---|
fastPeriod | number | 5 | Fast SMA period |
slowPeriod | number | 34 | Slow SMA period |
Output
Returns a single number[] series oscillating around zero.
Accessing Values
function onBar(ctx, i) { const ao = ctx.ind.ao[i]; }
Use Cases
Zero-Line Cross
function onBar(ctx, i) { const ao = ctx.ind.ao[i]; const prevAo = ctx.ind.ao[i - 1]; if (prevAo <= 0 && ao > 0) { ctx.order.market('ASSET', 1, { signal: 'buy', reason: 'ao_bullish' }); } if (prevAo >= 0 && ao < 0) { ctx.order.close('ASSET', { signal: 'sell', reason: 'ao_bearish' }); } }
Saucer Setup
function onBar(ctx, i) { const ao1 = ctx.ind.ao[i - 2]; const ao2 = ctx.ind.ao[i - 1]; const ao3 = ctx.ind.ao[i]; // Bullish saucer: AO > 0, dips then rises if (ao1 > ao2 && ao2 < ao3 && ao3 > 0) { ctx.order.market('ASSET', 1, { signal: 'buy', reason: 'ao_saucer' }); } }
Calculation
$$AO = SMA(HL/2, fastPeriod) - SMA(HL/2, slowPeriod)$$
Where $HL/2 = (High + Low) / 2$
Related
Related
indicatoraoawesomemomentumoscillatorqsl