Navigation:Home > Content >

atr_lv.mq4

Time: 2015-06-14 | Download file:atr_lv.mq4

//+------------------------------------------------------------------+
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
//2009fxtsd atr lvls

#property copyright ""
#property link      ""

#property indicator_separate_window
#property indicator_buffers    5
#property indicator_color1     DodgerBlue
#property indicator_color2     FireBrick
#property indicator_color3     Green
#property indicator_color4     DarkGreen
#property indicator_color5     Green

#property indicator_width1     1
#property indicator_style3     4
#property indicator_style4     2
#property indicator_style5     2



extern int atr_per1      = 2;
extern int atr_per2      = 5;


extern int ave_per     = 44;

extern int ave_lv1    = 50;
extern int ave_lv2    = 162;




double buffer1[];
double buffer2[];
double buffer3[];
double buffer4[];
double buffer5[];

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

int init()
{

   
   SetIndexBuffer(0,buffer1);SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(1,buffer2);
   SetIndexBuffer(2,buffer3);
   SetIndexBuffer(3,buffer4);
   SetIndexBuffer(4,buffer5);

   IndicatorShortName("atr lvl  "+atr_per1+","+atr_per2+";"+ave_per+": ");  
//   SetIndexLabel(0,"Sto");



   return(0);
}
int deinit()
{
   return(0);
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+



int start()
{
   int counted_bars=IndicatorCounted();
   int limit,i;
   
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
           limit=Bars-counted_bars;


   for(i=limit; i>=0; i--)
   {
     buffer1[i]  = iATR(NULL, 0, atr_per1, i); 
     buffer2[i]  = iATR(NULL, 0, atr_per2, i); 

     buffer3[i]  = iATR(NULL, 0, ave_per, i); 
 
     buffer4[i]  = buffer3[i] *ave_lv1/100; 
     buffer5[i]  = buffer3[i] *ave_lv2/100; 

 
   
   }
   
   return(0);
}

Recommend