有您的持续关注
我们会做得更好

指标MATWO



MATWO指标根据均线的不同算法在副图绘制类似单线MACD的柱状和信号线。实际运用中可以根据需要调试PERIOD参数。

MATWO指标图表效果如下:

MATWO指标

MATWO指标源码如下:

//+------------------------------------------------------------------+
//|                                                        MATWO.mq4 |
//|                                     Copyright 2014, QQ:125808047 |
//+------------------------------------------------------------------+
#property copyright "www.125808047.com"
#property link      "http://www.125808047.com/"

extern int PERIOD = 8;

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Gray
#property indicator_color2 Red
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorShortName("MATWO");
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);

//----
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int i,counted_bars=IndicatorCounted();
//----
   i=Bars-counted_bars-1;

   while(i>=0)
     {
      double MA_Blue = iMA(NULL,0,PERIOD,0,MODE_SMA,PRICE_WEIGHTED,i);
      double MA_Red = iMA(NULL,0,PERIOD,0,MODE_EMA,PRICE_CLOSE,i);
      double MA_Blue2 = iMA(NULL,0,PERIOD*2,0,MODE_SMA,PRICE_WEIGHTED,i);
      double MA_Red2 = iMA(NULL,0,PERIOD*2,0,MODE_EMA,PRICE_CLOSE,i);

      ExtMapBuffer1[i]=((MA_Red2-MA_Blue2)+(MA_Red-MA_Blue))*1000000;
      ExtMapBuffer2[i]=(MA_Red-MA_Blue)*1000000;
      i--;
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+
如您喜欢此文章请点下面分享按钮↴峰汇在线 » 指标MATWO
上一篇:
下一篇:
分享到:更多 ()