有您的持续关注
我们会做得更好

指标 BBwithFractdev



BBwithFractdev 指标在主图绘制类似布林带的通道。

BBwithFractdev 指标图表效果如下:BBwithFractdev 指标BBwithFractdev 指标源码如下:

//+------------------------------------------------------------------+
//|                                               BBwithFractdev.mq4 |
//|                                              http://www.kimiv.ru |
//+------------------------------------------------------------------+
#property copyright ""
#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);
}

void deinit() {
   Comment("www.125808047.com");
}

//+------------------------------------------------------------------+
//| 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);
  }
}
//+------------------------------------------------------------------+

如您喜欢此文章请点下面分享按钮↴峰汇在线 » 指标 BBwithFractdev
上一篇:
下一篇:
分享到:更多 ()