mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-07-27 18:47:55 +00:00
Added function OrderCloseAll to mtapi4
This commit is contained in:
@@ -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.14.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.14.0")]
|
||||
[assembly: AssemblyVersion("1.0.15.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.15.0")]
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "MT4Handler.h"
|
||||
#include "Windows.h"
|
||||
#include < vcclr.h >
|
||||
|
||||
using namespace System;
|
||||
using namespace MTApiService;
|
||||
|
||||
@@ -113,7 +113,7 @@
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<ModuleDefinitionFile>.\MTConnector.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
||||
@@ -303,6 +303,10 @@ namespace MtApi
|
||||
return (TradeOperation) retVal;
|
||||
}
|
||||
|
||||
public bool OrderCloseAll()
|
||||
{
|
||||
return sendCommand<bool>(MtCommandType.OrderCloseAll, null);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Check Status
|
||||
|
||||
@@ -181,6 +181,7 @@ namespace MtApi
|
||||
iTimeArray = 149,
|
||||
|
||||
//
|
||||
RefreshRates = 150
|
||||
RefreshRates = 150,
|
||||
OrderCloseAll = 151
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.16.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.16.0")]
|
||||
[assembly: AssemblyVersion("1.0.17.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.17.0")]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
|
||||
<?define ProductName="MtApi" ?>
|
||||
<?define ProductVersion="1.0.16" ?>
|
||||
<?define ProductVersion="1.0.17" ?>
|
||||
<?define Manufacturer="DW"?>
|
||||
|
||||
<Product Id="*"
|
||||
|
||||
Binary file not shown.
+37
-6
@@ -149,20 +149,20 @@ int init() {
|
||||
|
||||
if (IsDllsAllowed() == FALSE)
|
||||
{
|
||||
MessageBoxA(0, "Dlls not allowed.", "MtApi", 0);
|
||||
MessageBox("Dlls not allowed.", "MtApi", MB_OK);
|
||||
isCrashed = TRUE;
|
||||
return (1);
|
||||
}
|
||||
if (IsLibrariesAllowed() == FALSE)
|
||||
{
|
||||
MessageBoxA(0, "Libraries not allowed.", "MtApi", 0);
|
||||
MessageBox("Libraries not allowed.", "MtApi", MB_OK);
|
||||
isCrashed = TRUE;
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (IsTradeAllowed() == FALSE)
|
||||
{
|
||||
MessageBoxA(0, "Trade not allowed.", "MtApi", 0);
|
||||
MessageBox("Trade not allowed.", "MtApi", MB_OK);
|
||||
isCrashed = TRUE;
|
||||
return (1);
|
||||
}
|
||||
@@ -171,7 +171,7 @@ int init() {
|
||||
|
||||
if (!initExpert(ExpertHandle, ConnectionProfile, Symbol(), Bid, Ask, message))
|
||||
{
|
||||
MessageBoxA(0, message[0], "MtApi", 0);
|
||||
MessageBox(message[0], "MtApi", MB_OK);
|
||||
isCrashed = TRUE;
|
||||
return(1);
|
||||
}
|
||||
@@ -190,7 +190,7 @@ int deinit() {
|
||||
{
|
||||
if (!deinitExpert(ExpertHandle, message))
|
||||
{
|
||||
MessageBoxA(0, message[0], "MtApi", 0);
|
||||
MessageBox(message[0], "MtApi", MB_OK);
|
||||
isCrashed = TRUE;
|
||||
return (1);
|
||||
}
|
||||
@@ -1176,7 +1176,7 @@ int executeCommand()
|
||||
PrintParamError("date");
|
||||
}
|
||||
|
||||
if (!sendIntResponse(ExpertHandle, TimeDayOfYear(dateValue)))
|
||||
if (!sendIntResponse(ExpertHandle, TimeDayOfYear(dateValue[0])))
|
||||
{
|
||||
PrintResponseError("TimeDayOfYear");
|
||||
}
|
||||
@@ -3335,6 +3335,13 @@ int executeCommand()
|
||||
PrintResponseError("RefreshRates");
|
||||
}
|
||||
break;
|
||||
|
||||
case 151: //OrderCloseAll
|
||||
if (!sendBooleanResponse(ExpertHandle, OrderCloseAll()))
|
||||
{
|
||||
PrintResponseError("OrderCloseAll");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
Print("Unknown command type = ", commandType);
|
||||
@@ -3370,4 +3377,28 @@ void PrintParamError(string paramName)
|
||||
void PrintResponseError(string 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);
|
||||
}
|
||||
Reference in New Issue
Block a user