请教均线交叉报警问题

楼主  收藏   举报   帖子创建时间:  2019-05-05 15:10 回复:0 关注量:58
下了个均线交叉带箭头声音报警的指标,可以调均线类型的,本应是不错的东西,但这个声音报警经常响,没交叉都会响,麻烦哪位高手可以改一下本来是提醒作用,现在不停的响,像背景音乐一样,都不知道是谁在响了。
  //+------------------------------------------------------------------+
  //|                                         EMA-Crossover_Signal.mq4 |
  //|         Copyright ?2005, Jason Robinson (jnrtrading)            |
  //|                   http://www.jnrtading.co.uk                     |
  //+------------------------------------------------------------------+
  
     
  #property copyright "Copyright ?2005, Jason Robinson (jnrtrading)"
  #property link      "http://www.jnrtrading.co.uk"
  
  #property indicator_chart_window
  #property indicator_buffers 2
  #property indicator_color1 LawnGreen
  #property indicator_color2 Red
  
  double CrossUp[];
  double CrossDown[];
  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 =    6;
  extern bool Voicealert = true;
  //+------------------------------------------------------------------+
  //| Custom indicator initialization function                         |
  //+------------------------------------------------------------------+
  int init()
    {
  //---- indicators
     SetIndexStyle(0, DRAW_ARROW, EMPTY);
     SetIndexArrow(0, 233);
     SetIndexBuffer(0, CrossUp);
     SetIndexStyle(1, DRAW_ARROW, EMPTY);
     SetIndexArrow(1, 234);
     SetIndexBuffer(1, CrossDown);
  //----
     return(0);
    }
  //+------------------------------------------------------------------+
  //| Custom indicator deinitialization function                       |
  //+------------------------------------------------------------------+
  int deinit()
    {
  //----
  
  //----
     return(0);
    }
  //+------------------------------------------------------------------+
  //| Custom indicator iteration function                              |
  //+------------------------------------------------------------------+
  int start() {
     int limit, i, counter;
     double fasterMAnow, slowerMAnow, fasterMAprevious, slowerMAprevious, fasterMAafter, slowerMAafter;
     double Range, AvgRange;
     int counted_bars=IndicatorCounted();
  //---- check for possible errors
     if(counted_bars0) counted_bars--;
  
     limit=Bars-counted_bars;
     
     for(i = 0; i  slowerMAafter))
        {
        
           CrossUp = Low - Range*0.5;
           if (Voicealert==true){
              alert("Moving Average has crossed up");
           }
        }
        else if ((fasterMAnow < slowerMAnow) && (fasterMAprevious > slowerMAprevious) && (fasterMAafter < slowerMAafter)) {
           CrossDown = High + Range*0.5;
           if (Voicealert==true){
              alert("Moving Average has crossed down");
           }
        }
     }
     return(0);
  }
打赏