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

脉冲MACD指标 Cronex_Impulse_CD.mq4

Cronex_Impulse_CD指标是一种用于交易的脉冲方法扩展, 是精致的脉冲MACD指标。

图表:Cronex_Impulse_CD指标

源码:

//+------------------------------------------------------------------+
//|                                            Cronex_Impulse_CD.mq4 |
//|                                         Copyright @2007, Cronex. |
//+------------------------------------------------------------------+
#property  copyright "Copyright @2008, Cronex"
#property  link      "http://www.125808047.com/"

#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  SteelBlue
#property  indicator_color2  DarkOrange
#property  indicator_color3  DarkOrange
#property  indicator_level1  0

extern int SlowMA=34;
extern int FastMA=14;
extern int SignalMA=9;

double     MacdDivrBuffer[];
double     SignalBuffer[];
double     CDDivrBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
{
   SetIndexBuffer(0,MacdDivrBuffer);
   SetIndexBuffer(1,SignalBuffer);  
   SetIndexBuffer(2,CDDivrBuffer);   
 
   SetIndexStyle(0,DRAW_HISTOGRAM);   
   SetIndexStyle(1,DRAW_NONE); 
   SetIndexStyle(2,DRAW_HISTOGRAM);     
   
   SetIndexEmptyValue(0,0) ;
   SetIndexEmptyValue(1,0) ;
   SetIndexEmptyValue(2,0) ;   
   IndicatorDigits(Digits);

   IndicatorShortName("Cronex Impulse CD("+SlowMA+","+FastMA+","+SignalMA+")");
   SetIndexLabel(0,"Impulse MACD");
   SetIndexLabel(1,"Signal");
   SetIndexLabel(2,"Impulse CD");   
   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;
   int counted_bars=IndicatorCounted();
   double HiInd,LoInd,MasterInd;

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

   for(int i=0; i<limit; i++)
    {
     HiInd=iMA(NULL,0,SlowMA,0,MODE_SMMA,PRICE_HIGH,i);
     LoInd=iMA(NULL,0,SlowMA,0,MODE_SMMA,PRICE_LOW,i);
     MasterInd=iMA(NULL,0,FastMA,0,MODE_LWMA,PRICE_WEIGHTED,i);

     if(MasterInd>HiInd)
      MacdDivrBuffer[i]=MasterInd-HiInd;
      
     if(MasterInd<LoInd)
      MacdDivrBuffer[i]=MasterInd-LoInd;  
    }

   for(i=0; i<limit; i++)
       SignalBuffer[i]=iMAOnArray(MacdDivrBuffer,Bars,SignalMA,0,MODE_SMA,i);
       
   for(i=0; i<limit; i++)
       CDDivrBuffer[i]=MacdDivrBuffer[i]-SignalBuffer[i];       
   return(rates_total);
  }
打赏
版权所有转载请注明标题及链接:峰汇在线 » 脉冲MACD指标 Cronex_Impulse_CD.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏