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

均线类指标 Hull_Moving_Average

Hull_Moving_Average指标创建另类移动平均线。

Hull_Moving_Average指标图表:Hull_Moving_Average指标

Hull_Moving_Average指标源码:

//+------------------------------------------------------------------+
//|                                          Hull_Moving_Average.mq4 |
//|            Copyright @2007 , transport_david , David W Honeywell |
//+------------------------------------------------------------------+
#property copyright "Copyright @2007 , transport_david , David W Honeywell"
#property link      "http://www.125808047.com/"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 DeepSkyBlue
input int HUll_Periods = 6, Applied_Price = 0;

double Hull[];
double Calc[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit(void)
  {
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
   SetIndexEmptyValue(0,0.0);
   SetIndexBuffer(0,Hull);
   SetIndexEmptyValue(1,0.0);
   SetIndexBuffer(1,Calc);
   SetIndexLabel(0,"Hull_Moving_Average ( "+IntegerToString(HUll_Periods)+" )");
   IndicatorShortName(" Hull_Moving_Average ( "+IntegerToString(HUll_Periods)+" )");
   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[])
  {
   if(rates_total<= HUll_Periods)
      return(0);
   int limit=rates_total-prev_calculated;
//---- main loop
   for(int i=0; i<limit; i++)
     {
      double Exp = 2;
      double firstwma = iMA(NULL,0,HUll_Periods,0,MODE_LWMA,Applied_Price,i);
      double secondwma = iMA(NULL,0,MathFloor(HUll_Periods/2),0,MODE_LWMA,Applied_Price,i);
      Calc[i] = (Exp*firstwma)-secondwma;
    }
   for(i=0; i<limit; i++)
     {
      Hull[i] = iMAOnArray(Calc,0,MathFloor(MathSqrt(HUll_Periods)),0,MODE_LWMA,i);
    }
   return(rates_total);
  }
//+------------------------------------------------------------------+
打赏
版权所有转载请注明标题及链接:峰汇在线 » 均线类指标 Hull_Moving_Average
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏