This commit is contained in:
2025-01-15 22:09:21 +03:30
parent 341992374c
commit 9b307ae6e6
12 changed files with 3448 additions and 671 deletions
@@ -382,6 +382,8 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
/**
* Handle Tick Processing ...
*
* @param positions: XPosition instance Collection ...
*/
virtual void HandleTick()
{
@@ -450,6 +452,58 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
);
}
/**
* Check for any Guards ...
*
* @param guards: X121SMCGuard instance Collection ...
* @param positions: XPosition instance Collection ...
*
* @return ( virtual bool )
*/
virtual bool HandleGuard(
X121SMCGuard &guards[],
XPosition &positions[] //
)
{
//
bool result = false;
//
// Check State ...
if (IsDisabled())
{
return result;
}
//
// Check Signalling State ...
if (!AllowLong() && !AllowShort())
{
return result;
}
//
// Check Bar Tracker State ...
if (!mGuardBarTracker.CanProcessBar())
{
return result;
}
//
// Check For Guards ...
result = CheckGuard(
guards,
positions //
);
//
// Waits Until Next Candle if Current Tick has Guard ...
mGuardBarTracker.Waits();
//
return result;
}
/**
* Check For Signal ...
*
@@ -474,6 +528,25 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
return result;
}
/**
* Check for any Guard Actions ...
*
* @param guards: X121SMCGuard instance Collection ...
*
* @return ( virtual bool )
*/
virtual bool CheckGuard(
X121SMCGuard &guards[],
const XPosition &positions[] // Positions ...
)
{
//
bool result = false;
//
return result;
}
/**
* Detect SL Candidates based on Strategy and Conditions ...
*
@@ -518,8 +591,9 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
MqlTick mLastTick; // Last Issued Tick ...
//
XBarTracker mBarTracker; // Strategy Time Tracker ...
XCBarAnalyser mBarAnalyser; // Bar Analyser Instance
XBarTracker mBarTracker; // Strategy Bar Tracker ...
XBarTracker mGuardBarTracker; // Strategy Guard Bar Tracker ...
XCBarAnalyser mBarAnalyser; // Bar Analyser Instance
//
// Actions ...
@@ -867,6 +941,13 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
period //
);
//
// Initialize Guard Bar Tracker ...
mGuardBarTracker.Init(
symbol,
period //
);
//
}
@@ -3276,7 +3276,7 @@ class XC121SMCTradeHandler : public XCBaseAlert
//
// Handle Last Executed Signal ...
HandleSignalExecuted(signal);
HandleSignalExecuted(signal);
//
// Alert Executed Signal ...
@@ -3376,6 +3376,66 @@ class XC121SMCTradeHandler : public XCBaseAlert
return result;
}
/**
* Force Close Positions ...
*
* @return ( bool )
*/
bool ForceClose(
XPosition &positions[],
string comment,
string notificationMessage //
)
{
//
bool result = false;
//
int count = ArraySize(positions);
result = IsValidSize(count);
if (!result)
{
return result;
}
//
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();
//
if (IsValid(notificationMessage))
{
Alert(notificationMessage);
}
}
//
return result;
//
return result;
}
//
// Timing Actions ...