ATR_x2LHist_mtf





//+------------------------------------------------------------------+
//|                                                          ATR.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|atr x2                                 http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
//2008fxtsd   mtf keris f-la

#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 DeepSkyBlue
#property indicator_color2 RoyalBlue
#property indicator_width1 1
#property indicator_width2 1

#property indicator_level1 0.001
#property indicator_levelcolor  SlateGray
//---- input parameters
extern int AtrPeriod1=2;
extern int AtrPeriod2=14;


extern int TimeFrame=0;
extern string TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN";

//---- buffers
double AtrBuffer1[];
double AtrBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {

//   IndicatorBuffers(3);
//---- indicator line
   SetIndexStyle (0,DRAW_LINE);   
   SetIndexStyle (1,DRAW_HISTOGRAM);
   SetIndexBuffer(0,AtrBuffer2);   
   SetIndexBuffer(1,AtrBuffer1);


//---- name for DataWindow and indicator subwindow label
  
   TimeFrame = MathMax (TimeFrame,Period());

   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="MN"; break;
      default : TimeFrameStr="TF0";
   } 
  
   string short_name;
   short_name="ATR_("+AtrPeriod1+","+AtrPeriod2+") ["+TimeFrameStr+"] ";
   IndicatorShortName(short_name);
   
   SetIndexLabel(0,"ATR1 "+short_name);
   SetIndexLabel(1,"ATR2 "+short_name);

   SetIndexDrawBegin(0,AtrPeriod2);
   SetIndexDrawBegin(1,AtrPeriod1);

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Average True Range                                               |
//+------------------------------------------------------------------+
int start()
  {
   datetime TimeArray[];
   int    i,shift,limit,y,counted_bars=IndicatorCounted();
 
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
 
   ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame); 

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

   for(i=0,y=0;i<limit;i++)
   {
   if (Time[i]<TimeArray[y]) y++; 
   
    
     AtrBuffer1[i]=iATR(NULL,TimeFrame,AtrPeriod1,y) ; 
     AtrBuffer2[i]=iATR(NULL,TimeFrame,AtrPeriod2,y);
   }
   
   return(0);
  }
//+---



Sample





Analysis



Market Information Used:

Series array that contains open time of each bar


Indicator Curves created:



Indicators Used:

Indicator of the average true range


Custom Indicators Used:

Order Management characteristics:

Other Features: