Issue #89: Changed function PositionOpen to use json request/response

This commit is contained in:
vdemydiuk
2018-02-19 15:54:03 +02:00
parent c9c188f697
commit d6640300f5
8 changed files with 141 additions and 50 deletions
+19 -3
View File
@@ -544,10 +544,26 @@ namespace MtApi5
/// <returns>true - successful check of the basic structures, otherwise - false.</returns>
public bool PositionOpen(string symbol, ENUM_ORDER_TYPE orderType, double volume, double price, double sl, double tp, string comment , out MqlTradeResult result)
{
var commandParameters = new ArrayList { symbol, (int)orderType, volume, price, sl, tp, comment };
Log.Debug($"PositionOpen: symbol = {symbol}, orderType = {orderType}, volume = {volume}, price = {price}, sl = {sl}, tp = {tp}, comment = {comment}");
var strResult = SendCommand<string>(Mt5CommandType.PositionOpenWithResult, commandParameters);
return strResult.ParseResult(ParamSeparator, out result);
var response = SendRequest<OrderSendResult>(new PositionOpenRequest
{
Symbol = symbol,
OrderType = orderType,
Volume = volume,
Price = price,
Sl = sl,
Tp = tp,
Comment = comment
});
result = response?.TradeResult;
return response != null && response.RetVal;
//var commandParameters = new ArrayList { symbol, (int)orderType, volume, price, sl, tp, comment };
//var strResult = SendCommand<string>(Mt5CommandType.PositionOpenWithResult, commandParameters);
//return strResult.ParseResult(ParamSeparator, out result);
}
#endregion