experiment with such code, read the message in EA log (switch TF, enter variable, reload terminal without closing EA...)
and the second variant is to describe at global scope a variable with static modifier
Firstly, this is mql4.
Secondly, I need to run OnInit() at any change of variables of Expert Advisor.
That's all I ask for help!
Yes, rebooting the terminal and changing the text helps, but when you change variables, OnInit() does not work and that's why I get all the problems!!!!
Firstly, it's mql4. Secondly, I need to run OnInit() to change EA's variables.
Secondly, I need it to run OnInit() when Expert Advisor variables are changed.
That's all I ask for help!
Restarting the terminal and changing the text helps, but when you change the variables, OnInit() does not work and that's why I get all the problems!!!!
I have the following solution. OnInit() copies the variables at the 1st run of the EA. On Calc...() or whatever in MT4, it checks if the variables are identical to their copies. If the variables do not coincide, then we forcefully run OnInit() and if necessary, we will run something else before that to update the EA. And finally, return.
Firstly, it's mql4. Secondly, I need to run OnInit() to change EA's variables.
Secondly, I need it to run OnInit() when Expert Advisor variables are changed.
That's all I ask for help!
Yes, rebooting the terminal and changing the safeties helps, but when you change variables, OnInit() does not work and that's why I get all the problems!!!!
Have you looked at the code I gave you? It was MT4 and everything works as you asked
I have run the code I suggested, changed the external variable var twice, here is the Expert Advisor log:
015:36:39.736 Compiling 'test'
015:37:37.573 Expert test EURUSD,H1: loaded successfully
015:37:39.101 test EURUSD,H1 inputs: var1=1;
015:37:39.130 test EURUSD,H1: Вызов OnInit(), var1=1015:37:39.130 test EURUSD,H1: initialized
015:37:51.341 test EURUSD,H1: uninit reason 5015:37:51.343 test EURUSD,H1: Вызов OnInit(), var1=34567015:37:51.343 test EURUSD,H1: initialized
015:37:51.366 test EURUSD,H1 inputs: var1=34567;
015:38:04.124 test EURUSD,H1: uninit reason 5015:38:04.126 test EURUSD,H1: Вызов OnInit(), var1=-9999015:38:04.126 test EURUSD,H1: initialized
015:38:04.149 test EURUSD,H1 inputs: var1=-9999;
Here's the code where the "bugs are".
You can call any function from anywhere in an MQL program. The function of initializing an Expert Advisor is a function, and you can force-call OnInit(), but usually you don't need it.
Сразу же после того, как клиентский терминал загрузит программу (эксперт или пользовательский индикатор) и запустит процесс инициализации глобальных переменных, будет послано событие Init, которое обрабатывается функцией OnInit(), если она есть. Это событие также генерируется после смены финансового инструмента и/или периода графика, после...
it is better to normalize prices, then they will work, then the server will give out an error of "wrong prices", it is desirable to normalizeStopLoss_SELL
and most likely, you need to check if the StopLoss is equal to zero, and it is not desirable to compare real numbers to be equal, you should try to compare real numbers to > or <
If there are a lot of errors, would you mind pointing them all out?
I have run the code I suggested, changed the external variable var twice, here is the Expert Advisor log:
Here's the code where the "bugs are".
You can call any function from anywhere in MQL-program, the function of initializing an Expert Advisor is also a function. You can force-call OnInit(), but usually you don't need it - the terminal callsOnInit() by itself.
Thanks a lot thanks to your code of errors I found !!!!!!!!! GOOD LUCK !!!! AND THANKS FOR THE HELP !!!!!!
Please advise. How can I make the standard MA indicator be displayed not for the whole history, but for a specified number of candles? I would like to ask you a question.
prom18: Please advise. How can I make the standard MA indicator be displayed not for the whole history, but for a specified number of candles? Thank you.
Write your own MA indicator with setting the depth of history!
experiment with such code, read the message in EA log (switch TF, enter variable, reload terminal without closing EA...)
and the second variant is to describe at global scope a variable with static modifier
Firstly, this is mql4.
Secondly, I need to run OnInit() at any change of variables of Expert Advisor.
That's all I ask for help!
Yes, rebooting the terminal and changing the text helps, but when you change variables, OnInit() does not work and that's why I get all the problems!!!!
Firstly, it's mql4. Secondly, I need to run OnInit() to change EA's variables.
Secondly, I need it to run OnInit() when Expert Advisor variables are changed.
That's all I ask for help!
Restarting the terminal and changing the text helps, but when you change the variables, OnInit() does not work and that's why I get all the problems!!!!
I have the following solution. OnInit() copies the variables at the 1st run of the EA. On Calc...() or whatever in MT4, it checks if the variables are identical to their copies. If the variables do not coincide, then we forcefully run OnInit() and if necessary, we will run something else before that to update the EA. And finally, return.
Firstly, it's mql4. Secondly, I need to run OnInit() to change EA's variables.
Secondly, I need it to run OnInit() when Expert Advisor variables are changed.
That's all I ask for help!
Yes, rebooting the terminal and changing the safeties helps, but when you change variables, OnInit() does not work and that's why I get all the problems!!!!
Have you looked at the code I gave you? It was MT4 and everything works as you asked
read the documentationhttps://docs.mql4.com/ru/runtime/event_fire
I have run the code I suggested, changed the external variable var twice, here is the Expert Advisor log:
Here's the code where the "bugs are".
You can call any function from anywhere in an MQL program. The function of initializing an Expert Advisor is a function, and you can force-call OnInit(), but usually you don't need it.
there are a lot of errors in the code, in
it is better to normalize prices, then they will work, then the server will give out an error of "wrong prices", it is desirable to normalizeStopLoss_SELL
and most likely, you need to check if the StopLoss is equal to zero, and it is not desirable to compare real numbers to be equal, you should try to compare real numbers to > or <
If there are a lot of errors, would you mind pointing them all out?
did you look at the code I gave you? it was MT4 and everything works as you ask
then read the documentationhttps://docs.mql4.com/ru/runtime/event_fire
I have run the code I suggested, changed the external variable var twice, here is the Expert Advisor log:
Here's the code where the "bugs are".
You can call any function from anywhere in MQL-program, the function of initializing an Expert Advisor is also a function. You can force-call OnInit(), but usually you don't need it - the terminal callsOnInit() by itself.
Thanks a lot thanks to your code of errors I found !!!!!!!!! GOOD LUCK !!!! AND THANKS FOR THE HELP !!!!!!
Please advise. How can I make the standard MA indicator be displayed not for the whole history, but for a specified number of candles? Thank you.
How do I manually set quotes totest an EA?
There must be a solution, but I couldn't find it
What's wrong with F12 after a pause?
I meant specifically to set the price movement
How do I manually set quotes totest an EA?
Surely there is a solution, but I could not find it
Write your own ticks and put them in the strategy tester.