Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json serialize problem #120

Closed
vyacheslav-skvortsov opened this issue May 9, 2018 · 2 comments
Closed

Json serialize problem #120

vyacheslav-skvortsov opened this issue May 9, 2018 · 2 comments
Labels
Projects

Comments

@vyacheslav-skvortsov
Copy link

vyacheslav-skvortsov commented May 9, 2018

I want to perform "Order close by". This is my code:

MqlTradeResult result;
_apiClient.OrderSend(new MqlTradeRequest
 {
       Action = ENUM_TRADE_REQUEST_ACTIONS.TRADE_ACTION_CLOSE_BY,
       Position = request.Ticket,
       PositionBy = request.OppositeTicket,
}, out result);
return result;

I dont need to send Symbol property. After json serialization MtApi5 advisor takes this json:
{"RequestType" : 3,"TradeRequest" : {"Type" : 0,"Magic" : 0,"Order" : 0,"Type_filling" : 0,"Sl" : 0,"Tp" : 0,"Deviation" : 0,"Action" : 10,"PositionBy" : 15052,"Type_time" : 0,"Position" : 0,"Price" : 0,"MtExpiration" : 0,"Stoplimit" : 0,"Volume" : 0}}-There is no Symbol property and it leads to errors: "Failed to parse parameter TradeRequest" on response and "JsonToMqlTradeRequest: failed to get Symbol from JSON!" on Advisor.

I modified MqlTradeRequest class like this:

public class MqlTradeRequest
    {
        public ENUM_TRADE_REQUEST_ACTIONS Action { get; set; }           // Trade operation type
        public ulong Magic { get; set; }                                 // Expert Advisor ID (magic number)
        public ulong Order { get; set; }                                 // Order ticket

        public string Symbol { get; set; } = String.Empty;               // Trade symbol

Now everything is ok. Could you fix this, please, in next releases?

@vdemydiuk
Copy link
Owner

Sure. I will fix it next release. Thank you.

@vdemydiuk
Copy link
Owner

I have added fix to mql code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
MtApi MT5
Awaiting triage
Development

No branches or pull requests

2 participants