diff --git a/MtApi/MtApiClient.cs b/MtApi/MtApiClient.cs index 2c3576e0..cd44a83f 100755 --- a/MtApi/MtApiClient.cs +++ b/MtApi/MtApiClient.cs @@ -178,6 +178,12 @@ namespace MtApi return OrderCloseBy(ticket, opposite, Color.Empty); } + public bool OrderCloseByCurrentPrice(int ticket, int slippage) + { + var commandParameters = new ArrayList { ticket, slippage }; + return sendCommand(MtCommandType.OrderCloseByCurrentPrice, commandParameters); + } + public double OrderClosePrice() { return sendCommand(MtCommandType.OrderClosePrice, null); diff --git a/MtApi/MtCommandType.cs b/MtApi/MtCommandType.cs index 6e46c9cc..fbcef7d5 100755 --- a/MtApi/MtCommandType.cs +++ b/MtApi/MtCommandType.cs @@ -16,10 +16,12 @@ namespace MtApi OrderSendBuyStoplossProfit = 10011, OrderSendSellStoplossProfit = 10012, OrderClose = 2, + OrderCloseByCurrentPrice = 152, OrderCloseBy = 3, OrderClosePrice = 4, OrderClosePriceByTicket = 1004, OrderCloseTime = 5, + OrderCloseAll = 151, OrderComment = 6, OrderCommission = 7, OrderDelete = 8, @@ -185,7 +187,6 @@ namespace MtApi iTimeArray = 149, // - RefreshRates = 150, - OrderCloseAll = 151 + RefreshRates = 150 } } diff --git a/MtApi/Properties/AssemblyInfo.cs b/MtApi/Properties/AssemblyInfo.cs index 1a7a53e4..afb673fa 100755 --- a/MtApi/Properties/AssemblyInfo.cs +++ b/MtApi/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.20.0")] -[assembly: AssemblyFileVersion("1.0.20.0")] +[assembly: AssemblyVersion("1.0.21.0")] +[assembly: AssemblyFileVersion("1.0.21.0")] diff --git a/MtApiInstaller/Product.wxs b/MtApiInstaller/Product.wxs index 50b460ea..20aae5c6 100755 --- a/MtApiInstaller/Product.wxs +++ b/MtApiInstaller/Product.wxs @@ -1,7 +1,7 @@ - + diff --git a/mq4/MtApi.ex4 b/mq4/MtApi.ex4 index 12b30c72..75c557d4 100755 Binary files a/mq4/MtApi.ex4 and b/mq4/MtApi.ex4 differ diff --git a/mq4/MtApi.mq4 b/mq4/MtApi.mq4 index 8143b149..ec8e98c9 100755 --- a/mq4/MtApi.mq4 +++ b/mq4/MtApi.mq4 @@ -459,8 +459,47 @@ int executeCommand() { PrintResponseError("OrderClose"); } + break; + + case 151: //OrderCloseAll + if (!sendBooleanResponse(ExpertHandle, OrderCloseAll())) + { + PrintResponseError("OrderCloseAll"); + } + break; + + case 152: //OrderCloseByCurrentPrice + if (!getIntValue(ExpertHandle, 0, ticketValue)) + { + PrintParamError("ticket"); + } - break; + if (!getIntValue(ExpertHandle, 1, slippageValue)) + { + PrintParamError("slippage"); + } + + lotsValue = 0; + if (OrderSelect(ticketValue, SELECT_BY_TICKET)) + { + symbolValue = OrderSymbol(); + lotsValue = OrderLots(); + if (OrderType() == OP_SELL) + { + priceValue = MarketInfo(symbolValue, MODE_ASK); + } + else + { + priceValue = MarketInfo(symbolValue, MODE_BID); + } + } + + if (!sendBooleanResponse(ExpertHandle, OrderClose(ticketValue, lotsValue, priceValue, slippageValue))) + { + PrintResponseError("OrderClose"); + } + break; + case 3: // OrderCloseBy if (!getIntValue(ExpertHandle, 0, ticketValue)) @@ -3460,13 +3499,6 @@ int executeCommand() } break; - case 151: //OrderCloseAll - if (!sendBooleanResponse(ExpertHandle, OrderCloseAll())) - { - PrintResponseError("OrderCloseAll"); - } - break; - default: Print("Unknown command type = ", commandType); sendVoidResponse(ExpertHandle);