乾隆算法的 MACD

楼主  收藏   举报   帖子创建时间:  2019-05-05 10:42 回复:0 关注量:208
学了一下 模板  ,写了第一个指标,请老坛友请教。
  《MACD  标准》
  #property copyright "liu"
  #property link      ""
  
  #property indicator_buffers 4        //定义为4根线
  #property indicator_separate_window   //在附图显示
  #property indicator_color1 White      //定义各线颜色
  #property indicator_color2 Yellow
  #property indicator_color3 Red
  #property indicator_color4 Lime
  double Buffer1[];   //对应数组
  double Buffer2[];
  double Buffer3[];
  double Buffer4[];
  extern int Fast = 12;//3个参数
  extern int Slow = 26;
  extern int Signal = 9;
  int init() //初始化
    {
     SetIndexStyle(0,DRAW_LINE,0,1);//前2条画‘线】
     SetIndexStyle(1,DRAW_LINE,0,1);
     SetIndexStyle(2,DRAW_HISTOGRAM,0,1);//后一个 画 柱图  两种颜色
     SetIndexStyle(3,DRAW_HISTOGRAM,0,1);
     SetIndexBuffer(0,Buffer1);//预定义对应的缓冲
     SetIndexBuffer(1,Buffer2);
     SetIndexBuffer(2,Buffer3);
     SetIndexBuffer(3,Buffer4);
     IndicatorShortName("MACD("+Fast+","+Slow+","+Signal+")");//显示名称和参数
     SetIndexLabel(0,"DIFF");//对各线的描述
     SetIndexLabel(1,"EDA");
     SetIndexLabel(2,"MACD");
     SetIndexLabel(3,"MACD");
     IndicatorDigits(Digits+2);//小数位
     return(0);
    }
  int deinit()
  {
  return(0);
  }
  int start()
    {
     int limit,counted_bars=IndicatorCounted();
     if(counted_bars0) counted_bars--;
     limit=Bars-counted_bars;
     for(int i=0; i0)
        Buffer3[i]=(Buffer1[i] - Buffer2[i])*2;
        else
        Buffer4[i]=(Buffer1[i] - Buffer2[i])*2;}}
     return(0);
    }
打赏