Skip to main content
BTC / USDTCRYPTO107,400+2.19%ETH / USDTCRYPTO3,840+2.13%SOL / USDTCRYPTO182.40−1.99%BNB / USDTCRYPTO652.30+0.66%XRP / USDTCRYPTO2.2150+1.61%DOGE / USDTCRYPTO0.3850−1.79%TON / USDTCRYPTO5.240+2.34%AVAX / USDTCRYPTO42.60−2.07%LINK / USDTCRYPTO22.40+2.28%ADA / USDTCRYPTO1.0520−1.68%TRX / USDTCRYPTO0.3300+0.92%DOT / USDTCRYPTO8.420+2.93%BTC / USDTCRYPTO107,400+2.19%ETH / USDTCRYPTO3,840+2.13%SOL / USDTCRYPTO182.40−1.99%BNB / USDTCRYPTO652.30+0.66%XRP / USDTCRYPTO2.2150+1.61%DOGE / USDTCRYPTO0.3850−1.79%TON / USDTCRYPTO5.240+2.34%AVAX / USDTCRYPTO42.60−2.07%LINK / USDTCRYPTO22.40+2.28%ADA / USDTCRYPTO1.0520−1.68%TRX / USDTCRYPTO0.3300+0.92%DOT / USDTCRYPTO8.420+2.93%
定价

Awesome Oscillator

Bill Williams' 5/34 median-price momentum histogram — MT4, MT5, TradingView, TradeStation and MetaStock code.

The Awesome Oscillator plots the difference between a fast 5-bar and slow 34-bar simple moving average of the bar's median price, (high+low)/2, as a histogram around zero. Traders use zero-line crossings, twin-peaks and saucer setups to spot momentum shifts before price confirms. Copy the version for your platform.

Pine Script
//@version=5
indicator("Awesome Oscillator", overlay=false)
median = (high + low) / 2
ao = ta.sma(median, 5) - ta.sma(median, 34)
plot(ao, title="AO", style=plot.style_histogram, color=color.gray)
hline(0)
MQL4 · AwesomeOscillator.mq4
#property indicator_separate_window
#property indicator_buffers 1

double AoBuffer[];

int OnInit() {
  SetIndexBuffer(0, AoBuffer);
  IndicatorShortName("Awesome Oscillator");
  return 0;
}

int OnCalculate(const int rates_total, const int prev_calculated, const double &close[]) {
  for (int i = prev_calculated; i < rates_total; i++)
    AoBuffer[i] = iAO(NULL, 0, i);
  return rates_total;
}
MQL5 · AwesomeOscillator.mq5
#property indicator_separate_window
#property indicator_buffers 1

double AoBuffer[];

int OnInit() {
  SetIndexBuffer(0, AoBuffer);
  return INIT_SUCCEEDED;
}

int OnCalculate(const int rates_total, const int prev_calculated,
  const datetime &time[], const double &open[], const double &high[],
  const double &low[], const double &close[], const long &tick_volume[],
  const long &volume[], const int &spread[]) {
  for (int i = prev_calculated; i < rates_total; i++)
    AoBuffer[i] = iAO(NULL, 0, i);
  return rates_total;
}
EasyLanguage
variables: MedianPrice(0), AO(0);
MedianPrice = (High + Low) / 2;
AO = Average(MedianPrice, 5) - Average(MedianPrice, 34);
Plot1(AO, "Awesome Oscillator");
MetaStock
{Awesome Oscillator}
ao := Mov((H + L) / 2, 5, S) - Mov((H + L) / 2, 34, S);
ao

To use it inside dtcharts, paste any version into the Script Converter and it becomes a native indicator on your chart.