Author: 2005-2014, MetaQuotes Software Corp.
AwesomeOC

This script functions as a visual momentum indicator designed to help traders identify the strength and direction of market trends by analyzing price movements over two different timeframes simultaneously.

Core Logic and Mechanics

The tool operates by calculating the difference between two moving averages: a "fast" average and a "slow" average. By comparing these two values, the script measures how quickly the current market price is reacting compared to its historical average.

1. Data Calculation The logic begins by taking two sets of data:

  • A short-term window (8 periods) to capture immediate price action.
  • A long-term window (34 periods) to represent the broader trend.

The script calculates the average price for both windows and subtracts the long-term average from the short-term average. The resulting value tells you whether the market is accelerating upward, slowing down, or pulling back.

2. Momentum Visualisation Rather than just providing a single line, the script organizes this data into a histogram (a series of vertical bars). It evaluates the current momentum value against the previous one to determine its direction:

  • Upward Momentum: If the current calculation is higher than the previous one, the script identifies this as positive momentum.
  • Downward Momentum: If the current calculation is lower than the previous one, it identifies this as negative momentum.

3. Visual Differentiation To make these signals easy to read at a glance, the script separates the data into two distinct visual categories:

  • Positive Bars (Bisque): These appear when the momentum is increasing or remains in a bullish state, helping traders see where buying pressure might be dominant.
  • Negative Bars (Tomato): These appear when the momentum is decreasing or remains in a bearish state, highlighting areas where selling pressure may be taking over.

Summary for Traders

Essentially, this tool filters out "market noise" by smoothing out price fluctuations. It allows you to see whether the current price trend is gaining strength or losing steam, providing a clear visual cue of market sentiment through contrasting colors and bar heights.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
AwesomeOC
//+------------------------------------------------------------------+
//|                                                      Awesome.mq4 |
//|                   Copyright 2005-2014, MetaQuotes Software Corp. |
//|                                              http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright   "2005-2014, MetaQuotes Software Corp."
#property link        "http://www.mql4.com"
#property description "Awesome Oscillator"
#property strict

//--- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  Black
#property  indicator_color2  Bisque
#property  indicator_color3  Tomato
//--- buffers
double     ExtAOBuffer[];
double     ExtUpBuffer[];
double     ExtDnBuffer[];
//---
#define PERIOD_FAST 8
#define PERIOD_SLOW 34
//--- bars minimum for calculation
#define DATA_LIMIT  34
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit(void)
  {
//--- drawing settings
   SetIndexStyle(0,DRAW_NONE);
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,4,Bisque);
   SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,4,Tomato);
   IndicatorDigits(Digits+1);
   SetIndexDrawBegin(0,DATA_LIMIT);
   SetIndexDrawBegin(1,DATA_LIMIT);
   SetIndexDrawBegin(2,DATA_LIMIT);
//--- 3 indicator buffers mapping
   SetIndexBuffer(0,ExtAOBuffer);
   SetIndexBuffer(1,ExtUpBuffer);
   SetIndexBuffer(2,ExtDnBuffer);
//--- name for DataWindow and indicator subwindow label
   IndicatorShortName("ao/oc");
   SetIndexLabel(1,NULL);
   SetIndexLabel(2,NULL);
  }
//+------------------------------------------------------------------+
//| Awesome Oscillator                                               |
//+------------------------------------------------------------------+
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[])
  {
   int    i,limit=rates_total-prev_calculated;
   double prev=0.0,current;
//--- check for rates total
   if(rates_total<=DATA_LIMIT)
      return(0);
//--- last counted bar will be recounted
   if(prev_calculated>0)
     {
      limit++;
      prev=ExtAOBuffer[limit];
     }
//--- macd
   for(i=0; i<limit; i++)
      ExtAOBuffer[i]=(iMA(NULL,0,PERIOD_FAST,0,MODE_SMA,PRICE_MEDIAN,i)+
                      iMA(NULL,0,PERIOD_FAST,0,MODE_SMA,PRICE_MEDIAN,i+1))/2-
                     (iMA(NULL,0,PERIOD_SLOW,0,MODE_SMA,PRICE_MEDIAN,i)+
                      iMA(NULL,0,PERIOD_SLOW,0,MODE_SMA,PRICE_MEDIAN,i+1))/2;
//      ExtAOBuffer[i]=(iOpen(NULL,0,i+1)+iHigh(NULL,0,i+1)+iLow(NULL,0,i+1)+iClose(NULL,0,i+1)+iOpen(NULL,0,i)+iHigh(NULL,0,i)+iLow(NULL,0,i)+iClose(NULL,0,i))/8;
//--- dispatch values between 2 buffers
   bool up=true;
   for(i=limit-1; i>=0; i--)
     {
      current=ExtAOBuffer[i];
      if(current>prev)
         up=true;
      if(current<prev)
         up=false;
      if(!up)
        {
         ExtDnBuffer[i]=current;
         ExtUpBuffer[i]=0.0;
        }
      else
        {
         ExtUpBuffer[i]=current;
         ExtDnBuffer[i]=0.0;
        }
      prev=current;
     }
//--- done
   return(rates_total);
  }
//+------------------------------------------------------------------+

Comments