HistoBands





//+------------------------------------------------------------------+
//|                                                   HistoBands.mq4 |
//|                      Copyright © 2006, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 DodgerBlue
#property indicator_color2 Red

double WBP[];
extern int ShortPeriod=5;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(3);
   SetIndexStyle(0,DRAW_HISTOGRAM,0,2);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_HISTOGRAM,0,2);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexBuffer(2, WBP);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    i,k,counted_bars=IndicatorCounted();
   double HH,LL,WBPma,Stdev,Bands;

   if(Bars<=32) return(0);
   
//---- last counted bar will be recounted
   int limit=Bars-counted_bars;
   if(counted_bars>0) limit++; 

   for(i=0; i<limit-1; i++)
   {
      HH=High[Highest(NULL,0,MODE_HIGH,ShortPeriod,i)];
      LL=Low[Lowest(NULL,0,MODE_LOW,ShortPeriod,i)];
      WBP[i]=(HH+LL+Close[i])/3;
   }
   
   for(i=0; i<limit; i++)
   {
      WBPma=iMAOnArray(WBP,Bars,34,0,MODE_SMA,i);
      Stdev=iStdDevOnArray(WBP,Bars,34,MODE_SMA,0,i);
      Bands=((WBP[i]+2*Stdev-WBPma)/(4*Stdev))*4-2;
      ExtMapBuffer1[i]=0;
      ExtMapBuffer2[i]=0;
      if (Bands>0){ExtMapBuffer1[i]=Bands;}
      if (Bands<0){ExtMapBuffer2[i]=Bands;}
   }
   
   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
Standard Deviation indicator


Custom Indicators Used:

Order Management characteristics:

Other Features: