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
I do agree the main problem is the design itself, it's a bad idea to save objects only in OnDeinit().
Though about the OP issue itself, I am wondering what is the source of this statement : "The EA will be notified of the deinit event after the chart has been destroyed by the terminal. " ?
Certainly when the user said the issue happened when changing the timeframe, so the chart should not be destroyed at all.
I don't know, I am staying open as long as there is not a clear explanation.I see but I can't reproduce it so...
Hello programmer fellows.
To preserve the objects on the chart when the settings of my EA or the timeframe is changed, my EA saves the objects on external files on OnDeinit(), and load the objects from the external files on OnInit().
Thank you in advance for your time.
I see but I can't reproduce it so...
Thank you very much for trying to help.
I use the Version 5.00 - Build 4410.
Another thing that I have noticed, when I put the SaveLines() in the OnTimer() and OnDinit() then it throws the same errors, but when I comment the SaveLines() from the OnDeinit() and just leave the one from the OnTimer() it works correctly and the lines are loaded during OnInit().
So it seems that the issue comes from the OnDeinit function, and more specifically from the REASON_CHARTCHANGE reason.
The very same code is working correctly when the deinit reason is:
• REASON_RECOMPILE
• REASON_PARAMETERS
• REASON_CHARTCLOSE
• REASON_CLOSE
I guess I could leave the SaveLine() in the OnTimer() and remove it from the OnDeinit() for now as I'm not familiar with sqlite database (thank you for the suggestion Dominik).
Also, why is it a bad practice to save the object on OnDeInit?
I don't have any reason to save them while the EA is running that's why I put the function in the OnDeinit function thinking it was the more appropriate place to do it as I want to load them on OnInit() but both of you suggested that it's not a good idea so I'm surprised.
Thank you very much for trying to help.
I use the Version 5.00 - Build 4410.
Another thing that I have noticed, when I put the SaveLines() in the OnTimer() and OnDinit() then it throws the same errors, but when I comment the SaveLines() from the OnDeinit() and just leave the one from the OnTimer() it works correctly and the lines are loaded during OnInit().
So it seems that the issue comes from the OnDeinit function, and more specifically from the REASON_CHARTCHANGE reason.
The very same code is working correctly when the deinit reason is:
• REASON_RECOMPILE
• REASON_PARAMETERS
• REASON_CHARTCLOSE
• REASON_CLOSE
I guess I could leave the SaveLine() in the OnTimer() and remove it from the OnDeinit() for now as I'm not familiar with sqlite database (thank you for the suggestion Dominik).
Also, why is it a bad practice to save the object on OnDeInit?
I don't have any reason to save them while the EA is running that's why I put the function in the OnDeinit function thinking it was the more appropriate place to do it as I want to load them on OnInit() but both of you suggested that it's not a good idea so I'm surprised.
In general, it's not a good idea to save something important (only) in OnDeinit(). What will happen if MT5 crash or you computer, or a power outage or ...?
Thank you very much for trying to help.
I use the Version 5.00 - Build 4410.
Another thing that I have noticed, when I put the SaveLines() in the OnTimer() and OnDinit() then it throws the same errors, but when I comment the SaveLines() from the OnDeinit() and just leave the one from the OnTimer() it works correctly and the lines are loaded during OnInit().
So it seems that the issue comes from the OnDeinit function, and more specifically from the REASON_CHARTCHANGE reason.
The very same code is working correctly when the deinit reason is:
• REASON_RECOMPILE
• REASON_PARAMETERS
• REASON_CHARTCLOSE
• REASON_CLOSE
I guess I could leave the SaveLine() in the OnTimer() and remove it from the OnDeinit() for now as I'm not familiar with sqlite database (thank you for the suggestion Dominik).
Also, why is it a bad practice to save the object on OnDeInit?
I don't have any reason to save them while the EA is running that's why I put the function in the OnDeinit function thinking it was the more appropriate place to do it as I want to load them on OnInit() but both of you suggested that it's not a good idea so I'm surprised.