Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 624
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
This is how to modify
there are many 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 - it is not desirable to compare real numbers to be equal, you should try to compare real numbers to > or <
Help me fix a bug in the indicator, it doesn't draw high and low of the day when it's on the last candle of the hour.
I have sketched out the indicator, your code does not like working with strings, I would write it simpler, here is an example. Although if your task is to take into account server time offset, then the other way round is needed.
My example is also not an example, I wrote it fast, I think I should not have counted from the end of history to the beginning at first run, but from zero bar to the history, the code would have been shorter and would have been able to calculate the current day faster - the cycle would have been shorter,
But I checked it in the tester, it seems to work without problems, let it be that way, it's late, I'm sleepy... I made a bad example (((
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 whether 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 <
That's right. I just showed a place in the code, why it doesn't modify market orders: requesting a stop from the market will give 0.
Here's a sketched indicator, I don't like your code with strings, I would write it simpler, here's an example. Although if your task is to take into account server's time offset, then you have to do it differently.
My example is also not an example, I wrote it fast, I think I should not have counted from the end of history to the beginning at first run, but from zero bar to the history, the code would have been shorter and would have been able to calculate the current day faster - the cycle would have been shorter,
But I checked it in the tester, it seems to work without problems, let it be that way, it's late, I'm sleepy... Bad example done (((
It's not my code, I found it on the Internet, I can't write indicators. :)
For what it's worth a bad example, I really liked your indicator, it works in the Strategy Tester and on real charts.
Many thanks for the quick help!
May I also ask you to remove the lines that draw the channel? I have marked them with red arrows on the screenshot.
And if it's not too much trouble at all, please add the function to turn off/on the formation of lines on the current day. I marked them on the screenshot with blue arrows. https://prnt.sc/kuuj3e
Thanks in advance!
Hello Dear!
Please advise how to execute the OnInit() procedure;
after Expert Advisor variables have been changed!?
When placing the Expert Advisor on the chart, there is OnInit(); but when variables are changed, there is no OnInit!?
How to identify the event of the Expert Advisor variable change!?
Please help with advice, or rather with code, how to do it!?
Hello Dear!
Please advise how to execute the OnInit() procedure;
after Expert Advisor variables have been changed!?
When placing the Expert Advisor on the chart, there is OnInit(); but when variables are changed, there is no OnInit!?
How to identify the event of the Expert Advisor variable change!?
Please help with advice, or rather with code, how to do it!?
Experiment with this code, read the message in the EA log (switch the TF, enter the variable, restart the terminal without closing the EA...)
and the second option is to describe at global scope variable with modifier static
experiment with such code, read the message in the Expert Advisor log (switch the TF, enter the variable, reload the terminal without closing the Expert Advisor...)
and the second option is to describe at global scope variable with modifier static
At the global scope with the modifier static????? This is some kind of perversion.
On a global level with the static modifier static????? This is some kind of perversion.
But from my experience, when MT4 builds were often updated, it's better to write them according to classic C++, than to listen to the answer "write the code correctly" when communicating with developers
ZS: I remember why I started to write the static modifier globally, if I want to make sure I won't "lose" the variable value during MQL-program run. Earlier (about 5 years ago) the #property strict precompiler directive didn't exist and when enabling files (#include or library - I don't remember anymore) I "lost my variable" once, as the variable names coincided with the variable name.I was cursed by MQL but later I found this mistake by accident. But if I would write a static modifier the compiler would display a compilation error in that case too.
The current compiler is MT4, pretty handy and reliable, and with the directive #property strict, maybe I don't need such precautions, but I write static as a habit when I don't want to "lose a value" of a variable
ZZZY: this modifier does not affect the speed of execution of MQL-program, and it's convenient for me to open my code after some time, and having seen static I will know exactly, that this variable has a value, which is important "not to lose" during program execution
But from my experience, when MT4 builds were often updated, it's better to write them according to classic C++, than to listen to the answer "write the code correctly" when communicating with developers
ZS: I remember why I started to write the static modifier globally, if I want to make sure I won't "lose" the variable value during MQL-program run. Earlier (about 5 years ago) the #property strict precompiler directive didn't exist and when enabling files (#include or library - I don't remember anymore) I "lost my variable" once, as the variable names coincided with the variable name.I was cursed by MQL but later I found this mistake by accident. But if I would write a static modifier the compiler would display a compilation error in that case too.
The current compiler is MT4, pretty handy and reliable, and with the directive #property strict, maybe I don't need such precautions, but I write static as a habit when I don't want to "lose a value" of a variable
ZZZY: this modifier does not affect the speed of execution of MQL-program, and it's convenient for me to open my code after some time, and having seen static I will know exactly, that this variable has a value, which is important "not to lose" during program execution
The compiler will generate a warning if the variable names coincide with those in the include file. To me, a warning equals an error and I react to them the same way. And global-level variables with a static modifier equals butter.
But... If you like to write like that, no one can forbid you.
But... But... if you like writing it this way, no one can forbid you.
I have doubts about my uniqueness in this matter... I'm not the only one, searching through the MQL5 folder I found such declarations with static modifier on a global level in several source code of MT5 delivery
Even in the article "RANDOM DECISION FOREST IN THE SUMMARY" in the source code I found a declaration on the global level: static datetime last_time=0;
so I wrote as I see fit to allocate and will be, I do not 100% of variables at the global level describing as static
God protects the needy, said the nun... ))))