You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is the problem I encountered today.
When I get an order update from TradeMonitor
I try to pass the changed orders through the event for processing one by one.
One of the processing steps is to check the order ‘s comment.
I found it is null which will trigger .net to generate a null Exception
I think it should be a empty string.
I modified the mq4 file. But it’s still null
I don't clear the message build process, I think you can fix this problem faster.
This problem also made me discover another place for improvement.
The code in the TimerTradeMonitor line 82 looks like this:
_timer.Elapsed -= _timer_Elapsed; //unregister from events to prevent rise condition during work with orders
Check();
_timer.Elapsed += _timer_Elapsed; //register again
There is event passing in Check() on TradeMonitor line 153
AvailabilityOrdersChanged?.Invoke(this, new AvailabilityOrdersEventArgs(openedOrders, closedOrders));
This null error is included in my processing event
The result is that Check() has an error.
Then _timer.Elapsed += _timer_Elapsed is not executed
So the TradeMonitor was interrupted.
At the same time, the upper order processing event was handled by my try catch.
The result is nothing happens, as if the TimerTradeMonitor did not start running.
I spent a lot of time to find the root cause of this problem.
I think adding and subtracting _timer.Elapsed is not a particularly good method.
You can consider another way to control the switch of the order check event.
Also consider whether to do exception handling when sending events
I just thought of it, that is the problem I found before.
Set comment to "" instead of null when I send a order
After the order is executed, the real comment is not "", but the request type
I think there are some problems in the serialization of json.
At that time, I didn't think it was a big problem.
maybe the current problem is related to this.
Hi,
This bug is still there.
When I try to get an order, a wrong magic number is being returned, although I had opened the order with null and "" comment.
There seems to be a bug in json serialization/deserialization, which causes this issue
Fixed in PR #297 — the MQL4 MtOrder class conditionally skipped the Comment field when it was an empty string, causing the .NET client to deserialize it as null. Now always serialized as "Comment": "".
Activity
zhao0876 commentedon Jun 27, 2019
I just thought of it, that is the problem I found before.
Set comment to "" instead of null when I send a order
After the order is executed, the real comment is not "", but the request type
I think there are some problems in the serialization of json.
At that time, I didn't think it was a big problem.
maybe the current problem is related to this.
vdemydiuk commentedon Jul 12, 2019
Hi.
Thank you for report of this problem.
I will check it soon and try to fix.
payam-alexander commentedon Apr 17, 2020
Hi,
This bug is still there.
When I try to get an order, a wrong magic number is being returned, although I had opened the order with null and "" comment.
There seems to be a bug in json serialization/deserialization, which causes this issue
eabase commentedon Dec 1, 2020
I think we should put another more obvious default. Perhaps
MTAPI?tudstudent commentedon Mar 21, 2026
Fixed in PR #297 — the MQL4
MtOrderclass conditionally skipped theCommentfield when it was an empty string, causing the .NET client to deserialize it asnull. Now always serialized as"Comment": "".Issue #167: fixed problem with comment in order (MT4)