Strategy · Pine Script v5 · Own pane

Awesome Oscillator - Eterna MCP

by EternaHybridExchange

This strategy implements Bill Williams' Awesome Oscillator (AO) calculated as the difference between two simple moving averages of the median price.

View on GitHub

GitHub stars9on the repository
Pine versionv5runs as is
Lines of code102
Settings4inputs
LicenceMIT
Last update7 months ago12 Mar 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

102 lines of Pine Script v5 from strategies/momentum/awesome_oscillator.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

awesome_oscillator.pine
//@version=5
strategy("Awesome Oscillator - Eterna MCP", 
         shorttitle="AO",
         overlay=false,
         default_qty_type=strategy.percent_of_equity,
         default_qty_value=100,
         initial_capital=1000)

// ============================================
// PARAMETERS
// ============================================
fastLength = input.int(5, "Fast SMA Length", minval=1)
slowLength = input.int(34, "Slow SMA Length", minval=1)
leverageSize = input.float(5.0, "Leverage", minval=1, maxval=100)
positionSize = input.float(0.01, "Position Size", minval=0.001, maxval=1)

// ============================================
// AWESOME OSCILLATOR CALCULATION
// ============================================
// Median price
medianPrice = (high + low) / 2

// Fast and slow SMAs
fastSMA = ta.sma(medianPrice, fastLength)
slowSMA = ta.sma(medianPrice, slowLength)

// Awesome Oscillator
ao = fastSMA - slowSMA

// ============================================
// SIGNAL GENERATION
// ============================================
// Zero-line cross
bullishZeroCross = ta.crossover(ao, 0)
bearishZeroCross = ta.crossunder(ao, 0)

// Twin Peaks (divergence pattern)
// Bullish Twin Peaks: two lows below zero, second higher than first
twinPeakBullish = ao < 0 and ao > ao[2] and ao[2] < ao[4] and ao > 0[1]

// Bearish Twin Peaks: two highs above zero, second lower than first
twinPeakBearish = ao > 0 and ao < ao[2] and ao[2] > ao[4] and ao < 0[1]

// Saucer pattern (momentum shift)
// Bullish Saucer: three consecutive bars, middle lowest, last green
saucerBullish = ao > 0 and ao < ao[1] and ao[1] < ao[2] and ao > ao[1]

// Bearish Saucer: three consecutive bars, middle highest, last red
saucerBearish = ao < 0 and ao > ao[1] and ao[1] > ao[2] and ao < ao[1]

// Color change (early momentum signal)
aoGreen = ao > ao[1]
aoRed = ao < ao[1]

// Consecutive color bars
consecutiveGreen = aoGreen and aoGreen[1] and ao > 0
consecutiveRed = aoRed and aoRed[1] and ao < 0

// Combined entry signals
buySignal = bullishZeroCross or twinPeakBullish or (saucerBullish and consecutiveGreen)
sellSignal = bearishZeroCross or twinPeakBearish or (saucerBearish and consecutiveRed)

// ============================================
// STRATEGY LOGIC
// ============================================
if buySignal and strategy.position_size == 0
    strategy.entry("Long", strategy.long)
    alert('{"action":"buy","symbol":"' + syminfo.ticker + '","size":' + str.tostring(positionSize) + ',"leverage":' + str.tostring(leverageSize) + '}', alert.freq_once_per_bar_close)

if sellSignal and strategy.position_size == 0
    strategy.entry("Short", strategy.short)
    alert('{"action":"sell","symbol":"' + syminfo.ticker + '","size":' + str.tostring(positionSize) + ',"leverage":' + str.tostring(leverageSize) + '}', alert.freq_once_per_bar_close)

// Exit on opposite signal
if sellSignal and strategy.position_size > 0
    strategy.close("Long")

if buySignal and strategy.position_size < 0
    strategy.close("Short")

// ============================================
// PLOTTING
// ============================================
// Histogram with color coding
aoColor = ao > ao[1] ? color.green : color.red
plot(ao, "Awesome Oscillator", color=aoColor, style=plot.style_histogram, linewidth=3)

// Zero line
hline(0, "Zero Line", color=color.gray, linestyle=hline.style_solid, linewidth=2)

// Signals
plotshape(buySignal, "Buy", shape.triangleup, location.bottom, color.lime, size=size.normal)
plotshape(sellSignal, "Sell", shape.triangledown, location.top, color.red, size=size.normal)

// Pattern markers
plotshape(twinPeakBullish, "Twin Peak Buy", shape.diamond, location.bottom, color.aqua, size=size.small)
plotshape(twinPeakBearish, "Twin Peak Sell", shape.diamond, location.top, color.orange, size=size.small)
plotshape(saucerBullish, "Saucer Buy", shape.circle, location.bottom, color.green, size=size.tiny)
plotshape(saucerBearish, "Saucer Sell", shape.circle, location.top, color.maroon, size=size.tiny)

// Background zone
bgcolor(ao > 0 ? color.new(color.green, 98) : color.new(color.red, 98))

Overview

Awesome Oscillator - Eterna MCP generates long and short entries using three classic signal triggers: zero-line crossovers, twin peaks divergence patterns, and saucer setups backed by consecutive momentum bars. Positions close upon receiving an opposing signal. It plots the AO histogram and signal shapes in a separate pane. By default, there are no take-profit or stop-loss orders, relying entirely on signal reversals.

Details

Published by

EternaHybridExchange on GitHub

Type

Strategy, Pine Script v5

Draws

Separate pane below the chart

Category

Oscillators & momentum, Moving averages, Divergence

Markets

Crypto

Timeframes

Any timeframe

Risk Notes

  • The strategy enters trades without a stop loss

Topics

algorithmic-tradingautomated-tradingbacktestingbybitcrypto-tradingeternamcppine-scripttrading-strategiestradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Fast SMA Lengthint5fastLength
Slow SMA Lengthint34slowLength
Leveragefloat5.0leverageSize
Position Sizefloat0.01positionSize
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

330 stars

MACD + Divergences [Alorse] is a momentum strategy that calculates the MACD oscillator and identifies regular and hidden divergences using pivot high and low points. It filters trade signals with dual Exponential Moving Averages (EMA 150 and 600) to ensure tra

Strategy v4 Oscillators & momentumDivergence Repaints
Updated 2 months ago · None stated GitHub repository of MACD + Divergences [Alorse]
24 stars

This overlay strategy combines a Cipher B WaveTrend oscillator with two optional moving averages on the price chart. It exposes WaveTrend channel and average lengths, overbought and oversold levels, buy, sell and gold dots, and regular or hidden divergence mar

Strategy v5 Oscillators & momentumMoving averages
Updated 4 years ago · MPL-2.0 GitHub repository of Cipher B + EMAs Strategy

Divergenced B004

by ruckard
13 stars

Divergenced B004 is a Pine Script strategy that plots on the price chart and looks for divergences in the Squeeze Momentum Indicator. It shorts when a green-section squeeze value falls while price rises, and longs when a red-section squeeze value rises while p

Strategy v5 DivergenceOscillators & momentum
Updated 1 year ago · None stated GitHub repository of Divergenced B004

This strategy executes long positions by combining a 200-period EMA trend filter, Stochastic RSI oversold crosses, and Williams Alligator retracements, supplemented by RSI divergence detection. It triggers long entries when the price trades above the 200 EMA w

Strategy v4 TrendOscillators & momentum
Updated 3 years ago · Apache-2.0 GitHub repository of 200 EMA + Alligator + Stochastic Long Strategy

MACD Crossover (tutorial)

by pineforge-4pass
193 stars

This strategy calculates the Moving Average Convergence Divergence indicator and plots the MACD line, signal line, and histogram in a separate pane. It enters long positions when the MACD line crosses above the signal line and enters short positions when it cr

Strategy v6 Oscillators & momentumMoving averages
Updated today · Apache-2.0 GitHub repository of MACD Crossover (tutorial)

8D Run

by hasnocool
106 stars

8D Run is a Pine Script momentum strategy inspired by Linda Bradford Raschke. It tracks consecutive price closes relative to a 5-period Simple Moving Average (SMA). When price remains above the SMA for 8 or more bars and then dips below it, the strategy enters

Strategy v5 Oscillators & momentumMoving averages
Updated 2 years ago · GPL-3.0 GitHub repository of 8D Run

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers