发新话题
打印

[MT指标及EA] 版主及各位高手大哥

版主及各位高手大哥

版主及各位高手大哥,我想要一个均线交叉报警的mt指标,在坛子里找到一个,这个指标唯一不足的是报警功能。它的报警功能太弱,报警声音只响一下,然后就没声音了。我想要的是能长久报警的指标,就是手动接触报警声音。谢谢高手赐教
附上那个指标的源码:
//+------------------------------------------------------------------+
//|                                         EMA-Crossover_Signal.mq4 |
//|                                                             xfxy |
//|                                             http://www.onefx.net |
//+------------------------------------------------------------------+

  
#property copyright "xfxy"
#property link      "http://www.onefx.net"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 DodgerBlue
#property indicator_color2 Red
#property indicator_color3 Red
#property indicator_color4 Yellow

double CrossUp[];
double CrossDown[];
double MAF[];
double MAS[];

extern bool Alert_X=true;
extern int FasterMode = 1; //0=sma, 1=ema, 2=smma, 3=lwma
extern int FasterMA =   5;
extern int SlowerMode = 1; //0=sma, 1=ema, 2=smma, 3=lwma
extern int SlowerMA =   10;
static double UP_Alert,DO_Alert;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0, DRAW_ARROW, 2);
   SetIndexArrow(0, 233);
   SetIndexBuffer(0, CrossUp);
   SetIndexStyle(1, DRAW_ARROW, 2);
   SetIndexArrow(1, 234);
   SetIndexBuffer(1, CrossDown);
   SetIndexBuffer(2, MAF);
   SetIndexBuffer(3, MAS);
   SetIndexStyle(2, DRAW_LINE);
   SetIndexStyle(3, DRAW_LINE);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   ObjectDelete("onefx_label0");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   int limit, i, counter;
   double fasterMAnow, slowerMAnow, fasterMAprevious, slowerMAprevious, fasterMAafter, slowerMAafter;
   double Range;
   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;
   
   for(i = 0; i <= limit; i++)
   {
      MAF = iMA(NULL, 0, FasterMA, 0, FasterMode, PRICE_CLOSE, i);
      MAS = iMA(NULL, 0, SlowerMA, 0, SlowerMode, PRICE_CLOSE, i);
   }
   for(i = 0; i <= limit; i++)
   {
      Range=iATR(NULL,0,10,i+1);
      if (MAF > MAS && MAF[i+1] > MAS[i+1] && MAF[i+2] < MAS[i+2])
      {
         CrossUp = Open;//Low - Range*0.5;
      }
      if (MAF < MAS && MAF[i+1] < MAS[i+1] && MAF[i+2] > MAS[i+2])
      {
         CrossDown = Open;//High + Range*0.5;
      }
   }
   if (Alert_X==false)
   {
     DO_Alert=Time[0];
     UP_Alert=Time[0];
   }
   if (UP_Alert!=Time[0] && MAF[0] > MAS[0] && MAF[1] > MAS[1] && MAF[2] < MAS[2])
   {
     Alert(Symbol()+"  "+Period()+"  MA-Crossover_Signal "+FasterMA+" 金叉 "+SlowerMA);
     UP_Alert=Time[0];
   }
   if (DO_Alert!=Time[0] && MAF[0] < MAS[0] && MAF[1] < MAS[1] && MAF[2] > MAS[2])
   {
     Alert(Symbol()+"  "+Period()+"  MA-Crossover_Signal "+FasterMA+" 死叉"+SlowerMA);
     DO_Alert=Time[0];
   }
   return(0);
}
//+------------------------------------------------------------------+

TOP

那就用这个现成的啦
会修改就自己来

附件: 您所在的用户组无法下载或查看附件
胜败乃是兵家常事
输赢化作家常便饭

TOP

if (UP_Alert!=Time[0] && MAF[0] > MAS[0] && MAF[1] > MAS[1] && MAF[2] < MAS[2])
   {
     Alert(Symbol()+"  "+Period()+"  MA-Crossover_Signal "+FasterMA+" 金叉 "+SlowerMA);
     UP_Alert=Time[0];
   }
   if (DO_Alert!=Time[0] && MAF[0] < MAS[0] && MAF[1] < MAS[1] && MAF[2] > MAS[2])
   {
     Alert(Symbol()+"  "+Period()+"  MA-Crossover_Signal "+FasterMA+" 死叉"+SlowerMA);
     DO_Alert=Time[0];
   }
删除这段代码中的
UP_Alert=Time[0];
DO_Alert=Time[0];
即可

TOP

多谢两位哥哥!
欧系能多不能空

TOP

发新话题