This commit is contained in:
2025-01-16 02:14:34 +03:30
parent 2a6a95c88b
commit 46c38f8f54
5 changed files with 462 additions and 5 deletions
+57 -1
View File
@@ -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 //
);
}
}
}
}
//