Added fucntion OrderCloseAll into mt5 api

This commit is contained in:
Vyacheslav Demidyuk
2014-11-21 12:37:20 +02:00
parent fe4f0af9de
commit 772b27551c
7 changed files with 51 additions and 43 deletions
BIN
View File
Binary file not shown.
+23
View File
@@ -2,6 +2,7 @@
#property link ""
#include <Trade\SymbolInfo.mqh>
#include <trade/trade.mqh>
#import "MT5Connector.dll"
bool initExpert(int expertHandle, string connectionProfile, string symbol, double bid, double ask, string& err);
@@ -1590,6 +1591,17 @@ int executeCommand()
}
}
break;
case 63: //OrderCloseAll
{
bool retVal;
retVal = OrderCloseAll();
sendBooleanResponse(ExpertHandle, retVal);
}
break;
default:
Print("Unknown command type = ", commandType);
@@ -1704,4 +1716,15 @@ string ResultToString(bool retVal, datetime from, datetime to)
, (int)to);
return strResult;
}
bool OrderCloseAll()
{
CTrade trade;
int i = PositionsTotal()-1;
while (i >= 0)
{
if (trade.PositionClose(PositionGetSymbol(i))) i--;
}
return true;
}