last ...
This commit is contained in:
@@ -1043,6 +1043,28 @@ class X121SCTradeHandler : public XSCBaseAlert
|
||||
mMaxDrawdownPercentForOpenTrades = value;
|
||||
}
|
||||
|
||||
//
|
||||
// Protector Start ...
|
||||
|
||||
//
|
||||
double ProtectorStartDistanceInPoint()
|
||||
{
|
||||
return mProtectorStartDistanceInPointl
|
||||
}
|
||||
|
||||
//
|
||||
void ProtectorStartDistanceInPoint(double value)
|
||||
{
|
||||
//
|
||||
if (value < 0)
|
||||
{
|
||||
value = 0;
|
||||
}
|
||||
|
||||
//
|
||||
mProtectorStartDistanceInPoint = value;
|
||||
}
|
||||
|
||||
//
|
||||
// Hedge Props ...
|
||||
|
||||
@@ -1849,6 +1871,56 @@ class X121SCTradeHandler : public XSCBaseAlert
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Loop Through Main Positions ...
|
||||
double requiredDistance = ProtectorStartDistanceInPoint();
|
||||
if (requiredDistance <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
int protectedPositions = 0;
|
||||
for (int i = 0; i < pPositionsCount; i++)
|
||||
{
|
||||
//
|
||||
// Check Position is Protectable or not ...
|
||||
XPosition iProtected = pPositions[i];
|
||||
|
||||
//
|
||||
XPosition iPosition = iProtected.main;
|
||||
|
||||
//
|
||||
double iSymbolPoint = GetPoints(iPosition.symbol);
|
||||
double iDistance = MathAbs(iPosition.profit) / iSymbolPoint;
|
||||
|
||||
//
|
||||
bool isDistancePassed = iDistance >= requiredDistance;
|
||||
bool isProtected = HandlePositionProtecting(iPosition);
|
||||
if (isProtected)
|
||||
{
|
||||
protectedPositions++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (protectedPositions > 0)
|
||||
{
|
||||
//
|
||||
// Renew Data ...
|
||||
Clean(pPositions);
|
||||
int pPositionsCount = GetPositions(
|
||||
pPositions //
|
||||
);
|
||||
|
||||
//
|
||||
// Validate Count ...
|
||||
if (!IsValidSize(pPositionsCount))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -2057,6 +2129,21 @@ class X121SCTradeHandler : public XSCBaseAlert
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Protecting Position ...
|
||||
*/
|
||||
bool HandlePositionProtecting(XPosition &position)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Here we Make Sure this Position has ...
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
@@ -2083,6 +2170,9 @@ class X121SCTradeHandler : public XSCBaseAlert
|
||||
bool mUseMaxAllowedTradesPerSymbol; // Use Max Allowed Trades Per Symbol
|
||||
double mMaxDrawdownPercentForOpenTrades; // Max Drawdown Percent for Open Trades
|
||||
|
||||
//
|
||||
double mProtectorStartDistanceInPoint; // Protector Start Distance in Point
|
||||
|
||||
//
|
||||
// Hedging Properties ...
|
||||
bool mAllowHedge; // Allow Protector to Hedge Positions
|
||||
|
||||
Reference in New Issue
Block a user