JS-BollingerBands

Author: js_sergey@list.ru
Indicators Used
Moving average indicatorStandard Deviation indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
JS-BollingerBands
//+------------------------------------------------------------------+
//|                                           JS-BollingerBands.mq4  |
//|                                       js_sergey@list.ru  © 2009, |
//|                                           Ïèøó òîðãîâûå ñèñòåìû  |
//+------------------------------------------------------------------+

#property copyright " js_sergey@list.ru "
#property link      " http://multiexperts.ru/ "

#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color1 LimeGreen
#property indicator_color2 RoyalBlue
#property indicator_color3 RoyalBlue
#property indicator_color4 Crimson
#property indicator_color5 Crimson


//---- input parameters

extern string  n2                 =  " Bollinger2 Íàñòðîéêè ";
extern int     BandsPeriod        =  20;
extern int     BandsShift         =  0;
extern double  BandsDeviations_1  =  2.0;
extern double  BandsDeviations_2  =  1.0;
extern int     BandsMetod         =  0;//1,2,3
extern int     BandsPrice         =  4;//1,2,3,4


double Buffer_0[];
double Buffer_1[];
double Buffer_2[];
double Buffer_3[];
double Buffer_4[];


//----
//+------------------------------------------------------------------+
int init()
  {

//---- 3 indicator buffers mapping
   SetIndexBuffer(0,Buffer_0);
   SetIndexBuffer(1,Buffer_1);
   SetIndexBuffer(2,Buffer_2);
   SetIndexBuffer(3,Buffer_3);
   SetIndexBuffer(4,Buffer_4);
  
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexStyle(4,DRAW_LINE);  


   
   return(0);
  }
//+------------------------------------------------------------------+
int start()
  {
   double stddev_1, ma_1;
   int limit;
   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- main loop
   for(int i=0; i<limit; i++)
     {
    
      ma_1 = iMA(Symbol(), 0, BandsPeriod, BandsShift, BandsMetod, BandsPrice, i);
      Buffer_0[i] = iMA(Symbol(), 0, BandsPeriod, BandsShift, BandsMetod, BandsPrice, i);
      stddev_1 = iStdDev(Symbol(), 0, BandsPeriod, BandsShift, BandsMetod, BandsPrice, i);   
      Buffer_1[i] = ma_1+(BandsDeviations_1*stddev_1);
      Buffer_2[i] = ma_1-(BandsDeviations_1*stddev_1);   
      Buffer_3[i] = ma_1+(BandsDeviations_2*stddev_1);
      Buffer_4[i] = ma_1-(BandsDeviations_2*stddev_1);
            
     }


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