诚信为本
量力而为
当前位置:峰汇在线 > MetaTrader 4 > MT4指标 > 正文

BBflat_sw.mq4 将StdDev与均线MA完美结合在副图

BBflat_sw指标将StdDev与均线MA完美结合在副图。

图表:BBflat_sw指标

源码:

//+------------------------------------------------------------------+
//|                                                    BBflat_sw.mq4 |
//|                                                          by Raff |
//+------------------------------------------------------------------+
#property copyright "by Raff"
#property link "http://www.125808047.com"

#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Aqua
#property indicator_color2 Red
#property indicator_color3 Red
#property indicator_color4 Yellow
#property indicator_levelcolor  SlateGray
#property indicator_level1 0.0004
#property indicator_level2 -0.0004
//----
extern int period=9;
extern int shift=0;
extern int method=0;
extern int price=0;
extern double deviation=1.5;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit(void)
  {
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,ExtMapBuffer4);
   Comment("www.125808047.com");
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate (const int rates_total,
                 const int prev_calculated,
                 const datetime& time[],
                 const double& open[],
                 const double& high[],
                 const double& low[],
                 const double& close[],
                 const long& tick_volume[],
                 const long& volume[],
                 const int& spread[])
  {
   int limit, counted_bars=IndicatorCounted();
   double ima, std;
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   for(int i=0; i<limit; i++)
     {
      ima=iMA(NULL,0,period,shift,method,price,i);
      std=deviation*iStdDev(NULL,0,period,shift,method,price,i);
      ExtMapBuffer1[i]=0;
      ExtMapBuffer2[i]=std;
      ExtMapBuffer3[i]=-std;
      ExtMapBuffer4[i]=Close[i]-ima;
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+
打赏
版权所有转载请注明标题及链接:峰汇在线 » BBflat_sw.mq4 将StdDev与均线MA完美结合在副图
上一篇:
下一篇:
分享到: 更多 (0)

如您觉得此文不错请扫码打赏!

支付宝扫一扫打赏

微信扫一扫打赏