Zippu:
Do arrays survive execution of the script?
Are you discussing an EA or a Script?
Hi Keith, it's a good question thanks.
My goal is an EA, however I am not yet familiar with the differences between them.
I understand of course that a script is run once and the EA is always active - however it isn't clear to me if the EA isn't just a script which is repeatedley run on each tick.
How is the distinction made in the code?
(and, if there are specific resources that discuss this please do link me :) )
Cornelius
Hi Keith, it's a good question thanks.
My goal is an EA, however I am not yet familiar with the differences between them.
I understand of course that a script is run once and the EA is always active - however it isn't clear to me if the EA isn't just a script which is repeatedley run on each tick.
How is the distinction made in the code?
(and, if there are specific resources that discuss this please do link me :) )
Cornelius
Read this: https://www.mql5.com/en/docs/runtime/running and rest of the chapter on MQL5 programs.
- www.mql5.com
Hi Keith, it's a good question thanks.
My goal is an EA, however I am not yet familiar with the differences between them.
I understand of course that a script is run once and the EA is always active - however it isn't clear to me if the EA isn't just a script which is repeatedley run on each tick.
How is the distinction made in the code?
(and, if there are specific resources that discuss this please do link me :) )
Cornelius
An EA has a function called OnTick() which is run on every tick
A Script has a function called OnStart() which is run once.
That's perfect, thank you very much @Drazen Penic, @Fernando Morales and @Keith Watford.
I really appreciate you taking the time to point me in the right direction.
Happy trading!
Cornelius
- 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'm new to the MT language, haven't coded anything in a very long time, and yet... I am going try my hand at making an EA :p. I've already one running and have some of my own ideas that I would like to try out.
I'm starting by reading through the language database and writing out some pseudo code however I came across a question to which I cannot find the answer.
Sorry if I'm dumb, but...
Do arrays survive execution of the script? My understanding is that scripts are entirely executed once per tick, therefore anything I define will be cleared at the end of the script and redefined again on the next one.
How then can we maintain array data over time? I saw in another thread somebody mentioned using comment files or log files, which I guess are accessed on each tick. That would certainly work, but is there an easier way?
I am aiming to build around the grid theme, so would be carrying trade data from tick to tick.
Again sorry if this is a noob question but I can't seem to find my answer in the knowledge base.
Of course if it is there, please do feel free to link me to it :)
Thanks for your help!
Cornelius