Author: Copyright � 2006, MetaQuotes Software Corp.
HistoBands
Indicators Used
Moving average indicatorStandard Deviation indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
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);
  }
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---