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
...
So my question is actually: What happens with the information saved in my struct went the following happens:
So, I just want to know what can happen that will cause my array struct to loose the values that are stored in it when the above happens while the EA is running.
With EA nothing is lost in both the 4 cases. All variables are preserved.
Any time your EA is removed due to any condition, including but not limited to re-initialization, all data structures are also destroyed. The only way to prevent this is to use an object and implement logic to serialize its data and save it to a file so when the EA comes back up it will be able to load in the previously saved state.
That's not exact.
Global/static data (using structure or not) are not destroyed as long as the EA remains on the chart.
That's not exact.
Global/static data (using structure or not) are not destroyed as long as the EA remains on the chart.
They're not perfectly preserved either... I've had some unexpected consequences (complex objects) with the assumption that they were. Best to explicitly destroy them and reinitialize them with saved data if your program depends on a persistent state.
While this is indeed the proper way there is another - saving into a chart object. It can keep data through timeframe change and terminal (and PC) restart, it will save some disk read and write compared to file write, but it will lose data if terminal is not properly exited.
I've seen this "lifehack" before but it seems like more work. Do you have an example?
I used it on a multitimeframe arrow indicator with sound and background-change alert. I saved played and disabled alerts in invisible arrow objects named prefix+timeframe+time. It's not that much work, but definitely an overcomplication of logic. And only advantage is less reads and writes, which would be valid advantage if it needs thousands of entries per day, so in most cases definitely not a better alternative. But still a possible way, hence the need to be shared.
I've probably deleted the code as I can't find it anywhere. It was an interesting example of "innovations", although a total mess.
They're not perfectly preserved either... I've had some unexpected consequences (complex objects) with the assumption that they were. Best to explicitly destroy them and reinitialize them with saved data if your program depends on a persistent state.
If that's really the case that would be a bug and should be reported to Metaquotes.
If that's really the case that would be a bug and should be reported to Metaquotes.
lol, how?
lol, how?
With a testcase code and eventually all needed information to reproduce it. You can publish it in this topic https://www.mql5.com/en/forum/289237
I will help to reproduce it and submit it to Metaquotes (through Russian forum and personal contacts).
Just a thank you to everyone who took the time to reply to my question.
Thanks,
Christoff