Added command CloseOrderByCurrentPrice into mtapi 4

This commit is contained in:
vdemydiuk
2015-12-02 15:56:51 +02:00
parent f1a8d83c3b
commit 2d6a0f7b35
6 changed files with 52 additions and 13 deletions
+6
View File
@@ -178,6 +178,12 @@ namespace MtApi
return OrderCloseBy(ticket, opposite, Color.Empty); return OrderCloseBy(ticket, opposite, Color.Empty);
} }
public bool OrderCloseByCurrentPrice(int ticket, int slippage)
{
var commandParameters = new ArrayList { ticket, slippage };
return sendCommand<bool>(MtCommandType.OrderCloseByCurrentPrice, commandParameters);
}
public double OrderClosePrice() public double OrderClosePrice()
{ {
return sendCommand<double>(MtCommandType.OrderClosePrice, null); return sendCommand<double>(MtCommandType.OrderClosePrice, null);
+3 -2
View File
@@ -16,10 +16,12 @@ namespace MtApi
OrderSendBuyStoplossProfit = 10011, OrderSendBuyStoplossProfit = 10011,
OrderSendSellStoplossProfit = 10012, OrderSendSellStoplossProfit = 10012,
OrderClose = 2, OrderClose = 2,
OrderCloseByCurrentPrice = 152,
OrderCloseBy = 3, OrderCloseBy = 3,
OrderClosePrice = 4, OrderClosePrice = 4,
OrderClosePriceByTicket = 1004, OrderClosePriceByTicket = 1004,
OrderCloseTime = 5, OrderCloseTime = 5,
OrderCloseAll = 151,
OrderComment = 6, OrderComment = 6,
OrderCommission = 7, OrderCommission = 7,
OrderDelete = 8, OrderDelete = 8,
@@ -185,7 +187,6 @@ namespace MtApi
iTimeArray = 149, iTimeArray = 149,
// //
RefreshRates = 150, RefreshRates = 150
OrderCloseAll = 151
} }
} }
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.20.0")] [assembly: AssemblyVersion("1.0.21.0")]
[assembly: AssemblyFileVersion("1.0.20.0")] [assembly: AssemblyFileVersion("1.0.21.0")]
+1 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?define ProductName="MtApi" ?> <?define ProductName="MtApi" ?>
<?define ProductVersion="1.0.20" ?> <?define ProductVersion="1.0.21" ?>
<?define Manufacturer="DW"?> <?define Manufacturer="DW"?>
<?define ProductPath="..\build\products\$(var.Configuration)\"?> <?define ProductPath="..\build\products\$(var.Configuration)\"?>
BIN
View File
Binary file not shown.
+40 -8
View File
@@ -459,8 +459,47 @@ int executeCommand()
{ {
PrintResponseError("OrderClose"); 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 case 3: // OrderCloseBy
if (!getIntValue(ExpertHandle, 0, ticketValue)) if (!getIntValue(ExpertHandle, 0, ticketValue))
@@ -3460,13 +3499,6 @@ int executeCommand()
} }
break; break;
case 151: //OrderCloseAll
if (!sendBooleanResponse(ExpertHandle, OrderCloseAll()))
{
PrintResponseError("OrderCloseAll");
}
break;
default: default:
Print("Unknown command type = ", commandType); Print("Unknown command type = ", commandType);
sendVoidResponse(ExpertHandle); sendVoidResponse(ExpertHandle);