1. Init - does something that you want the EA to do as it is loaded in the chart. If that is so, why does this not prompt the Hello world upon load of the EA?
// This:voidOnInit();
//orvoid Init();
//gives the error message: '{' - function definition unexpected// while this:voidOnInit()
//orvoid Init()
//gives the error message: 'return' - 'void' function returns a value
- Is the Init/OnInit part of the code optional?
- Is Init same as OnInit? If no, how are they different? I read that Init is for MQL4 and OnInit is for MQL5. Is there any difference other than the syntax?
2. Deinit - shows an error message why the EA failed. I was unable to test it but is this correct?
- Is Deinit same as OnDeinit? as stated above.
- I read that void classes do not return any value. But why does void Deinit (); return the reason for deinitialization?
3. Start - It is said that this is for scripts and not EA. https://docs.mql4.com/runtime/event_fire#start however, it works fine in my EA. Furthermore, a certain EA generator website uses this Start function as a default command which encompasses all OpenBuy, OpenSell, etc orders. Can anyone clarify this?
4. OnTick - It seems to work fine, in the same precise way Start works. But sometimes, Start works but OnTick fails. How can that be? How are the 2 different? The only distinction between them is as said by the abovementioned site, but in my test case it does not seem to be the case.
5. Print - when must the "void" class be included in the code, as the mql4 guide has mentioned in the examples? My experience shows that sometimes it requires the void portion. At times it does not. Is this discrepancy due to the Print() function or the void class? If so, what might that be?
These will be all for now.
I thank you in advance for your patience. Your guidance is very much appreciated. :)
Immediately after the client terminal loads a program (an Expert Advisor or custom indicator) and starts the process of initialization of global variables, the Init event will be sent, which will be processed by OnInit() event handler, if there is such. This event is also generated after a financial instrument and/or chart timeframe is changed...
Hahaha... how did this go unnoticed? I seriously think that the whroeder1 account is run by a bot and occasionally checked by a human.
It's been established that there is a bug in the round function for half-rounding. Instead of round you should use
You can't be serious.
It was established in that other thread, that your values resulted in a value of x.499999 which MathRoundcorrectly rounded down and NormalizedDouble (incorrectly) did not.
1. Init - does something that you want the EA to do as it is loaded in the chart. If that is so, why does this not prompt the Hello world upon load of the EA?
- Why do the following errors show?
- Is the Init/OnInit part of the code optional?
- Is Init same as OnInit? If no, how are they different? I read that Init is for MQL4 and OnInit is for MQL5. Is there any difference other than the syntax?
2. Deinit - shows an error message why the EA failed. I was unable to test it but is this correct?
- Is Deinit same as OnDeinit? as stated above.
- I read that void classes do not return any value. But why does void Deinit (); return the reason for deinitialization?
3. Start - It is said that this is for scripts and not EA. https://docs.mql4.com/runtime/event_fire#start however, it works fine in my EA. Furthermore, a certain EA generator website uses this Start function as a default command which encompasses all OpenBuy, OpenSell, etc orders. Can anyone clarify this?
4. OnTick - It seems to work fine, in the same precise way Start works. But sometimes, Start works but OnTick fails. How can that be? How are the 2 different? The only distinction between them is as said by the abovementioned site, but in my test case it does not seem to be the case.
5. Print - when must the "void" class be included in the code, as the mql4 guide has mentioned in the examples? My experience shows that sometimes it requires the void portion. At times it does not. Is this discrepancy due to the Print() function or the void class? If so, what might that be?
These will be all for now.
I thank you in advance for your patience. Your guidance is very much appreciated. :)
It's been established that there is a bug in the round function for half-rounding. Instead of round you should use
whroeder1:
...
It was established in that other thread, that your values resulted in a value of x.499999 which MathRoundcorrectly rounded down and NormalizedDouble (incorrectly) did not.
Actually what is established is that MathRound() and NormalizeDouble() are rounding in a different way. Nothing more. Half rounding up is the common method, but it's not the only one, and it's not mandatory.
Saying now that one should always use NormalizeDouble() while rounding (normalizing to tick) a price, is not better than saying that NormalizeDouble() usage is always wrong.
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.
I would like to ask the following:
- Why do the following errors show?
- Is the Init/OnInit part of the code optional?
- Is Init same as OnInit? If no, how are they different? I read that Init is for MQL4 and OnInit is for MQL5. Is there any difference other than the syntax?
2. Deinit - shows an error message why the EA failed. I was unable to test it but is this correct?
- Is Deinit same as OnDeinit? as stated above.
- I read that void classes do not return any value. But why does void Deinit (); return the reason for deinitialization?
3. Start - It is said that this is for scripts and not EA. https://docs.mql4.com/runtime/event_fire#start however, it works fine in my EA. Furthermore, a certain EA generator website uses this Start function as a default command which encompasses all OpenBuy, OpenSell, etc orders. Can anyone clarify this?
4. OnTick - It seems to work fine, in the same precise way Start works. But sometimes, Start works but OnTick fails. How can that be? How are the 2 different? The only distinction between them is as said by the abovementioned site, but in my test case it does not seem to be the case.
5. Print - when must the "void" class be included in the code, as the mql4 guide has mentioned in the examples? My experience shows that sometimes it requires the void portion. At times it does not. Is this discrepancy due to the Print() function or the void class? If so, what might that be?
These will be all for now.
I thank you in advance for your patience. Your guidance is very much appreciated. :)
Hahaha... how did this go unnoticed? I seriously think that the whroeder1 account is run by a bot and occasionally checked by a human.
It's been established that there is a bug in the round function for half-rounding. Instead of round you should use
I would like to ask the following:
- Why do the following errors show?
- Is the Init/OnInit part of the code optional?
- Is Init same as OnInit? If no, how are they different? I read that Init is for MQL4 and OnInit is for MQL5. Is there any difference other than the syntax?
2. Deinit - shows an error message why the EA failed. I was unable to test it but is this correct?
- Is Deinit same as OnDeinit? as stated above.
- I read that void classes do not return any value. But why does void Deinit (); return the reason for deinitialization?
3. Start - It is said that this is for scripts and not EA. https://docs.mql4.com/runtime/event_fire#start however, it works fine in my EA. Furthermore, a certain EA generator website uses this Start function as a default command which encompasses all OpenBuy, OpenSell, etc orders. Can anyone clarify this?
4. OnTick - It seems to work fine, in the same precise way Start works. But sometimes, Start works but OnTick fails. How can that be? How are the 2 different? The only distinction between them is as said by the abovementioned site, but in my test case it does not seem to be the case.
5. Print - when must the "void" class be included in the code, as the mql4 guide has mentioned in the examples? My experience shows that sometimes it requires the void portion. At times it does not. Is this discrepancy due to the Print() function or the void class? If so, what might that be?
These will be all for now.
I thank you in advance for your patience. Your guidance is very much appreciated. :)
Up. :)
Hahaha... how did this go unnoticed? I seriously think that the whroeder1 account is run by a bot and occasionally checked by a human.
Please stop that behaviour.
Forum on trading, automated trading systems and testing trading strategies
General rules and best pratices of the Forum.
Alain Verleyen, 2018.03.11 19:44
Forum rules, enforced by moderators :
Your statement is a direct attack on WHRoeder and is not acceptable.I hope you will agree we have to stop repeating the errors of the past.
nicholishen:
It's been established that there is a bug in the round function for half-rounding. Instead of round you should use
Actually what is established is that MathRound() and NormalizeDouble() are rounding in a different way. Nothing more. Half rounding up is the common method, but it's not the only one, and it's not mandatory.
Saying now that one should always use NormalizeDouble() while rounding (normalizing to tick) a price, is not better than saying that NormalizeDouble() usage is always wrong.