last ...
This commit is contained in:
@@ -3311,6 +3311,79 @@ class XC121SMCTradeHandler : public XCBaseAlert
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Force Close Specified Positions ...
|
||||
*
|
||||
* @param symbol: String ...
|
||||
* @param provider: String ...
|
||||
* @param period: ENUM_TIMEFRAMES member ...
|
||||
* @param type: ENUM_X_POSITION_TYPES member ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool ForceClose(
|
||||
string symbol = NULL,
|
||||
string provider = NULL,
|
||||
ENUM_TIMEFRAMES period = NULL,
|
||||
ENUM_X_POSITION_TYPES type = NULL //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
XPosition positions[];
|
||||
int count = mTrader.GetPositions(
|
||||
positions,
|
||||
symbol,
|
||||
provider,
|
||||
period,
|
||||
type //
|
||||
);
|
||||
result = IsValidSize(count);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
datetime cTime = TimeCurrent();
|
||||
|
||||
//
|
||||
string comment = "Force Close (" + ToString(count) + ") Positions At: " + ToFormatString(cTime) + "...";
|
||||
int closedPositionsCount = mTrader.Close(
|
||||
positions,
|
||||
comment //
|
||||
);
|
||||
result = IsValidSize(closedPositionsCount);
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
// Finish Positions and Clear Data ...
|
||||
for (int i = 0; i < ArraySize(positions); i++)
|
||||
{
|
||||
//
|
||||
XPosition iPosition = positions[i];
|
||||
Finish(
|
||||
iPosition.ticket,
|
||||
iPosition,
|
||||
comment //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
ResetProtections();
|
||||
|
||||
//
|
||||
string message = "Force Close (" + ToString(count) + ") Positions At: " +
|
||||
ToFormatString(cTime) + " Successfully ...";
|
||||
Alert(message);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Timing Actions ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user