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

MT4价格突破某个点位预警的指标



MT4在操盘中有时候需要关注价格突破或到达某个点位,那么下面这个指标就会很实用。有三种类型的示警:第一种用于价格上涨至设定价位的上方时(在图表上显示为绿线),第二种用于价格下跌至设定价位的下方时(在图表上显示为红线),第三种用于价格接近某一确切的价位时(显示为黄线)。所有的示警在被触发之后,都会关闭,但当设定新值之后,可以再次开启。如果您使用电子邮件示警功能,那么不要忘记在您的MetaTrader平台选项窗口设置电子邮件设置。

输入参数:
SoundWhenPriceGoesAbove (默认 = 0.0) — 如果价格上涨至此值的上方将触发示警。
SoundWhenPriceGoesBelow (默认 = 0.0) — 如果价格下跌至此值的下方将触发示警。
SoundWhenPriceIsExactly (默认 = 0.0) — 如果价格到达此值时将触发示警。
SendEmail (默认 = false) — 如果选择为true且正确的电子邮件设置已经设置在MetaTrader选项窗口,那么示警将发送到设置的电子邮箱地址。

该指标不能用作一种交易系统,它不产生任何信号。无论何时您希望收到某一新价位的通知时,您都可以使用该指标。之后,您可以利用您的时间在市场上做一些您想做的事情。如果您不想使用它们中的某些,您可以将输入参数设置为零。

MT4源码如下:

//+------------------------------------------------------------------+
 //|                                                                      突破预警.mq4    |
 //|                                                            Ideas by 125808047     |
 //+------------------------------------------------------------------+
 #property copyright "突破预警"
 #property link     "http://www.125808047.com"
#property indicator_chart_window
extern double SoundWhenPriceGoesAbove = 0;
 extern double SoundWhenPriceGoesBelow = 0;
 extern double SoundWhenPriceIsExactly = 0;
 extern bool SendEmail = false;
//+------------------------------------------------------------------+
 //| Custom indicator initialization function                         |
 //+------------------------------------------------------------------+
 int init()
 {
 if (SoundWhenPriceIsExactly > 0)
 {
 ObjectCreate("SoundWhenPriceIsExactly", OBJ_HLINE, 0, Time[0], SoundWhenPriceIsExactly);
 ObjectSet("SoundWhenPriceIsExactly", OBJPROP_STYLE, STYLE_SOLID);
 ObjectSet("SoundWhenPriceIsExactly", OBJPROP_COLOR, Yellow);
 ObjectSet("SoundWhenPriceIsExactly", OBJPROP_WIDTH, 1);
 }
 if (SoundWhenPriceGoesAbove > 0)
 {
 ObjectCreate("SoundWhenPriceGoesAbove", OBJ_HLINE, 0, Time[0], SoundWhenPriceGoesAbove);
 ObjectSet("SoundWhenPriceGoesAbove", OBJPROP_STYLE, STYLE_SOLID);
 ObjectSet("SoundWhenPriceGoesAbove", OBJPROP_COLOR, Green);
 ObjectSet("SoundWhenPriceGoesAbove", OBJPROP_WIDTH, 1);
 }
 if (SoundWhenPriceGoesBelow > 0)
 {
 ObjectCreate("SoundWhenPriceGoesBelow", OBJ_HLINE, 0, Time[0], SoundWhenPriceGoesBelow);
 ObjectSet("SoundWhenPriceGoesBelow", OBJPROP_STYLE, STYLE_SOLID);
 ObjectSet("SoundWhenPriceGoesBelow", OBJPROP_COLOR, Red);
 ObjectSet("SoundWhenPriceGoesBelow", OBJPROP_WIDTH, 1);
 }
 return(0);
 }
//+------------------------------------------------------------------+
 //| Custor indicator deinitialization function                       |
 //+------------------------------------------------------------------+
 int deinit()
 {
 ObjectDelete("SoundWhenPriceIsExactly");
 ObjectDelete("SoundWhenPriceGoesAbove");
 ObjectDelete("SoundWhenPriceGoesBelow");
 return(0);
 }
 //+------------------------------------------------------------------+
 //| Custom indicator iteration function                              |
 //+------------------------------------------------------------------+
 int start()
 {
 // added by Mn -----------------------------------------------------------
 if (ObjectGet("SoundWhenPriceGoesAbove", 1) != SoundWhenPriceGoesAbove)
 SoundWhenPriceGoesAbove = ObjectGet("SoundWhenPriceGoesAbove", 1);
 if (ObjectGet("SoundWhenPriceGoesBelow", 1) != SoundWhenPriceGoesBelow)
 SoundWhenPriceGoesBelow = ObjectGet("SoundWhenPriceGoesBelow", 1);
 if (ObjectGet("SoundWhenPriceIsExactly", 1) != SoundWhenPriceIsExactly)
 SoundWhenPriceIsExactly = ObjectGet("SoundWhenPriceIsExactly", 1);
 // added by Mn -----------------------------------------------------------
if ((Ask > SoundWhenPriceGoesAbove) && (SoundWhenPriceGoesAbove > 0))
 {
 Alert("Price above the alert level.");
 PlaySound("alert.wav");
 SendMail("Price for " + Symbol() +  " above the alert level " + Ask, "Price for " + Symbol() +  " reached " + Ask + " level, which is above your alert level of " + SoundWhenPriceGoesAbove);
 ObjectDelete("SoundWhenPriceGoesAbove");
 SoundWhenPriceGoesAbove = 0;
 }
 if ((Bid < SoundWhenPriceGoesBelow) && (SoundWhenPriceGoesBelow > 0))
 {
 Alert("Price below the alert level.");
 PlaySound("alert.wav");
 SendMail("Price for " + Symbol() +  " below the alert level " + Bid, "Price for " + Symbol() +  " reached " + Bid + " level, which is below your alert level of " + SoundWhenPriceGoesBelow);
 ObjectDelete("SoundWhenPriceGoesBelow");
 SoundWhenPriceGoesBelow = 0;
 }
 if ((Bid == SoundWhenPriceIsExactly) || (Ask == SoundWhenPriceIsExactly))
 {
 Alert("Price is exactly at the alert level.");
 PlaySound("alert.wav");
 SendMail("Price for " + Symbol() +  " exactly at the alert level " + Ask, "Price for " + Symbol() +  " reached " + Ask + "/" + Bid + " level, which is exactly your alert level of " + SoundWhenPriceIsExactly);
 ObjectDelete("SoundWhenPriceIsExactly");
 SoundWhenPriceIsExactly = 0;
 }
 }
 //+------------------------------------------------------------------+
如您喜欢此文章请点下面分享按钮↴峰汇在线 » MT4价格突破某个点位预警的指标
上一篇:
下一篇:
分享到:更多 ()

评论 抢沙发

评论前必须登录!