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);
  }
//+------------------------------------------------------------------+





Sample





Analysis



Market Information Used:

Series array that contains open time of each bar


Indicator Curves created:

Implements a curve of type DRAW_LINE
Implements a curve of type DRAW_HISTOGRAM


Indicators Used:

Moving average indicator


Custom Indicators Used:

Order Management characteristics:

Other Features: