请Bull老师赐教

楼主  收藏   举报   帖子创建时间:  2019-05-05 05:45 回复:0 关注量:419
老师:
      我是mt4的初学者,试做一些编程练习
  我准备做周期为20的指数移动平均线 (EMA)的包络线,上包络线由指数移动平均线(EMA)50个周期的最大值构成, 下包络线由指数移动平均线(EMA)50个周期的最小值构成
      我将mt4中已有的指标程序改写了如下:
  
  
  
  //---- indicator settings
  #property  indicator_separate_window
  #property  indicator_buffers 3
  #property  indicator_color1  Green
  #property  indicator_color2  Red
  #property  indicator_color3   DodgerBlue
  
  //---- indicator buffers
  double     ExtBuffer0[];
  double     ExtBuffer1[];
  double     ExtBuffer2[];
  int        ExtBuffer3[];
  int         ExtBuffer4[];
  //+------------------------------------------------------------------+
  //| Custom indicator initialization function                         |
  //+------------------------------------------------------------------+
  int init()
    {
  //---- 2 additional buffers are used for counting.
     IndicatorBuffers(5);
  //---- drawing settings
     SetIndexStyle(0,DRAW_LINE);
     SetIndexStyle(1,DRAW_LINE);
     SetIndexStyle(2,DRAW_LINE);
   
  
     IndicatorDigits(Digits+2);
     SetIndexDrawBegin(0,0);
     SetIndexDrawBegin(1,0);
     SetIndexDrawBegin(2,0);
   
     
  
  //---- 4 indicator buffers mapping
     SetIndexBuffer(0,ExtBuffer0);
     SetIndexBuffer(1,ExtBuffer1);
     SetIndexBuffer(2,ExtBuffer2);
   
  //---- name for DataWindow and indicator subwindow label
     IndicatorShortName("AaCc");
     SetIndexLabel(1,NULL);
     SetIndexLabel(2,NULL);
  //---- initialization done
     return(0);
    }
  //+------------------------------------------------------------------+
  //| Accelerator/Decelerator Oscillator                               |
  //+------------------------------------------------------------------+
  int start()
    {
     int    limit;
     int    counted_bars=IndicatorCounted();
     
     //---- last counted bar will be recounted
     
  //---- initial zero
      if(counted_bars0) counted_bars--;
     limit=Bars-counted_bars;
     //---- macd counted in the 1-st additional buffer
     for(int i=0; i
打赏