Author: Copyright � 2011, Victor Niclolaev aka Vinin
Indicators Used
Moving average indicatorStandard Deviation indicator
Miscellaneous
Implements a curve of type %1
1 Views
0 Downloads
0 Favorites
VininI_BB
//+------------------------------------------------------------------+
//|                                                    VininI_BB.mq4 |
//|                     Copyright © 2011, Victor Niclolaev aka Vinin |
//|                                                    vinin@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, Victor Niclolaev aka Vinin"
#property link      "vinin@mail.ru"

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Yellow
#property indicator_color2 Yellow
#property indicator_color3 Red
//--- input parameters
extern int       period=30;
extern double    kStDev=1.0;
extern int Shift=0;
//--- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexShift(0, Shift);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexShift(1, Shift);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexShift(2, Shift);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   IndicatorDigits(Digits);
   int    counted_bars=IndicatorCounted();
   int pos, limit=Bars-counted_bars;
   if (limit>1) {
      pos=Bars-period-1;
      double price=iMA(NULL, 0, period, 0, MODE_SMA,PRICE_CLOSE,pos);
      double delta=iStdDev(NULL,0,period, 0, MODE_SMA, PRICE_CLOSE, pos)*kStDev;
      ExtMapBuffer1[pos]=price+delta;
      ExtMapBuffer2[pos]=price-delta;
      if (High[pos]>ExtMapBuffer1[pos]) {
         ExtMapBuffer1[pos]=High[pos];
         ExtMapBuffer2[pos]=High[pos]-2.0*delta;
      }
      if (Low[pos]<ExtMapBuffer2[pos]) {
         ExtMapBuffer2[pos]=Low[pos];
         ExtMapBuffer1[pos]=Low[pos]+2.0*delta;
      }
      ExtMapBuffer3[pos]=(ExtMapBuffer1[pos]+ExtMapBuffer2[pos])*0.5;
      limit=pos-1;
   }
   for (pos=limit;pos>=0;pos--) {
      price=ExtMapBuffer3[pos+1];
      delta=iStdDev(NULL,0,period, 0, MODE_SMA, PRICE_CLOSE, pos)*kStDev;
      ExtMapBuffer1[pos]=ExtMapBuffer1[pos+1];
      ExtMapBuffer2[pos]=ExtMapBuffer2[pos+1];
      if (High[pos]>ExtMapBuffer1[pos]) {
         ExtMapBuffer1[pos]=High[pos];
         ExtMapBuffer2[pos]=High[pos]-2.0*delta;
         if (ExtMapBuffer2[pos]<ExtMapBuffer2[pos+1]) ExtMapBuffer2[pos]=ExtMapBuffer2[pos+1];
      }
      if (Low[pos]<ExtMapBuffer2[pos]) {
         ExtMapBuffer2[pos]=Low[pos];
         ExtMapBuffer1[pos]=Low[pos]+2.0*delta;
         if (ExtMapBuffer1[pos]>ExtMapBuffer1[pos+1]) ExtMapBuffer1[pos]=ExtMapBuffer1[pos+1];
      }
      ExtMapBuffer3[pos]=(ExtMapBuffer1[pos]+ExtMapBuffer2[pos])*0.5;
   }



   

   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 ---