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

在附图中显示均线的MT4指标MA_Gideon



MA_Gideon指标将均线组在附图中呈现出来,并加入了3EMA的开盘价格作为价格波动的指数,风格独特。调用图表效果如下:

MT4自定义指标MQL4源码如下:

//+------------------------------------------------------------------+
//|                                                    MA_Gideon.mq4 |
//|                                               Ideas by 125808047 |
//+------------------------------------------------------------------+
#property copyright "www.125808047.com"
#property link     "http://www.125808047.com"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 4
#property  indicator_color1  Lime
#property  indicator_color2  Red
#property  indicator_color3  Yellow
#property  indicator_color4  DodgerBlue
//----
extern double slowPeriod=103;
extern double MainPeriod=78;
extern double TrendOverPeriod=24;
//---- indicator buffers
string signal;
double fastTrigger[];
double slowTrigger[];
double MainLine[];
double TrendOver[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 2 additional buffers are used for counting.
   //   IndicatorBuffers(4);
   SetIndexDrawBegin(0,30);
   SetIndexDrawBegin(1,30);
   SetIndexDrawBegin(2,30);
   SetIndexDrawBegin(3,30);
//----
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
   SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,1);
   SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,1);
//----
   SetIndexBuffer(0,fastTrigger);
   SetIndexLabel(0,"fastTrigger");
   SetIndexBuffer(1,slowTrigger);
   SetIndexLabel(1,"slowTrigger");
   SetIndexBuffer(2,MainLine);
   SetIndexLabel(2,"Main Line");
   SetIndexBuffer(3,TrendOver);
   SetIndexLabel(3,"TrendOver");
   //   ArraySetAsSeries(fastTrigger, true);
//---- name for DataWindow and indicator subwindow label
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Calculations                                                     |
//+------------------------------------------------------------------+
int start()
  {
   //   int limit=ArraySize(fastTrigger);
   int limit;
   int i;
   int counted_bars=300;
   //   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- main loop
//---- done
   for(i=0; i<=limit; i++)
     {
      fastTrigger[i]=  iMA(Symbol(),0,3,0,MODE_EMA,PRICE_OPEN,i);
     }
   for(i=0; i<=limit; i++)
     {
      slowTrigger[i]=iMAOnArray(fastTrigger,0,slowPeriod,0,MODE_SMMA,i);
      MainLine[i]= iMAOnArray(fastTrigger,0,MainPeriod,0,MODE_SMMA,i);
      TrendOver[i]= iMAOnArray(fastTrigger,0,TrendOverPeriod,0,MODE_SMA,i);
     }
   //   This way also works, just slower
   //   for(i=0; i <= limit; i++) 
   //   {   
   //   MainLine[i]= iMAOnArray(fastTrigger,0,MainPeriod,0,MODE_SMMA,i);
   //   }
   //   for(i=0; i <= limit; i++) 
   //   {
   //   TrendOver[i]= iMAOnArray(fastTrigger,0,TrendOverPeriod,0,MODE_LWMA,i);
   //   }
  return(0);
  }
//+------------------------------------------------------------------+

如您喜欢此文章请点下面分享按钮↴峰汇在线 » 在附图中显示均线的MT4指标MA_Gideon
上一篇:
下一篇:
分享到:更多 ()