📅 财经日历 📊 实时波动 📈 大盘云图 📶 行情走势 🆚 投机情绪 🚀 今日热点

    求解释一句MACD语言

    2019-06-10 · 1590 阅读
    求解释MACD指标中,“SimpleMAOnBuffer(rates_total,prev_calculated,0,InpSignalSMA,ExtMacdBuffer,ExtSignalBuffer);”这句话是什么意思,求解?
    ==================================
    //+------------------------------------------------------------------+
    //|                                                  Custom MACD.mq4 |
    //|                   Copyright 2005-2014, MetaQuotes Software Corp. |
    //|                                              http://www.mql4.com |
    //+------------------------------------------------------------------+
    #property copyright   "2005-2014, MetaQuotes Software Corp."
    #property link        "http://www.mql4.com"
    #property description "Moving Averages Convergence/Divergence"
    #property strict
    #include <MovingAverages.mqh>
    //--- indicator settings
    #property  indicator_separate_window
    #property  indicator_buffers 2
    #property  indicator_color1  Silver
    #property  indicator_color2  Red
    #property  indicator_width1  2
    //--- indicator parameters
    input int InpFastEMA=12;   // Fast EMA Period
    input int InpSlowEMA=26;   // Slow EMA Period
    input int InpSignalSMA=9;  // Signal SMA Period
    //--- indicator buffers
    double    ExtMacdBuffer[];
    double    ExtSignalBuffer[];
    //--- right input parameters flag
    bool      ExtParameters=false;
    //+------------------------------------------------------------------+
    //| Custom indicator initialization function                         |
    //+------------------------------------------------------------------+
    int OnInit(void)
      {
       IndicatorDigits(Digits+1);
    //--- drawing settings
       SetIndexStyle(0,DRAW_HISTOGRAM);
       SetIndexStyle(1,DRAW_LINE);
       SetIndexDrawBegin(1,InpSignalSMA);
    //--- indicator buffers mapping
       SetIndexBuffer(0,ExtMacdBuffer);
       SetIndexBuffer(1,ExtSignalBuffer);
    //--- name for DataWindow and indicator subwindow label
       IndicatorShortName("MACD("+IntegerToString(InpFastEMA)+","+IntegerToString(InpSlowEMA)+","+IntegerToString(InpSignalSMA)+")");
       SetIndexLabel(0,"MACD");
       SetIndexLabel(1,"Signal");
    //--- check for input parameters
       if(InpFastEMA<=1 || InpSlowEMA<=1 || InpSignalSMA<=1 || InpFastEMA>=InpSlowEMA)
         {
          Print("Wrong input parameters");
          ExtParameters=false;
          return(INIT_FAILED);
         }
       else
          ExtParameters=true;
    //--- initialization done
       return(INIT_SUCCEEDED);
      }
    //+------------------------------------------------------------------+
    //| Moving Averages Convergence/Divergence                           |
    //+------------------------------------------------------------------+
    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 i,limit;
    //---
       if(rates_total<=InpSignalSMA || !ExtParameters)
          return(0);
    //--- last counted bar will be recounted
       limit=rates_total-prev_calculated;
       if(prev_calculated>0)
          limit++;
    //--- macd counted in the 1-st buffer
       for(i=0; i<limit; i++)
          ExtMacdBuffer=iMA(NULL,0,InpFastEMA,0,MODE_EMA,PRICE_CLOSE,i)-
                        iMA(NULL,0,InpSlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
    //--- signal line counted in the 2-nd buffer
       SimpleMAOnBuffer(rates_total,prev_calculated,0,InpSignalSMA,ExtMacdBuffer,ExtSignalBuffer);
    //--- done
       return(rates_total);
      }
    //+------------------------------------------------------------------+


    ""
    还没有人打赏,支持一下
    回复

    举报

     

    回答|共 3 个

    dsxxl5320 LV1

    发表于 2019-6-10 21:52:29 | 显示全部楼层

    计算指数移动平均线

    PhilipHall LV2

    发表于 2019-6-11 08:53:49 | 显示全部楼层

    请问“SimpleMAOnBuffer”是系统的程序吗?

    吴东 LV1

    发表于 2025-12-8 23:47:45 | 显示全部楼层

    支持下
    您需要登录后才可以回帖 登录 | 注册

    提醒: 禁止引战、谩骂、灌水内容

    微信二维码

    有问题联系客服