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.
//@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)#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;
}#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;
}variables: MedianPrice(0), AO(0);
MedianPrice = (High + Low) / 2;
AO = Average(MedianPrice, 5) - Average(MedianPrice, 34);
Plot1(AO, "Awesome Oscillator");{Awesome Oscillator}
ao := Mov((H + L) / 2, 5, S) - Mov((H + L) / 2, 34, S);
aoTo use it inside dtcharts, paste any version into the Script Converter and it becomes a native indicator on your chart.