BBwithFractdev

Author: ��� ����� �. aka KimIV
BBwithFractdev
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
BBwithFractdev
//+------------------------------------------------------------------+
//|                                               BBwithFractdev.mq4 |
//|                                           Êèì Èãîðü Â. aka KimIV |
//|                                              http://www.kimiv.ru |
//|                                                                  |
//| Ïîëîñû Áîëëèíäæåðà ñ äðîáíûì êîýôôèöèåíòîì îòêëîíåíèÿ            |
//+------------------------------------------------------------------+
#property copyright "Êèì Èãîðü Â. aka KimIV"
#property link      "http://www.kimiv.ru"

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Green
#property indicator_color2 Blue
#property indicator_color3 Green

//---- input parameters
extern int    BB_Period = 13;     // Ïåðèîä ñðåäíåé è îòêëîíåíèÿ
extern double Deviation = 2.618;  // Êîýôôèöèåíò îòêëîíåíèÿ

//---- indicator buffers
double buf1[];
double buf2[];
double buf3[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void init() {
  SetIndexStyle(0, DRAW_LINE);
  SetIndexStyle(1, DRAW_LINE);
  SetIndexStyle(2, DRAW_LINE);
  IndicatorDigits(MarketInfo(Symbol(), MODE_DIGITS));

  SetIndexBuffer(0, buf1);
  SetIndexBuffer(1, buf2);
  SetIndexBuffer(2, buf3);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
void start() {
  int i, j;
  double ave, sko, sum;

  if (Bars<=BB_Period) return;
  for (i=Bars-BB_Period; i>=0; i--) {
    buf2[i] = iMA(NULL,0,BB_Period,0,MODE_SMA,PRICE_CLOSE,i);
    sum = 0;
    for (j=0; j<BB_Period; j++) sum+=Close[i+j];
    ave = sum / BB_Period;
    sum = 0;
    for (j=0; j<BB_Period; j++) sum+=(Close[i+j]-ave)*(Close[i+j]-ave);
    sko = MathSqrt(sum / BB_Period);
    buf1[i] = buf2[i]+(Deviation*sko);
    buf3[i] = buf2[i]-(Deviation*sko);
  }
}
//+------------------------------------------------------------------+

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