【Development Behind the Scenes】After the MT5 update, “Orders go through but the EA is behaving oddly”?—First, suspicion on Build issues and the recovery method I used, an “extreme” workaround
This time, I will write about a slightly troublesome issue that I actually encountered during MT5 development.
One day, an EA that had been working normally suddenly
the order itself was filled correctly
but the EA side judged it as a "order failed"
an error sound and a timeout sound played
the post-order processing did not execute
This phenomenon occurred.
In the Trade Toolbox series' SmartOrderEA, it is a state where the panel processing and success sounds that should occur after a successful order do not work.
At first glance, it might seem that there is a problem with the EA's program.
However, upon investigation, the cause turned out to be in an unexpected place.
1. It is an “order succeeded” but judged as “failed”
First, I checked the Expert log.
Then there was this kind of log.
CTrade::OrderSend: market buy 0.01 USDJPY sl: 158.716 [unknown retcode 0]
Order failed | Error=4756 | Retcode=0 | Comment=DoneWhat caught my attention here was
Comment=Done
It seems to indicate that the order was completed, but the Retcode obtained by the EA was
0.
Therefore the EA judged the order as a failure and did not execute subsequent processing.
In other words,
the order is established, but the EA is told it failed.
This is a very confusing state.
2. Suspecting the MT5 core rather than the code
At this point, of course, I checked the EA's code.
However in this case,I did not modify the code.
Moreover, comparing with another environment where it was functioning normally, the MT5 Build was different.
The environment that was functioning normally hadBuild 6090.
On the other hand, the environment where the problem occurred hadBuild 6116.
Therefore, I suspected an impact from MT5 itself updates.
You can check MT5 Build from
Help → About
to confirm.
In this case, the difference in Build and the phenomenon of “Done but Retcode=0” overlapped, making it highly likely that there was an issue with MT5's return code processing.
3. The "extreme" measure I used
Having concluded that the cause lay with MT5 itself, the next question was
“How to revert immediately?”
There is also the option to wait for a corrected update.
However, I wanted to avoid a situation where the EA does not operate normally in the actual environment.
So what I did was
back up the MT5 that was functioning correctlyterminal64.exe and transplant it to the problematic environment
.
It is a rather rough method (laughs).
It is not an official recovery procedure, but it worked in this investigation.
Steps I followed
Exit MT5 completely
Open the installation folder of the MT5 that is functioning normally
Back up terminal64.exe.Replace the MT5 that has the issue with the backed-up
terminal64.exe.Restart MT5
This restored the MT5 environment to the Build that was functioning correctly, and the EA's behavior was recovered as well.
Of course, since this method directly swaps MT5 core files, it is not something to do regularly; it is simply the workaround I used this time.I am presenting it as a fallback measure rather than a standard procedure.
4. The importance of “keeping a healthy environment” learned from this experience
What I realized again from this case is
the importance of keeping a healthy, working environment
.
After MT5 updates,
“EA that used to work now behaves oddly”
“Indicator display is wrong”
“Behavior is different from before”
If this happens, instead of immediately modifying the code,
make the first check whether the MT5 Build has changed
and consider that as the initial step for problem isolation.
Even this alone makes it easier to identify the cause.
Of course, not all issues are caused by build updates.
“It started acting strangely right after an update”
so it is worthwhile to check the Build first.
Conclusion
In this case, at first I questioned the EA's code.
However,
I did not change the code
↓
compare with a normal environment
↓
MT5 Build is different
↓
the log also contains a contradiction of “Done but Retcode=0”
By confirming in this order, I was able to isolate the cause.
When software has bugs, people tend to blame the code alone.
But for tools that run on MT4/MT5,it is also important to check whether the execution environment itself has changed.
If after an MT5 update the EA or indicator behaves strangely,
first, check the Build.
If you keep this as the first item for problem isolation, you may avoid needlessly modifying code.
Trade Toolbox series is here
The Trade Toolbox series has a free version, a trial version, and a paid version.
If anything interests you, please try it in your actual environment first.
Product list for the Trade Toolbox series
Trade_Toolbox_SmartOrder_Pro_EA is here
And for those who actually use it,
please share your frank impressions in reviews such as
“This was convenient”
“Things to improve”
I would be happy to hear your honest feedback in reviews.
Not only positive feedback,but the real opinions of those who used it will be a reference for future development.
Thank you for reading to the end.