NoName04

Overview of the Awesome Oscillator Logic

This script functions as a visual momentum indicator designed to help traders identify the strength and direction of market trends. Instead of just showing the price of an asset, it measures the "velocity" of the market movement to provide clearer signals on whether the current trend is accelerating or losing steam.

How the Calculation Works

The logic operates by comparing two different types of moving averages (which are essentially smoothed averages of past prices).

  1. Short-Term vs. Long-Term Momentum: The script calculates a fast-moving average (based on the most recent 5 periods) and a slow-moving average (based on the last 34 periods). By subtracting the slow average from the fast average, the tool determines the "gap" between current market behavior and historical behavior.
  2. Trend Identification:
    • When the result of this calculation is positive, it suggests that recent price action is stronger than the historical average, often indicating upward momentum.
    • When the result is negative, it suggests that recent prices are lagging behind the historical average, often indicating downward momentum.

Visual Representation and Behavior

To make these calculations easy for a human to read at a glance, the script translates the data into a color-coded histogram in a separate window below the main price chart:

  • Color Switching: The script constantly monitors whether the current momentum value is higher or lower than the value immediately preceding it.
  • Green Bars: When the momentum is rising (the current value is greater than the previous one), the bars are displayed in green. This signals a strengthening trend or a positive shift in sentiment.
  • Red Bars: When the momentum starts to drop (the current value is lower than the previous one), the bars switch to red. This signals that the trend is weakening or shifting toward the downside.

Summary for Traders

Essentially, this tool acts as a "speedometer" for price action. Rather than looking at the raw price, you are looking at the difference between short-term and long-term averages. It helps you see not just where the price is going, but how fast it is moving there, allowing for a quicker visual distinction between bullish and bearish momentum through the use of contrasting colors.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
17 Views
0 Downloads
0 Favorites
NoName04
//+------------------------------------------------------------------+
//|                                                      Awesome.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2004, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 2
#property  indicator_color1  Green
#property  indicator_color2  Red
//---- indicator buffers
double     ind_buffer1[];
double     ind_buffer2[];
double     ind_buffer3[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 1 additional buffer used for counting.
   IndicatorBuffers(3);
   //---- drawing settings
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,3);
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,3);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
   SetIndexDrawBegin(0,34);
   SetIndexDrawBegin(1,34);
//---- 3 indicator buffers mapping
   if(!SetIndexBuffer(0,ind_buffer1) &&
      !SetIndexBuffer(1,ind_buffer2) &&
      !SetIndexBuffer(2,ind_buffer3))
      Print("cannot set indicator buffers!");
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("AO");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Awesome Oscillator                                               |
//+------------------------------------------------------------------+
int start()
  {
   int    limit;
   int    counted_bars=IndicatorCounted();
   double prev,current;
//---- check for possible errors
   if(counted_bars<0) return(-1);
   //---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- macd counted in the 1-st additional buffer
   for(int i=0; i<limit; i++)
      ind_buffer3[i]=iMA(NULL,0,5,0,MODE_SMA,PRICE_MEDIAN,i)-iMA(NULL,0,34,0,MODE_SMA,PRICE_MEDIAN,i);
//---- dispatch values between 2 buffers
   bool up=true;
   for(i=limit-1; i>=0; i--)
     {
      current=ind_buffer3[i];
      prev=ind_buffer3[i+1];
      if(current>prev) up=true;
      if(current<prev) up=false;
      if(!up)
        {
         ind_buffer2[i]=current;
         ind_buffer1[i]=0.0;
        }
      else
        {
         ind_buffer1[i]=current;
         ind_buffer2[i]=0.0;
        }
     }
//---- done
   return(0);
  }

Comments