Percent Bollinger Bands_v1

Author: ��� ����� �. aka KimIV
Percent Bollinger Bands_v1
Indicators Used
Bollinger bands indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
Percent Bollinger Bands_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                      Percent Bollinger Bands.mq4 |
//|                                           Êèì Èãîðü Â. aka KimIV |
//|                                              http://www.kimiv.ru |
//+------------------------------------------------------------------+
#property copyright "Êèì Èãîðü Â. aka KimIV"
#property link      "http://www.kimiv.ru"

#property indicator_separate_window
//---- input parameters
extern int MA_Period=20;
extern int Deviation=2;
//---- indicator buffers
double ExtMapBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init() {
  SetIndexStyle(0, DRAW_LINE);
  IndicatorDigits(MarketInfo(Symbol(), MODE_DIGITS));
  SetIndexBuffer(0, ExtMapBuffer);
  return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() {
  int i, counted_bars = IndicatorCounted();
  double dn, up;
  if(Bars<=MA_Period) return(0);
//---- check for possible errors
  if (counted_bars<0) return(-1);
//---- last counted bar will be recounted
  if (counted_bars>0) counted_bars--;
//---- 
  i = Bars - MA_Period - 1;
  if(counted_bars>=MA_Period) i = Bars - counted_bars - 1;
  while(i>=0) {
    dn = iBands(NULL,0,MA_Period,Deviation,0,PRICE_LOW,MODE_LOWER,i);
    up = iBands(NULL,0,MA_Period,Deviation,0,PRICE_HIGH,MODE_UPPER,i);
    ExtMapBuffer[i] = (Close[i] - dn) / (up - dn);
    i--;
  }
//----
  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 ---