Awesome_(AO)_mtf

Download script
Awesome_(AO)_mtf

This technical tool is designed to provide traders with a visual representation of market momentum by analyzing price trends across multiple timeframes. Rather than simply looking at the current price movement, it calculates the relationship between different moving averages to highlight whether the market's strength is accelerating or slowing down.

Core Logic and Functionality

Multi-Timeframe Analysis The script features the ability to analyze data from a specific timeframe (such as 1-minute, 1-hour, or daily charts) regardless of which chart you are currently viewing. It ensures that if the chosen analysis period is smaller than your current view, it automatically adjusts to match your screen, providing a consistent perspective on market trends.

Momentum Calculation At its heart, the tool calculates a "difference" value. It takes two different Simple Moving Averages (SMAs)—one based on a short-term window of 5 periods and another based on a longer-term window of 34 periods—and measures the gap between them. By using the "Median Price," the calculation remains stable and less susceptible to extreme price spikes or "noise" that can sometimes mislead standard indicators.

Visual Signaling (Color Coding) To make this data easy to interpret at a glance, the script translates these raw calculations into a color-coded histogram:

  • Green Highlights: When the current momentum value is higher than the previous one, it signals upward movement or strengthening positive pressure.
  • Red Highlights: When the momentum value drops compared to the previous point, it indicates downward movement or weakening trend strength.

Key Features for the User

  • Dynamic Adjustments: The tool includes a "Shift" setting that allows you to move the signal line forward or backward on the chart to better align with your personal trading strategy.
  • Historical Depth: The script is configured to process a significant amount of historical data (up to 1,500 bars), allowing for a deep look-back to identify recurring patterns.
  • Visual Clarity: By using distinct colors and a histogram format, the tool eliminates the need for complex manual calculations, allowing traders to quickly identify whether the current market "pulse" is expanding or contracting.
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
Awesome_(AO)_mtf
//+------------------------------------------------------------------+
//|                                                      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
#property indicator_width2 2
#property indicator_width3 2

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

extern int TimeFrame = 0;
extern int SigLineShift =0;
extern int MaxBarsToCount = 1500;
extern string  defaults   = "5,34; SMA,PRICE_MEDIAN";
extern string  TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-CurrentTF";




//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   //---- drawing settings
   SetIndexStyle(0,DRAW_LINE);
   SetIndexShift(0,SigLineShift);
   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
   SetIndexLabel(1,NULL);
   SetIndexLabel(2,NULL);

   switch(TimeFrame)
   {
      case 1: string TimeFrameStr ="M1";  break;
      case 5     :   TimeFrameStr ="M5";  break;
      case 15    :   TimeFrameStr ="M15"; break;
      case 30    :   TimeFrameStr ="M30"; break;
      case 60    :   TimeFrameStr ="H1";  break;
      case 240   :   TimeFrameStr ="H4";  break;
      case 1440  :   TimeFrameStr ="D1";  break;
      case 10080 :   TimeFrameStr ="W1";  break;
      case 43200 :   TimeFrameStr ="MN1"; break;
      default : TimeFrameStr = "CurrentTF";
   }
  
   IndicatorShortName("AO ["+TimeFrameStr+"]");


   if (TimeFrame<Period()) TimeFrame=Period();


//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Awesome Oscillator                                               |
//+------------------------------------------------------------------+
int start()
  {
   datetime TimeArray[];
   int    i,limit,y=0,counted_bars=IndicatorCounted();
   double prev,current;
//---- last counted bar will be recounted
//   if(counted_bars>0) counted_bars--;
   ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame); 

limit= Bars-counted_bars;
limit= MathMax(limit,TimeFrame/Period());
limit= MathMin(limit,MaxBarsToCount);

   for(i=0,y=0;i<limit;i++)
   {
   if (Time[i]<TimeArray[y]) y++;
//---- macd
      ExtBuffer0[i]=iMA(NULL,TimeFrame,5,0,MODE_SMA,PRICE_MEDIAN,y)-iMA(NULL,TimeFrame,34,0,MODE_SMA,PRICE_MEDIAN,y);
//---- 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