VasiliKolchanov: Hi all, could you please tell me how to pause a function, not the entire EA, but only one function, for example an alert?
How is that? So far, only a rather comical situation appears: the man goes on, but let him leave his head in this place for a while. Then we will bring it back.
VasiliKolchanov: Hi all ! Could you please tell me how to pause a function, not the whole EA, but just one function, e.g. alerts ?
You can do everything with a program that can be described with words, in your question, you have described what you have to do. This is how it is done: you describe the global (well, almost at the top of the program) variable in the program: bool pauza=false; When it's false - function works, true - function is paused. Now the function must react to pauza. To do this, either add if(pauza)return; at the beginning of the function, or something similar at the place of function call.
It remains in the main function to check the condition and manage the function through the variable pauza.
If you need to control from outside the program (from another script, Expert Advisor, indicator), then use the global variable of the terminal
How is that? So far, only a rather comical situation appears: the man goes on, but let him leave his head in this place for a while. Then we will bring it back.
I triggered the alert at a certain price level, there are a lot of instruments and the price will not immediately move away from the level of alert action, of course it will keep on chasing and chasing. You can disable the alert using the flag, but since there are many instruments, it is easy to forget to enable the alert, so for this I need to disable it temporarily and enable it (or rather its function) again after a specified time period.
VasiliKolchanov: I have an alert triggered at a certain price level, there are many instruments, and the price will not immediately move away from the alert triggering level, of course it will chop and chop further. You can disable the alert using a flag, but since there are a lot of instruments, it is easy to forget to enable the alert, so I need to disable it temporarily and enable it (or rather its function) after a specified period of time.
For this case, you can set an Alert triggering period. Let's say in seconds:
inputuint i_uAlertPeriod = 120; // Период отображения Alert, сек.
...
void DoAlert(string sText)
{
staticdatetime dtLastTime = 0;
if (TimeCurrent() - dtLastTime < i_uAlertPeriod)
return;
dtLastTime = TimeCurrent();
Alert(sText);
}
For this case, you can set an Alert triggering period. Let's say in seconds:
Ihor thanks for the answer, just one question, won't it be a delay of action, i.e. during the pause the alerts will accumulate with each tick, and when the time expires the EA will still give them to me (all accumulated) ? It may sound ridiculous, but sorry newbie - I'm learning.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
All of this is quite feasible
Hi all, could you please tell me how to pause a function, not the entire EA, but only one function, for example an alert?
How is that? So far, only a rather comical situation appears: the man goes on, but let him leave his head in this place for a while. Then we will bring it back.
Probably something else is meant.
Hi all ! Could you please tell me how to pause a function, not the whole EA, but just one function, e.g. alerts ?
You can do everything with a program that can be described with words, in your question, you have described what you have to do.
This is how it is done: you describe the global (well, almost at the top of the program) variable in the program: bool pauza=false;
When it's false - function works, true - function is paused.
Now the function must react to pauza.
To do this, either add if(pauza)return; at the beginning of the function, or something similar at the place of function call.
It remains in the main function to check the condition and manage the function through the variable pauza.
If you need to control from outside the program (from another script, Expert Advisor, indicator), then use the global variable of the terminal
How is that? So far, only a rather comical situation appears: the man goes on, but let him leave his head in this place for a while. Then we will bring it back.
I guess that's not what you mean.
I have an alert triggered at a certain price level, there are many instruments, and the price will not immediately move away from the alert triggering level, of course it will chop and chop further. You can disable the alert using a flag, but since there are a lot of instruments, it is easy to forget to enable the alert, so I need to disable it temporarily and enable it (or rather its function) after a specified period of time.
For this case, you can set an Alert triggering period. Let's say in seconds:
I need to take data from the last closed trade, more precisely, I need lot value, how can I register this in Mt4
I looked everywhere, there is one for Mt5, but not for Mt4
I need to take data from the last closed trade, more precisely, I need lot value, how can I register this in Mt4
I looked everywhere, there is one for Mt5, but not for Mt4
Actually it should be the other way around)
For this case, you can set an Alert triggering period. Let's say in seconds: