Wilder Volatility System





//+------------------------------------------------------------------+
//|                                     Wilder Volatility System.mq4 |
//|                      Copyright © 2006, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+

#property indicator_chart_window 
#property indicator_buffers 4 
#property indicator_color1 Red 
#property indicator_color2 Blue 
#property indicator_color3 Tomato
#property indicator_color4 DeepSkyBlue 


//---- input parameters //îáúÿâëåíèå ââîäèìûõ âíåøíèõ ïàðàìåòðîâ
extern int Range = 7; 
extern bool Chanel = true;//Ðèñóåì êàíàëû
extern bool Znachjk = true;// Åñëè true òî ðèñóåì çíà÷êè íàä Õàåì èëè ïîä Ëîó
                           // â ïðîòèâíîì ñëó÷àå íà ãðàíèöå êàíàëà
//---- buffers
double UpBuffer[]; 
double DnBuffer[]; 
double ChanelUp[]; 
double ChanelDn[]; 


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init() //èíèöèàëèçàöèÿ ïåðåìåííûõ
  {

//---- indicator line

   SetIndexStyle(0,DRAW_ARROW); 
   SetIndexArrow(0,251);
   SetIndexBuffer(0,UpBuffer);
   SetIndexEmptyValue(0,0.0);

   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,251);
   SetIndexBuffer(1,DnBuffer);
   SetIndexEmptyValue(1,0.0);

   SetIndexStyle(2,DRAW_LINE,0,2);
   SetIndexStyle(3,DRAW_LINE,0,2);
   SetIndexBuffer(2,ChanelUp);
   SetIndexBuffer(3,ChanelDn);
   SetIndexDrawBegin(2,0); //óñòàíîâêà íà÷àëüíîé òî÷êè ïðîðèñîâêè äëÿ 0 áóôåðà
   SetIndexDrawBegin(3,0); //óñòàíîâêà íà÷àëüíîé òî÷êè ïðîðèñîâêè äëÿ 1 áóôåðà
//----
   return(0); //âîçâðàò èç ñåêöèè èíèöèàëèçàöèè
  }
//+------------------------------------------------------------------+
//| PriceChannel                                                     |
//+------------------------------------------------------------------+
int start() //íà÷àëî ïðîãðàììû (ðàñ÷åòà)
  {
   int i; //îáúÿâëåíèå öåëî÷èñëåííîé ïåðåìåííîé i,k,sch
   double Up_Chanel, Dn_Chanel,H_Range,L_Range,H,L;
   int H_R,L_R;
   
   for(i=Bars-1;i>=0;i--)
   {
      H_R = iHighest(NULL,0,MODE_CLOSE,Range+1,i+1);
      L_R = iLowest(NULL,0,MODE_CLOSE,Range+1,i+1);       
      H_Range = Close[H_R];
      L_Range = Close[L_R];
      Up_Chanel = Close[H_R] - 2*iATR(NULL,0,Range+1,i);
      Dn_Chanel = Close[L_R] + 2*iATR(NULL,0,Range+1,i);
      H=High[i];
      L=Low[i]; 


      if(Chanel == true) // Ðèñóåì êàíàëû, åñëè íàäî :)
      {
         ChanelUp[i] = Up_Chanel; 
         ChanelDn[i] = Dn_Chanel; 
      }
   
  /*  
      if(Znachjk == true)//Ðèñóåì çíà÷åê íàä õàåì èëè ëîó òåêóùåãî áàðà
      {
         if (Close[i] > Up_Chanel) //H_Range) 
         {
             Comment("Up trend");
             UpBuffer[i] = EMPTY_VALUE;
             DnBuffer[i] = L;//Dn_Chanel;
             ChanelUp[i] = EMPTY_VALUE; 
             ChanelDn[i] = Dn_Chanel;
         }
         if (Close[i] < Dn_Chanel) //L_Range)// ???? Âîçìîæíî èìåëîñü ââèäó Close[i] < H_Range  ??????? 
         {
             Comment("Down trend");
             UpBuffer[i] = H;//Up_Chanel;
             DnBuffer[i] = EMPTY_VALUE;
             ChanelUp[i] = Up_Chanel; 
             ChanelDn[i] = EMPTY_VALUE;
         }
       }
       else//Ðèñóåì çíà÷åê íà ãðàíèöå êàíàëà
       {
         if (Close[i] > H_Range) 
         {
             Comment("Up trend");
             UpBuffer[i] = EMPTY_VALUE;
             DnBuffer[i] = Dn_Chanel;
         }
         if (Close[i] < L_Range)// ???? Âîçìîæíî èìåëîñü ââèäó Close[i] < H_Range  ??????? 
         {
             Comment("Down trend");
             UpBuffer[i] = Up_Chanel;
             DnBuffer[i] = EMPTY_VALUE;
         }
       }  
      */   
   }
   
   return(0);
  }
//+------------------------------------------------------------------+



Sample





Analysis



Market Information Used:

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


Indicator Curves created:

Implements a curve of type DRAW_ARROW

Implements a curve of type DRAW_LINE

Indicators Used:

Indicator of the average true range


Custom Indicators Used:

Order Management characteristics:

Other Features: