I would like to ask the following:
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?
int OnInit() { return(INIT_SUCCEEDED); Print("Hello World"); }
Try
int OnInit() { Print("Hello World"); return(INIT_SUCCEEDED); }
Try
When you want to start a new project, click on "New" towards the top and left in the editor. Then click on "Indicator" or "Expert" and complete each stage. Then you will have the new template for coding which will include the recent options, OnTick or OnCalculate. It will also use Property Strict which everybody should be using nowadays.
When you want to start a new project, click on "New" towards the top and left in the editor. Then click on "Indicator" or "Expert" and complete each stage. Then you will have the new template for coding which will include the recent options, OnTick or OnCalculate. It will also use Property Strict which everybody should be using nowadays.
But sometimes, the OnTick causes errors while the start works flawlessly.
It is extremely doubtful that OnTick would cause errors that you would not get with start.
It is more likely that it is Property Strict that will give errors/warnings because the coding is not following strict procedures. Be thankful for that as it will force you to improve your coding.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of 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. :)
=====