last ...
This commit is contained in:
@@ -2104,7 +2104,63 @@ class XC121SMCExpert : public XCBaseExpert
|
||||
if (canPartialClose)
|
||||
{
|
||||
//
|
||||
// TODO: Implement this ..
|
||||
XPosition iPosition;
|
||||
bool hasPosition = mTrader.GetPosition(
|
||||
iGuard.ticket,
|
||||
iPosition //
|
||||
);
|
||||
|
||||
//
|
||||
bool isLong = IsLong(iPosition.type);
|
||||
|
||||
//
|
||||
if (hasPosition)
|
||||
{
|
||||
//
|
||||
// Normalize Volume Multiplier ...
|
||||
double vMult = iGuard.volumeMultiplier;
|
||||
if (vMult > 0.5)
|
||||
{
|
||||
vMult = 0.5;
|
||||
}
|
||||
if (vMult < 0)
|
||||
{
|
||||
vMult = 0.5;
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate and Normalize Volume ...
|
||||
double volume = iPosition.volume * iGuard.volumeMultiplier;
|
||||
volume = NormalizeVolume(
|
||||
volume,
|
||||
iPosition.symbol //
|
||||
);
|
||||
|
||||
//
|
||||
string comment = "Guard Partially Closed: " + ToString(volume) + " ...";
|
||||
string message = "Guard Partially Closed " + (isLong ? "Long" : "Short") + ": " + ToString(volume) + " Successfully ...";
|
||||
bool isModified = mTrader.ClosePartial(
|
||||
iPosition.ticket,
|
||||
volume,
|
||||
comment //
|
||||
);
|
||||
if (isModified)
|
||||
{
|
||||
//
|
||||
mTradeHandler.Alert(message);
|
||||
|
||||
//
|
||||
if (volume == iPosition.volume)
|
||||
{
|
||||
//
|
||||
mTradeHandler.Finish(
|
||||
iPosition.ticket,
|
||||
iPosition,
|
||||
comment //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user