omissamf: I would like to modify this code
Hello WHRoeder , thanks for the reply . I apologize for my behavior , but it was not my intent to offend and disrespect to anyone. I tried all day to change the code to accomplish this , but I did not succeed . They are the beginning of the study MQL4 . I ask again apologize administrators . Greetings , Massimo
Hello WHRoeder, I tried, but don't work!!! I tried in all ways, but do not understand where I'm wrong!!
Anyway, thanks for everything, Massimo.
I don't see an alert in your code
Hello GunRai, I send you the complete code, so I'll explain. I could not delay the confirmation of the conditions of the candel opening (as it is doing now), but after 3 seconds, even the suggestion of WHRoeder. I can not understand where I'm wrong !!!
Thanks, Max.
//+------------------------------------------------------------------+ //| 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); } //+------------------------------------------------------------------+
You are correct; you are running an indicator. | int start(){ if (BarStart !=Time[0]) { BarStart = Time[0]; Sleep(3000); RefreshRates(); //this code don't work |
Try this | #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:
Thanks, now I study the code you posted me and then let you know.You are correct; you are running an indicator. | |
Try this |
For now, infinite thanks, Massimo.
WHRoeder:
WHRoeder Hello, I tried to change the code with your instructions. I tried various ways and that's what you send is what you have not errors, but the delay of about five seconds there is only sull'alert sound, while the arrows keep appearing exact opening of the candle.You are correct; you are running an indicator. | |
y thi |
Hello and thank you, Massimo.
#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: there is only sull'alert sound,
- No idea what you meant.
Alert(“ ATTENTION!!!!); }
Try/post code that compiles.
WHRoeder:
I put ATTENTION !!! because it is the one that appears in sound / visual alert, but I'm trying, with your help, to delay the onset of the Arrow few seconds. In this case. Attention !!! It will appear after 5 seconds, while Arrows appear just open the candle.- No idea what you meant.
- Try/post code that compiles.
Thanks for everything, Massimo.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I would like to modify this code so that the alert, instead of appearing at the opening of the candle, detects the conditions after a few seconds.
Thanks for everything, Massimo.