Awesome_v1

This script is designed as a visual trading tool for MetaTrader, specifically used to help traders identify momentum and trend reversals in the market. It functions by calculating the difference between two different types of moving averages and visualizing that information as a color-coded histogram.

Core Logic and Mechanism

1. The Foundation: Momentum Calculation At its core, the script measures price momentum by comparing a "fast" average to a "slow" average.

  • It looks at a 5-period moving average, which reacts quickly to recent price changes.
  • It compares this against a 34-period moving average, which represents a longer-term trend.

By subtracting the slower average from the faster one, the script determines whether the current market momentum is accelerating or decelerating. If the result is positive, it suggests upward momentum; if negative, it suggests downward momentum.

2. Trend Detection and Directional Shift The script doesn't just show these values; it analyzes the relationship between the current value and the previous value to determine the direction of the trend.

  • It checks if the current momentum is higher or lower than what it was in the previous bar.
  • If the momentum is rising, it identifies an "up" trend.
  • If the momentum is falling, it identifies a "down" trend.

3. Visual Representation To make this information easy to read at a glance, the script translates these mathematical calculations into a dual-colored histogram:

  • Green Highlights: When the momentum is moving upward, the script plots the values in green. This serves as a visual cue for bullish activity.
  • Red Highlights: When the momentum turns downward, the script switches the display to red. This acts as a warning sign for bearish activity.

Summary for the User

Essentially, this tool filters out "market noise" by smoothing out price data into two averages. It then highlights the "swing" of the market—showing you not just where the price is, but whether the speed and strength of that price movement are increasing or decreasing, allowing for a clearer view of market sentiment.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
Awesome_v1
//+------------------------------------------------------------------+
//|                                                      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