Here is what I got for each object with empty strings and object type 0:
ERR_WRONG_STRING_PARAMETER | 5040 | Damaged parameter of string type |
And the same code works just fine when the deinit reason is REASON_PARAMETERS.
Thank you for your suggestion.
Here is what I got for each object with empty strings and object type 0:
ERR_WRONG_STRING_PARAMETER | 5040 | Damaged parameter of string type |
And the same code works just fine when the deinit reason is REASON_PARAMETERS.
int totalObjects = ObjectsTotal(0, 0, -1); // Get the total number of objects in the chart Print("Total objects in the chart: ", totalObjects); for (int i = 0; i < totalObjects; i++) { string lineName = ObjectName(0, i);
Missing window argument.
I have modified the code following your recommendations but I still get error 4103 and 4202 even after correcting:
ERR_CHART_NOT_FOUND | 4103 | Chart not found |
ERR_OBJECT_NOT_FOUND | 4202 | Graphical object was not found |
int totalObjects = ObjectsTotal(0, 0, -1); // Get the total number of objects in the chart Print("Total objects in the chart: ", totalObjects); for (int i = 0; i < totalObjects; i++) { string lineName = ObjectName(0, i, 0, -1); Print("ERROR = ", GetLastError()); int objectType = (int)ObjectGetInteger(0, lineName, OBJPROP_TYPE); Print("Object index: ", i, " - Name: '", lineName, "' - Type: ", objectType);
2024.07.17 19:06:17.573 Manual Trading Interface (AUDJPY,M1) Deinitializing with reason: 3 2024.07.17 19:06:17.588 Manual Trading Interface (AUDJPY,M1) Total objects in the chart: 32 2024.07.17 19:06:17.603 Manual Trading Interface (AUDJPY,M1) ERROR = 4103 2024.07.17 19:06:17.619 Manual Trading Interface (AUDJPY,M1) Object index: 0 - Name: '32319Back' - Type: 0 2024.07.17 19:06:17.641 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.641 Manual Trading Interface (AUDJPY,M1) Object index: 1 - Name: '' - Type: 0 2024.07.17 19:06:17.641 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.641 Manual Trading Interface (AUDJPY,M1) Object index: 2 - Name: '' - Type: 0 2024.07.17 19:06:17.641 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.641 Manual Trading Interface (AUDJPY,M1) Object index: 3 - Name: '' - Type: 0 2024.07.17 19:06:17.641 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.641 Manual Trading Interface (AUDJPY,M1) Object index: 4 - Name: '' - Type: 0 2024.07.17 19:06:17.641 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.641 Manual Trading Interface (AUDJPY,M1) Object index: 5 - Name: '' - Type: 0 2024.07.17 19:06:17.642 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.642 Manual Trading Interface (AUDJPY,M1) Object index: 6 - Name: '' - Type: 0 2024.07.17 19:06:17.642 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.642 Manual Trading Interface (AUDJPY,M1) Object index: 7 - Name: '' - Type: 0 2024.07.17 19:06:17.642 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.642 Manual Trading Interface (AUDJPY,M1) Object index: 8 - Name: '' - Type: 0 2024.07.17 19:06:17.642 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.642 Manual Trading Interface (AUDJPY,M1) Object index: 9 - Name: '' - Type: 0 2024.07.17 19:06:17.643 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.643 Manual Trading Interface (AUDJPY,M1) Object index: 10 - Name: '' - Type: 0 2024.07.17 19:06:17.643 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.643 Manual Trading Interface (AUDJPY,M1) Object index: 11 - Name: '' - Type: 0 2024.07.17 19:06:17.643 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.643 Manual Trading Interface (AUDJPY,M1) Object index: 12 - Name: '' - Type: 0 2024.07.17 19:06:17.643 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.643 Manual Trading Interface (AUDJPY,M1) Object index: 13 - Name: '' - Type: 0 2024.07.17 19:06:17.652 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.652 Manual Trading Interface (AUDJPY,M1) Object index: 14 - Name: '' - Type: 0 2024.07.17 19:06:17.653 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.653 Manual Trading Interface (AUDJPY,M1) Object index: 15 - Name: '' - Type: 0 2024.07.17 19:06:17.653 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.653 Manual Trading Interface (AUDJPY,M1) Object index: 16 - Name: '' - Type: 0 2024.07.17 19:06:17.654 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.654 Manual Trading Interface (AUDJPY,M1) Object index: 17 - Name: '' - Type: 0 2024.07.17 19:06:17.668 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.668 Manual Trading Interface (AUDJPY,M1) Object index: 18 - Name: '' - Type: 0 2024.07.17 19:06:17.668 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.668 Manual Trading Interface (AUDJPY,M1) Object index: 19 - Name: '' - Type: 0 2024.07.17 19:06:17.668 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.668 Manual Trading Interface (AUDJPY,M1) Object index: 20 - Name: '' - Type: 0 2024.07.17 19:06:17.668 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.668 Manual Trading Interface (AUDJPY,M1) Object index: 21 - Name: '' - Type: 0 2024.07.17 19:06:17.670 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.670 Manual Trading Interface (AUDJPY,M1) Object index: 22 - Name: '' - Type: 0 2024.07.17 19:06:17.671 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.671 Manual Trading Interface (AUDJPY,M1) Object index: 23 - Name: '' - Type: 0 2024.07.17 19:06:17.671 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.671 Manual Trading Interface (AUDJPY,M1) Object index: 24 - Name: '' - Type: 0 2024.07.17 19:06:17.671 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.671 Manual Trading Interface (AUDJPY,M1) Object index: 25 - Name: '' - Type: 0 2024.07.17 19:06:17.671 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.671 Manual Trading Interface (AUDJPY,M1) Object index: 26 - Name: '' - Type: 0 2024.07.17 19:06:17.671 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.671 Manual Trading Interface (AUDJPY,M1) Object index: 27 - Name: '' - Type: 0 2024.07.17 19:06:17.671 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.671 Manual Trading Interface (AUDJPY,M1) Object index: 28 - Name: '' - Type: 0 2024.07.17 19:06:17.671 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.671 Manual Trading Interface (AUDJPY,M1) Object index: 29 - Name: '' - Type: 0 2024.07.17 19:06:17.671 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.671 Manual Trading Interface (AUDJPY,M1) Object index: 30 - Name: '' - Type: 0 2024.07.17 19:06:17.671 Manual Trading Interface (AUDJPY,M1) ERROR = 4202 2024.07.17 19:06:17.671 Manual Trading Interface (AUDJPY,M1) Object index: 31 - Name: '' - Type: 0 2024.07.17 19:06:17.672 Manual Trading Interface (AUDJPY,M1) File closed: AUDJPYHLINEs.txt 2024.07.17 19:06:17.712 Manual Trading Interface (AUDJPY,M4) Opened file for reading: AUDJPYHLINEs.txt 2024.07.17 19:06:17.712 Manual Trading Interface (AUDJPY,M4) File closed after reading: AUDJPYHLINEs.txt
Does anyone has any idea or had the same issue? I'm still struggling with this issue...
UP!
Does anyone has any idea or had the same issue? I'm still struggling with this issue...
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().
It works just fine when I change the user inputs or recompile for example, but when I change the timeframe (when the deinit reason is CHARTCHANGE) it returns empty strings for the ObjectNames and 0 for the object type (for all objects regardless of their respective types) when saving the objects to the external file.
Here is the code I use, and the logs below:
(I use other functions to save other object types but we don't need them here)
For example's sake it is supposed to save 2 HLINes.
Logs when changing the user input (when it works and saves the 2 lines that it is supposed to be saving):
And here are the logs when changing the timeframe (weird behavior):
What I have tried:
- To loop forward and backward through the objects. (it didn't work)
- To save the objects on CHART_CHANGE and also on OnTimer() to also save them outside the OnDeinit function. (it didn't work)
- To use Sleep(100); before, and after the save function in the OnDeinit(). (it didn't work)
- To put the save function into a "if (reason == REASON_CHARTCHANGE)"
I dont' have a lot of experience programming so I might be missing something very obvious but I would really appreciate some help as I don't know what to try anymore and I don't understnad the root of the issue even after exploring the forum.
Thank you in advance for your time.
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.
Do you suspect it to be a bug?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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().
It works just fine when I change the user inputs or recompile for example, but when I change the timeframe (when the deinit reason is CHARTCHANGE) it returns empty strings for the ObjectNames and 0 for the object type (for all objects regardless of their respective types) when saving the objects to the external file.
Here is the code I use, and the logs below:
(I use other functions to save other object types but we don't need them here)
For example's sake it is supposed to save 2 HLINes.
Logs when changing the user input (when it works and saves the 2 lines that it is supposed to be saving):
And here are the logs when changing the timeframe (weird behavior):
What I have tried:
- To loop forward and backward through the objects. (it didn't work)
- To save the objects on CHART_CHANGE and also on OnTimer() to also save them outside the OnDeinit function. (it didn't work)
- To use Sleep(100); before, and after the save function in the OnDeinit(). (it didn't work)
- To put the save function into a "if (reason == REASON_CHARTCHANGE)"
I dont' have a lot of experience programming so I might be missing something very obvious but I would really appreciate some help as I don't know what to try anymore and I don't understnad the root of the issue even after exploring the forum.
Thank you in advance for your time.