Added function OrderCloseAll to mtapi4

This commit is contained in:
Vyacheslav Demidyuk
2014-11-26 00:30:30 +02:00
parent 772b27551c
commit ab14a5f8a2
9 changed files with 50 additions and 13 deletions
+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.14.0")] [assembly: AssemblyVersion("1.0.15.0")]
[assembly: AssemblyFileVersion("1.0.14.0")] [assembly: AssemblyFileVersion("1.0.15.0")]
+1
View File
@@ -4,6 +4,7 @@
#include "MT4Handler.h" #include "MT4Handler.h"
#include "Windows.h" #include "Windows.h"
#include < vcclr.h >
using namespace System; using namespace System;
using namespace MTApiService; using namespace MTApiService;
+1 -1
View File
@@ -113,7 +113,7 @@
</ClCompile> </ClCompile>
<Link> <Link>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>user32.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>.\MTConnector.def</ModuleDefinitionFile> <ModuleDefinitionFile>.\MTConnector.def</ModuleDefinitionFile>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
+4
View File
@@ -303,6 +303,10 @@ namespace MtApi
return (TradeOperation) retVal; return (TradeOperation) retVal;
} }
public bool OrderCloseAll()
{
return sendCommand<bool>(MtCommandType.OrderCloseAll, null);
}
#endregion #endregion
#region Check Status #region Check Status
+2 -1
View File
@@ -181,6 +181,7 @@ 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.16.0")] [assembly: AssemblyVersion("1.0.17.0")]
[assembly: AssemblyFileVersion("1.0.16.0")] [assembly: AssemblyFileVersion("1.0.17.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.16" ?> <?define ProductVersion="1.0.17" ?>
<?define Manufacturer="DW"?> <?define Manufacturer="DW"?>
<Product Id="*" <Product Id="*"
BIN
View File
Binary file not shown.
+37 -6
View File
@@ -149,20 +149,20 @@ int init() {
if (IsDllsAllowed() == FALSE) if (IsDllsAllowed() == FALSE)
{ {
MessageBoxA(0, "Dlls not allowed.", "MtApi", 0); MessageBox("Dlls not allowed.", "MtApi", MB_OK);
isCrashed = TRUE; isCrashed = TRUE;
return (1); return (1);
} }
if (IsLibrariesAllowed() == FALSE) if (IsLibrariesAllowed() == FALSE)
{ {
MessageBoxA(0, "Libraries not allowed.", "MtApi", 0); MessageBox("Libraries not allowed.", "MtApi", MB_OK);
isCrashed = TRUE; isCrashed = TRUE;
return (1); return (1);
} }
if (IsTradeAllowed() == FALSE) if (IsTradeAllowed() == FALSE)
{ {
MessageBoxA(0, "Trade not allowed.", "MtApi", 0); MessageBox("Trade not allowed.", "MtApi", MB_OK);
isCrashed = TRUE; isCrashed = TRUE;
return (1); return (1);
} }
@@ -171,7 +171,7 @@ int init() {
if (!initExpert(ExpertHandle, ConnectionProfile, Symbol(), Bid, Ask, message)) if (!initExpert(ExpertHandle, ConnectionProfile, Symbol(), Bid, Ask, message))
{ {
MessageBoxA(0, message[0], "MtApi", 0); MessageBox(message[0], "MtApi", MB_OK);
isCrashed = TRUE; isCrashed = TRUE;
return(1); return(1);
} }
@@ -190,7 +190,7 @@ int deinit() {
{ {
if (!deinitExpert(ExpertHandle, message)) if (!deinitExpert(ExpertHandle, message))
{ {
MessageBoxA(0, message[0], "MtApi", 0); MessageBox(message[0], "MtApi", MB_OK);
isCrashed = TRUE; isCrashed = TRUE;
return (1); return (1);
} }
@@ -1176,7 +1176,7 @@ int executeCommand()
PrintParamError("date"); PrintParamError("date");
} }
if (!sendIntResponse(ExpertHandle, TimeDayOfYear(dateValue))) if (!sendIntResponse(ExpertHandle, TimeDayOfYear(dateValue[0])))
{ {
PrintResponseError("TimeDayOfYear"); PrintResponseError("TimeDayOfYear");
} }
@@ -3336,6 +3336,13 @@ 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);
@@ -3371,3 +3378,27 @@ void PrintResponseError(string commandName)
{ {
Print("[ERROR] response: ", commandName); Print("[ERROR] response: ", commandName);
} }
bool OrderCloseAll()
{
int total = OrdersTotal();
for(int i = total-1; i >= 0; i--)
{
if (OrderSelect(i, SELECT_BY_POS))
{
int type = OrderType();
switch(type)
{
//Close opened long positions
case OP_BUY: OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
break;
//Close opened short positions
case OP_SELL: OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );
break;
}
}
}
return (true);
}