Oscillator of ATR





//+------------------------------------------------------------------+
//|                                            Oscillator of ATR.mq4 |
//|                                                   vasbsm@mail.ru |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "vasbsm@mail.ru"
#property link      ""

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
#property indicator_width1 3
//---- input parameters
extern int       FirstAtrPeriod=138;
extern int       SecondAtrPeriod=94;
extern int       TypeMA=0;
//-----------------------
double OscAtrBuffer[];
double TempBuffer[];
//------------------------
int init()
  {
   string short_name;
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,OscAtrBuffer);
   SetIndexBuffer(1,TempBuffer);
   short_name="Oscillator of ATR("+FirstAtrPeriod+","+SecondAtrPeriod+","+"Type of MA="+TypeMA+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
   SetIndexDrawBegin(0,FirstAtrPeriod);
   return(0);
  }
//---------------------------------------------
int start()
  {
   int    counted_bars=IndicatorCounted(),i;
   if(Bars<=FirstAtrPeriod) return(0);
   if(counted_bars<1)
      for(i=1;i<=FirstAtrPeriod;i++) OscAtrBuffer[Bars-i]=0.0;    
   //----------------
      i=Bars-counted_bars-1;
   while(i>=0)
     {
      double high=High[i];
      double low =Low[i];
      if(i==Bars-1) TempBuffer[i]=high-low;
      else
        {
         double prevclose=Close[i+1];
         TempBuffer[i]=1000*(MathMax(high,prevclose)-MathMin(low,prevclose));
        }
      i--;
     }
    //---------------
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;
   for(i=0; i<limit; i++)
      OscAtrBuffer[i]=iMAOnArray(TempBuffer,Bars,FirstAtrPeriod,0,TypeMA,i)-iMAOnArray(TempBuffer,Bars,SecondAtrPeriod,0,TypeMA,i);
    //---------------   
   return(0);
  }
//+------------------------------------------------------------------+



Sample





Analysis



Market Information Used:

Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar
Series array that contains close prices for each bar


Indicator Curves created:

Implements a curve of type DRAW_HISTOGRAM


Indicators Used:

Moving average indicator


Custom Indicators Used:

Order Management characteristics:

Other Features: