延缓警报几秒钟 - 页 2 12345 新评论 [删除] 2016.03.02 22:45 #11 计时器上(OnTimer)。 Massimo 2016.03.03 15:31 #12 谢谢 eevviill, 但 我的技能 太复杂 了。 我 开始 接触编程, 他们是 自学的 , 我 很难 理解 一些东西。 谢谢你做的一切, Massimo。 [删除] 2016.03.03 16:08 #13 omissamf:谢谢 eevviill, 但 我的技能 太复杂 了。 我 开始 接触编程, 他们是 自学的 , 我 很难 理解 一些东西。 谢谢你做的一切, Massimo。int seconds=3; int OnInit() { EventSetTimer(seconds); IndicatorBuffers(2); SetIndexBuffer(0, Buffer1); SetIndexEmptyValue(0, 0); SetIndexArrow(0, 241); SetIndexBuffer(1, Buffer2); SetIndexEmptyValue(1, 0); SetIndexArrow(1, 242); //initialize myPoint myPoint = Point(); if(Digits() == 5 || Digits() == 3) { myPoint *= 10; } return(INIT_SUCCEEDED); } //_____________________________________________ //_____________________________________________ int start() { return(0); } void OnTimer(){ //Indicator Buffer 1 if(iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 0) < 30 ) { Buffer1[0] = Low[0] - iATR(NULL, PERIOD_CURRENT, 14, 0); //Set indicator value at Candlestick Low - Average True Range if(0 == 0 && Time[0] != time_alert) { myAlert("indicator", "Buy"); time_alert = Time[0]; } //Instant alert, only once per bar } else { Buffer1[0] = 0; } //Indicator Buffer 2 if(iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 0) > 70 ) { Buffer2[0] = High[0] + iATR(NULL, PERIOD_CURRENT, 14, 0); //Set indicator value at Candlestick High + Average True Range if(0 == 0 && Time[0] != time_alert) { myAlert("indicator", "Sell"); time_alert = Time[0]; } //Instant alert, only once per bar } else { Buffer2[0] = 0; } } } Massimo 2016.03.03 19:24 #14 谢谢 eevviill,你的 代码工作, 但我不是 从 信号后 三秒 ,打开 蜡烛, 但如果, 例如, RSI 是 70 级以上 的30秒后,蜡烛 是开放的, 代码 让 3/2 尚未 ,然后 提出 了箭头。 目前,最接近的 代码 是 谁建议我 GumRai , 但 给我的 信号和 设置的 蜡烛 的开放 ,而不是 在3 秒 后。 谢谢你做的一切, Massimo。int start(){ if (BarStart !=Time[0]) { BarStart = Time[0]; //This is the code suggested by GumRai. This works well, but the arrow appears and fixed the opening of the candle, instead of 3 seconds after its opening. [删除] 2016.03.03 19:48 #15 但我不是从三秒后 的信号,打开了蜡烛最好先写出来,而不是 "我需要每3秒的警报"。 [删除] 2016.03.03 19:59 #16 extern int seconds=3; int time_dif; bool current_candle_alert_been; int prev_bars; int OnInit() { prev_bars=Bars; EventSetTimer(1); time_dif=int(TimeLocal()-TimeCurrent()); ... void OnTimer() { if(Bars!=prev_bars) current_candle_alert_been=false; prev_bars=Bars; if(current_candle_alert_been) return; if(TimeLocal()-time_dif<Time[0]+seconds) return; current_candle_alert_been=true; ... Keith Watford 2016.03.03 20:50 #17 static datetime BarStart=0; static bool check=false; if(BarStart!=Time[0]) { BarStart=Time[0]; check=true; } if(check && TimeCurrent()>=Time[0]+3) { check=false; //Check Condition }这应该在第一个收到的tick点上进行检查,该tick点至少在条形图打开时间 后3秒。请注意,如果指标初始化时,条形图已经打开了n秒,并且n>3,它将在那个时候被检查。另外,很明显,它对历史条形图不起作用。 [删除] 2016.03.04 06:59 #18 GumRai:这应该是在收到的第一个刻度线时进行检查,该刻度线至少在条形图打开时间后3秒。注意,如果在指标初始化时,条形图已经打开了n秒,并且n>3,那么它将在那个时候被检查。另外,很明显,它对历史条形图不起作用。:))))1)我想修改这段代码,使警报不是在蜡烛开盘时出现,而是在几秒钟后检测条件。2)但是我没有在开盘三秒后收到信号。P.S. 不要使用Time[0],使用Bars Keith Watford 2016.03.04 07:59 #19 eevviill::))))1)我想修改这段代码,使警报不是在蜡烛开盘时出现,而是在几秒钟后检测条件。2)但我没有从三秒后打开蜡烛 的信号。你的观点是什么?eevviill。:))))P.S. 不要使用Time[0],使用Bars为什么不呢?使用Time[0]来检测一个新的条形图并没有错。 Massimo 2016.03.04 08:27 #20 嗨,伙计们, 你们真 了不起 !!! 我不知道该如何感谢你们的合作。 我不知道 该如何感谢你们 的合作。 eevviill 发布的 代码 工作得很好,这就是 我的意思。 而 GumRai 的 代码 在 RSI 越过 30/70 水平 时 就会 重绘 并 给出 信号。 我 根据 eevviill 的建议 插入了 工作代码, 希望它能 发挥 更大的 作用。 谢谢你做的一切, 马西莫。//+------------------------------------------------------------------+ //| Test Delay.mq4 | //| Massimo | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Massimo" #property link "https://www.mql5.com" #property version "1.00" #property description "" #include <stdlib.mqh> #include <stderror.mqh> //--- indicator settings #property indicator_chart_window #property indicator_buffers 2 #property indicator_type1 DRAW_ARROW #property indicator_width1 1 #property indicator_color1 0xFFAA00 #property indicator_label1 "Buy" #property indicator_type2 DRAW_ARROW #property indicator_width2 1 #property indicator_color2 0x0000FF #property indicator_label2 "Sell" extern int seconds =3; int time_dif; bool current_candle_alert_been; int prev_bars; datetime time_alert; //used when sending alert //--- indicator buffers double Buffer1[]; double Buffer2[]; extern int Period1 = 2; double myPoint; //initialized in OnInit void myAlert(string type, string message) { if(type == "print") Print(message); else if(type == "error") { Print(type+" | Test @ "+Symbol()+","+Period()+" | "+message); } else if(type == "order") { } else if(type == "modify") { } } //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { prev_bars=Bars; EventSetTimer(1); time_dif=int(TimeLocal()-TimeCurrent()); IndicatorBuffers(2); SetIndexBuffer(0, Buffer1); SetIndexEmptyValue(0, 0); SetIndexArrow(0, 241); SetIndexBuffer(1, Buffer2); SetIndexEmptyValue(1, 0); SetIndexArrow(1, 242); //initialize myPoint myPoint = Point(); if(Digits() == 5 || Digits() == 3) { myPoint *= 10; } return(INIT_SUCCEEDED); } //________________________________ int start() { return(0); } //_________________________________ void OnTimer(){ { if(Bars!=prev_bars) current_candle_alert_been=false; prev_bars=Bars; if(current_candle_alert_been) return; if(TimeLocal()-time_dif<Time[0]+seconds) return; current_candle_alert_been=true; //Indicator Buffer 1 if(iRSI(NULL, PERIOD_CURRENT, Period1, PRICE_CLOSE, 0) < 30 ) { Buffer1[0] = Low[0] - iATR(NULL, PERIOD_CURRENT, 14, 0); //Set indicator value at Candlestick Low - Average True Range if(0 == 0 && Time[0] != time_alert) { myAlert("indicator", "Buy"); time_alert = Time[0]; } //Instant alert, only once per bar } else { Buffer1[0] = 0; } //Indicator Buffer 2 if(iRSI(NULL, PERIOD_CURRENT, Period1, PRICE_CLOSE, 0) > 70 ) { Buffer2[0] = High[0] + iATR(NULL, PERIOD_CURRENT, 14, 0); //Set indicator value at Candlestick High + Average True Range if(0 == 0 && Time[0] != time_alert) { myAlert("indicator", "Sell"); time_alert = Time[0]; } //Instant alert, only once per bar } else { Buffer2[0] = 0; } } } //----------------------------------------------------------------------------------------------------------------------------- 12345 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
谢谢你做的一切, Massimo。
谢谢 eevviill, 但 我的技能 太复杂 了。 我 开始 接触编程, 他们是 自学的 , 我 很难 理解 一些东西。
谢谢你做的一切, Massimo。
目前,最接近的 代码 是 谁建议我 GumRai , 但 给我的 信号和 设置的 蜡烛 的开放 ,而不是 在3 秒 后。
谢谢你做的一切, Massimo。
但我不是从三秒后 的信号,打开了蜡烛
最好先写出来,而不是 "我需要每3秒的警报"。
这应该在第一个收到的tick点上进行检查,该tick点至少在条形图打开时间 后3秒。
请注意,如果指标初始化时,条形图已经打开了n秒,并且n>3,它将在那个时候被检查。另外,很明显,它对历史条形图不起作用。
这应该是在收到的第一个刻度线时进行检查,该刻度线至少在条形图打开时间后3秒。
注意,如果在指标初始化时,条形图已经打开了n秒,并且n>3,那么它将在那个时候被检查。另外,很明显,它对历史条形图不起作用。
:))))
1)我想修改这段代码,使警报不是在蜡烛开盘时出现,而是在几秒钟后检测条件。
2)但是我没有在开盘三秒后收到信号。
P.S. 不要使用Time[0],使用Bars
:))))
1)我想修改这段代码,使警报不是在蜡烛开盘时出现,而是在几秒钟后检测条件。
2)但我没有从三秒后打开蜡烛 的信号。
你的观点是什么?
:))))
P.S. 不要使用Time[0],使用Bars
为什么不呢?使用Time[0]来检测一个新的条形图并没有错。
我不知道 该如何感谢你们 的合作。
eevviill 发布的 代码 工作得很好,这就是 我的意思。
而 GumRai 的 代码 在 RSI 越过 30/70 水平 时 就会 重绘 并 给出 信号。
我 根据 eevviill 的建议 插入了 工作代码, 希望它能 发挥 更大的 作用。
谢谢你做的一切, 马西莫。