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

MT4到达指定价格报警指标



该指标可以满足一些不想一直盯盘而需要价格超过趋势线的时候发出警报或者邮件提醒。如果不用趋势线可以修改源代码中ld_8 = ObjectGetValueByShift(LineStr, 0);为ld_8 =其它条件或实时价格。

价格报警指标源码如下:

//+------------------------------------------------------------------+
//|                                                     价格报警.mq4 |
//|                                     Copyright 2016, QQ:125808047 |
//+------------------------------------------------------------------+
#property copyright "峰汇在线 QQ:125808047" 
#property link"http://www.125808047.com/"
 

#property indicator_chart_window

extern int AlarmType = 1;
extern int UPvalue = 10;
extern int DOWNvalue = 10;
extern bool On = true;
extern bool 多次报警 = TRUE;
extern int Email = 1;
extern string 报警声音 = "alert.wav";
extern string LineSubStr = "AlarmLineStr";


static int AlarmTimes=0 ;


int init() {
   return (0);
}

int start() {
   string LineStr;
   double ld_8;
   
   if (On) {
     
      for (int li_16 = 0; li_16 < ObjectsTotal(); li_16++) {
         LineStr=ObjectName(li_16);
         if (StringFind(LineStr,LineSubStr,0)<0)
          {
           // Print("Can not find line:"+ );
            continue;  
            
            }
        //  Print("Find :"+LineStr);  
           
         //l_name_0=LineStr;  
         //if (ObjectType(l_name_0) == 2 || ObjectType(l_name_0) == 1) {
         if (ObjectFind(LineStr)!=-1){ 
            if (AlarmType == 1) {
              
               ld_8 = ObjectGetValueByShift(LineStr, 0);
               //if (ObjectType(l_name_0) == 1) 
                 ld_8 = ObjectGet(LineStr, OBJPROP_PRICE1);
               if (iClose(Symbol(),1 ,1) < ld_8 && iClose(Symbol(),1 ,0) >= ld_8) {
                  AlarmTimes=AlarmTimes+1;
                  //Alert(Symbol() + "到达上方价格 " + DoubleToStr(ld_8, 4) + ",现价为:" + DoubleToStr(Close[0], 4));
                  if (AlarmTimes<4) PlaySound(报警声音); if (Email == 1) SendMail(Symbol() + "MT4趋势线信号", 
"到达上方价格 " + DoubleToStr(ld_8, 4) + ",现价为:" + DoubleToStr(Close[0], 4)); } else if (iClose(Symbol(),1 ,1) > ld_8 && iClose(Symbol(),1 ,0) <= ld_8) {
                  //Alert(Symbol() + "到达下方价格 " + DoubleToStr(ld_8, 4) + ",现价为:" + DoubleToStr(Close[0], 4));
                  AlarmTimes=AlarmTimes+1;
                  if (AlarmTimes<4)
                    PlaySound(报警声音);
                  if (Email == 1) SendMail(Symbol() + "MT4趋势线信号", "到达下方价格 " + DoubleToStr(ld_8, 4) + 
",现价为:" + DoubleToStr(Close[0], 4));
               }
               
               else
                 AlarmTimes=0;
            }
            

         }
      }
   }
   return (0);
}

如您喜欢此文章请点下面分享按钮↴峰汇在线 » MT4到达指定价格报警指标
上一篇:
下一篇:
分享到:更多 ()