Testing I found the following solution:
When the reason for OnDeinit is REASON_CHARTCHANGE or REASON_PARAMETERS, do not delete the pointers, because of all the reasons OnDeinit were the only ones that generated an invalid pointer when restarting the EA. This solution worked! Does it have any bad side effects on EA in doing this?
void OnDeinit(const int reason) { if(reason != REASON_CHARTCHANGE && reason != REASON_PARAMETERS){ delete ArrayOrdersModifyTickets; delete ArrayPositionsModifyTicket; delete ArrayOrdersModifyExpiration; delete ArrayPositionsModifySL_Price; delete ArrayPositionsModifyTP_Price; delete ArrayOrdersModifyPrice; delete ArrayOrdersModifySL_Price; delete ArrayOrdersModifyTP_Price; delete ArrayOrdersModifyVolume; delete ArrayOrdersModifyStopLimit; delete ArrayOrdersModifyTypeTime; delete ArrayOrdersDeleteTickets; delete ArrayPositionsCloseTickets; delete arraytest; } Print(TimeCurrent(),": " ,__FUNCTION__," código de motivo = ",reason); //--- "limpa" comentário Comment(""); }

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
All right?
I use pointers to store order information that could not be modified (positions and pending orders), or could not be closed (positions), or could not be deleted (pending orders). For later, take these orders / positions and make the necessary checks and try again with the previous values or updated according to the current market price.
My test code:
Attached, test file.
Thanks in advance for your help!