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

以HMA创建通道 Firebird_HMA_[i].mq4

Firebird_HMA_[i] 指标根据均线HMA的特定算法创建通道。用在D1和W1周期较为明显。

图表:Firebird_HMA_[i] 指标

源码:

//+------------------------------------------------------------------+
//|                                              Firebird_HMA_[i].mq4|
//|                  Copyright @2000-2007, MetaQuotes Software Corp. |
//+------------------------------------------------------------------+
#property  copyright "Copyright @2005 TraderSeven"
#property link      "http://www.125808047.com/"

#property  indicator_chart_window
#property  indicator_buffers 2
#property  indicator_color1  Blue
#property  indicator_color2  Red

extern int HMA_Period=20;
extern double Percentage=2.0;

double     ind_buffer0[];
double     ind_buffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
   SetIndexBuffer(0,ind_buffer0);
   SetIndexBuffer(1,ind_buffer1);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
   IndicatorShortName("HMA("+HMA_Period+")");
   Comment("www.125808047.com");
   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 limit,i;
   int counted_bars=IndicatorCounted();

   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;

   for(i=1; i<limit+1; i++)
     {
      ind_buffer0[i]=(1+Percentage/100)*iMA(NULL,0,MathFloor(HMA_Period/2),0,MODE_LWMA,PRICE_HIGH,i)*2-
      iMA(NULL,0,HMA_Period,0,MODE_LWMA,PRICE_HIGH,i);
      ind_buffer1[i]=(1-Percentage/100)*iMA(NULL,0,MathFloor(HMA_Period/2),0,MODE_LWMA,PRICE_HIGH,i)*2-
      iMA(NULL,0,HMA_Period,0,MODE_LWMA,PRICE_HIGH,i);
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+
打赏
版权所有转载请注明标题及链接:峰汇在线 » 以HMA创建通道 Firebird_HMA_[i].mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏