Awesome

This script is designed to function as a visual trading tool that helps identify momentum and price trends on your charts. It works by calculating the relationship between two different moving averages—essentially comparing the short-term price behavior against the long-term average to see which one is currently leading.

How the Logic Works

1. Calculating Momentum The core of this tool begins by measuring a "momentum" value. It does this by taking a fast-moving average (focused on the last 5 periods) and subtracting a much slower-moving average (focused on the last 34 periods). When the difference between these two is positive, it suggests that short-term price action is moving upward relative to the long-term trend. When the difference is negative, it suggests downward movement.

2. Identifying Trend Direction Once the momentum value is calculated, the script analyzes how that value changes from one moment to the next. It looks for "peaks" and "valleys":

  • If the current momentum value is higher than the previous one, the trend is considered to be moving up.
  • If the current momentum value is lower than the previous one, the trend is considered to be moving down.

3. Visual Representation To make this information easy for a trader to read, the script organizes these calculations into a distinct visual format:

  • Upward Momentum: When the momentum values are increasing, the tool highlights the data points (often represented in green).
  • Downward Momentum: When the momentum values are decreasing, the tool highlights the data points (often represented in red).

By comparing these visual "bars," you can quickly see the strength and direction of the market's momentum. It allows you to distinguish between areas where the price is gaining steam and areas where it might be losing energy, providing a clearer picture of the current market sentiment.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
Awesome
//+------------------------------------------------------------------+
//|                                                      Awesome.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2005, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  Black
#property  indicator_color2  Green
#property  indicator_color3  Red

//---- indicator buffers
double     ExtBuffer0[];
double     ExtBuffer1[];
double     ExtBuffer2[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   //---- drawing settings
   SetIndexStyle(0,DRAW_NONE);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   IndicatorDigits(Digits+1);
   SetIndexDrawBegin(0,34);
   SetIndexDrawBegin(1,34);
   SetIndexDrawBegin(2,34);
//---- 3 indicator buffers mapping
   SetIndexBuffer(0,ExtBuffer0);
   SetIndexBuffer(1,ExtBuffer1);
   SetIndexBuffer(2,ExtBuffer2);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("AO");
   SetIndexLabel(1,NULL);
   SetIndexLabel(2,NULL);
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Awesome Oscillator                                               |
//+------------------------------------------------------------------+
int start()
  {
   int    limit;
   int    counted_bars=IndicatorCounted();
   double prev,current;
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- macd
   for(int i=0; i<limit; i++)
      ExtBuffer0[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=ExtBuffer0[i];
      prev=ExtBuffer0[i+1];
      if(current>prev) up=true;
      if(current<prev) up=false;
      if(!up)
        {
         ExtBuffer2[i]=current;
         ExtBuffer1[i]=0.0;
        }
      else
        {
         ExtBuffer1[i]=current;
         ExtBuffer2[i]=0.0;
        }
     }
//---- done
   return(0);
  }

Comments