你好,WHRoeder,谢谢你的回答。我为我的行为道歉,但我的目的不是要冒犯和不尊重任何人。我整天都在试图改变代码来实现这一点,但我没有成功。他们是研究MQL4的开始。我要求再次向管理员道歉。问候,Massimo
你好,WHRoeder,我试过了,但没有 用!!!我尝试了所有的方法,但不明白我错在哪里!!!。
总之,感谢你所做的一切,Massimo。
我在你的代码中没有看到一个警报
你好GunRai , 我把 完整的代码 发给你, 所以 我解释一下。 我不能 延迟 确认 蜡烛 打开 的条件 (因为它 现在正在做), 但在3 秒 后 ,甚至 WHRoeder 的 建议。 我不 明白 我 在哪里 错了!!!!!!。
谢谢 你, 马克斯。
//+------------------------------------------------------------------+ //| RSI 70-30.mq4 | //| Massimo | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Massimo" #property link "https://www.mql5.com" #property version "1.00" #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" static datetime BarStart=0; //--- indicator buffers double Buffer1[]; double Buffer2[]; datetime time_alert; //used when sending alert extern bool Audible_Alerts = true; double myPoint; //initialized in OnInit void myAlert(string type, string message) { if(type == "print") Print(message); else if(type == "error") { Print(type+" | RSI 30-70 @ "+Symbol()+","+Period()+" | "+message); } else if(type == "order") { } else if(type == "modify") { } else if(type == "indicator") { if(Audible_Alerts) Alert(type+" | RSI 30-70 @ "+Symbol()+","+Period()+" | "+message); } } //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { 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(){ if (BarStart !=Time[0]) { BarStart = Time[0]; Sleep(3000); RefreshRates(); //this code don't work // //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; } } return(0); } //+------------------------------------------------------------------+
你是正确的,你正在运行一个指标。 | int start(){ if (BarStart !=Time[0]) { BarStart = Time[0]; Sleep(3000); RefreshRates(); //this code don't work |
试试这个 | #define MAX_DATETIME D'3000.12.31 23:59:59' // 32,535,215,999 #define MIN_DATETIME D'1970.01.01 00:00:00' // Zero. int start(){ static datetime alertTime = MAX_DATETIME; if(TimeCurrent() > alertTime){ alertTime = MAX_DATETIME; Alert(...); } if (BarStart !=Time[0]) { BarStart = Time[0]; : if(condition) alertTime = TimeCurrent() + 3; // Delay |
WHRoeder:
谢谢, 现在 我研究一下 你发给 我的 代码 ,然后 让你知道。你是正确的,你正在运行一个指标。 | |
试试这个 |
现在, 无限的感谢, Massimo。
WHRoeder:
WHRoeder 你好, 我试着 用 你的指示 来改变代码。 我尝试了 各种 方法 , 这是你 发送的 是你 没有错误, 但延迟 约 五秒钟 ,只有 sull'alert的 声音, 而 箭头 不断出现 准确的 蜡烛的 开放 。你是正确的;你正在运行一个指标。 | |
y thi |
你好,谢谢你, 马西莫。
#define MAX_DATETIME D'3000.12.31 23:59:59' // 32,535,215,999 #define MIN_DATETIME D'1970.01.01 00:00:00' // Zero. int start(){ static datetime alertTime = MAX_DATETIME; if (TimeCurrent() > alertTime) { alertTime = MAX_DATETIME; Alert(“ ATTENTION!!!!); } if (BarStart !=Time[0]) { BarStart = Time[0]; // //Indicator Buffer 1 if(iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 0) < 30 ) { alertTime = TimeCurrent() + 3; Buffer1[0] = Low[0] - iATR(NULL, PERIOD_CURRENT, 14, 0); } else { Buffer1[0] = 0; } //Indicator Buffer 2 if(iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 0) > 70 ) { alertTime = TimeCurrent() + 3; Buffer2[0] = High[0] + iATR(NULL, PERIOD_CURRENT, 14, 0); } else { Buffer2[0] = 0; } } return(0); } //+------------------------------------------------------------------+
omissamf: 只有 sull'alert 的声音。
- 不知道你是什么意思。
Alert(“ ATTENTION!!!!); }
试着/贴出能编译的 代码。
WHRoeder:
我把 ATTENTION !!!因为它是 在 声音 / 视觉 警报 中 出现的, 但我正在 尝试, 在你的帮助下,延迟 箭 的发作 几秒钟。 在这种情况下。 注意 !!!它将 在5 秒 后 出现 ,而 箭头 则 在刚打开 蜡烛 时 出现。- 不知道你是什么意思。
- 试着/贴出能编译的 代码。
谢谢你所做的一切, 马西莫。
我想 修改这 段 代码, 使 警报 不是 在 蜡烛 开盘时 出现,而是 在 几秒钟 后 检测 条件。
谢谢你做的一切, 马西莫。