Try to Cleanup Memory for Fix Memory Leaks ...

This commit is contained in:
2025-01-17 02:19:22 +03:30
parent 46c38f8f54
commit 3c2de65f40
23 changed files with 842 additions and 382 deletions
@@ -44,7 +44,7 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
//
// Constructor(s) ...
void XCX121SMCBaseStrategy(
XCX121SMCBaseStrategy(
//
// Base ...
string _symbol, // Trading Symbol
@@ -61,7 +61,7 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
//
// Deconstructor ...
void ~XCX121SMCBaseStrategy()
~XCX121SMCBaseStrategy()
{
DeInit();
}
@@ -500,6 +500,9 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
// Waits Until Next Candle if Current Tick has Guard ...
mGuardBarTracker.Waits();
//
ArrayFree(positions);
//
return result;
}
@@ -863,6 +866,9 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
{
AddObjectIfNotExists(objects[i]);
}
//
ArrayFree(objects);
}
//
@@ -959,6 +965,10 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
//
delete mPOIDrawer;
//
ArrayFree(mTicks);
ArrayFree(mSignalEventHandlers);
//
Destroy();
}
@@ -1108,8 +1108,7 @@ class XC121SMCCycleHelper : public XCBase
{
//
delete mX121Helper;
//
delete mPOIDetector;
delete mBarAnalyser;
}
@@ -1628,6 +1628,14 @@ class XC121SMCTradeHandler : public XCBaseAlert
// Deconstructor ...
~XC121SMCTradeHandler()
{
//
ArrayFree(mData);
ArrayFree(mSymbolInfos);
ArrayFree(mLastExecutedSignals);
//
delete mDrawer;
//
delete mTrader;
delete mCollector;
@@ -3882,7 +3890,6 @@ class XC121SMCTradeHandler : public XCBaseAlert
double mHedgeingMinRequiredProfitPerVolumeStep; // Minimum Required Profit Per Volume Step for Hedging ...
//
XCBarAnalyser mBarAnalyser;
XCPOIDrawer *mDrawer;
//
@@ -55,6 +55,19 @@ class XC121SMCExpert : public XCBaseExpert
//
TOnX121SMCSignal OnSignalEventListener;
//
// Constructor(s) ...
XC121SMCExpert()
{
}
//
// Deconstructor(s) ...
~XC121SMCExpert()
{
ArrayFree(mStrategies);
}
//
// Getter(s) / Setter(s) ...
@@ -2306,6 +2319,9 @@ class XC121SMCExpert : public XCBaseExpert
}
}
}
//
Clean(guards);
}
//
+528 -58
View File
@@ -348,6 +348,8 @@ bool DetectX121SMCGuards(
bool isConsolidationZoneBreakedUp = false;
bool isConsolidationZoneBreakedDown = false;
bool hasConsolidationZone = x121SMCConsolidationZone.IsValid();
//
if (!hasConsolidationZone)
{
//
@@ -414,14 +416,16 @@ bool DetectX121SMCGuards(
// Decision ...
double decisionPriceZoneUpper = 0;
double decisionPriceZoneLower = 0;
bool isValidDecisionPriceZoneForPeak = false;
bool isValidDecisionPriceZoneForVale = false;
bool isDecisionPriceZoneBearish = false;
bool isDecisionPriceZoneBullish = false;
bool isDecisionPriceZoneValidForPeak = false;
bool isDecisionPriceZoneValidForVale = false;
bool isDecisionPriceZoneLowerRejected = false;
bool isDecisionPriceZoneUpperRejected = false;
bool isDecisionPriceZoneUpperBreakedUp = false;
bool isDecisionPriceZoneLowerBreakedDown = false;
bool hasDecisionPriceZone = x121SMCDecisionPriceZone.IsValid();
//
if (!hasDecisionPriceZone)
{
@@ -443,24 +447,28 @@ bool DetectX121SMCGuards(
decisionPriceZoneLower //
);
//
isDecisionPriceZoneBearish = x121SMCDecisionPriceZone.IsBearish();
isDecisionPriceZoneBullish = x121SMCDecisionPriceZone.IsBullish();
//
XOHCL iBar;
bool isInited = iBar.Init(
symbol,
decisionXConditions.period,
cIndex //
);
//
if (hasBoundary)
{
//
XOHCL iBar;
bool isInited = iBar.Init(
symbol,
decisionXConditions.period,
cIndex //
);
//
isValidDecisionPriceZoneForPeak =
isDecisionPriceZoneValidForPeak =
decisionXConditions.peaksBuffer[1] <= decisionPriceZoneUpper &&
decisionXConditions.peaksBuffer[1] >= decisionPriceZoneLower;
//
isValidDecisionPriceZoneForVale =
isDecisionPriceZoneValidForVale =
decisionXConditions.valesBuffer[1] <= decisionPriceZoneUpper &&
decisionXConditions.valesBuffer[1] >= decisionPriceZoneLower;
@@ -500,20 +508,55 @@ bool DetectX121SMCGuards(
iBar //
);
}
//
// Clear Price Zone ...
bool canReset =
//
(!isInited ||
!hasBoundary)
//
||
//
(isInited &&
hasBoundary &&
(iBar.high < decisionPriceZoneLower ||
iBar.low > decisionPriceZoneUpper))
//
;
if (canReset)
{
//
x121SMCDecisionPriceZone.Clean();
//
decisionPriceZoneUpper = 0;
decisionPriceZoneLower = 0;
isDecisionPriceZoneBearish = false;
isDecisionPriceZoneBullish = false;
isDecisionPriceZoneValidForPeak = false;
isDecisionPriceZoneValidForVale = false;
isDecisionPriceZoneLowerRejected = false;
isDecisionPriceZoneUpperRejected = false;
isDecisionPriceZoneUpperBreakedUp = false;
isDecisionPriceZoneLowerBreakedDown = false;
}
}
//
// Analyse ...
double analysePriceZoneUpper = 0;
double analysePriceZoneLower = 0;
bool isValidAnalysePriceZoneForPeak = false;
bool isValidAnalysePriceZoneForVale = false;
bool isAnalysePriceZoneBearish = false;
bool isAnalysePriceZoneBullish = false;
bool isAnalysePriceZoneValidForPeak = false;
bool isAnalysePriceZoneValidForVale = false;
bool isAnalysePriceZoneLowerRejected = false;
bool isAnalysePriceZoneUpperRejected = false;
bool isAnalysePriceZoneUpperBreakedUp = false;
bool isAnalysePriceZoneLowerBreakedDown = false;
bool hasAnalysePriceZone = x121SMCAnalysePriceZone.IsValid();
//
if (!hasAnalysePriceZone)
{
@@ -535,24 +578,28 @@ bool DetectX121SMCGuards(
analysePriceZoneLower //
);
//
isAnalysePriceZoneBearish = x121SMCAnalysePriceZone.IsBearish();
isAnalysePriceZoneBullish = x121SMCAnalysePriceZone.IsBullish();
//
XOHCL iBar;
bool isInited = iBar.Init(
symbol,
analyseXConditions.period,
cIndex //
);
//
if (hasBoundary)
{
//
XOHCL iBar;
bool isInited = iBar.Init(
symbol,
analyseXConditions.period,
cIndex //
);
//
isValidAnalysePriceZoneForPeak =
isAnalysePriceZoneValidForPeak =
analyseXConditions.peaksBuffer[1] <= analysePriceZoneUpper &&
analyseXConditions.peaksBuffer[1] >= analysePriceZoneLower;
//
isValidAnalysePriceZoneForVale =
isAnalysePriceZoneValidForVale =
analyseXConditions.valesBuffer[1] <= analysePriceZoneUpper &&
analyseXConditions.valesBuffer[1] >= analysePriceZoneLower;
@@ -592,20 +639,55 @@ bool DetectX121SMCGuards(
iBar //
);
}
//
// Clear Price Zone ...
bool canReset =
//
(!isInited ||
!hasBoundary)
//
||
//
(isInited &&
hasBoundary &&
(iBar.high < analysePriceZoneLower ||
iBar.low > analysePriceZoneUpper))
//
;
if (canReset)
{
//
x121SMCAnalysePriceZone.Clean();
//
analysePriceZoneUpper = 0;
analysePriceZoneLower = 0;
isAnalysePriceZoneBearish = false;
isAnalysePriceZoneBullish = false;
isAnalysePriceZoneValidForPeak = false;
isAnalysePriceZoneValidForVale = false;
isAnalysePriceZoneLowerRejected = false;
isAnalysePriceZoneUpperRejected = false;
isAnalysePriceZoneUpperBreakedUp = false;
isAnalysePriceZoneLowerBreakedDown = false;
}
}
//
// Verification ...
double verificationPriceZoneUpper = 0;
double verificationPriceZoneLower = 0;
bool isValidVerificationPriceZoneForPeak = false;
bool isValidVerificationPriceZoneForVale = false;
bool isVerificationPriceZoneBearish = false;
bool isVerificationPriceZoneBullish = false;
bool isVerificationPriceZoneValidForPeak = false;
bool isVerificationPriceZoneValidForVale = false;
bool isVerificationPriceZoneLowerRejected = false;
bool isVerificationPriceZoneUpperRejected = false;
bool isVerificationPriceZoneUpperBreakedUp = false;
bool isVerificationPriceZoneLowerBreakedDown = false;
bool hasVerificationPriceZone = x121SMCVerificationPriceZone.IsValid();
//
if (!hasVerificationPriceZone)
{
@@ -627,24 +709,28 @@ bool DetectX121SMCGuards(
verificationPriceZoneLower //
);
//
isVerificationPriceZoneBearish = x121SMCVerificationPriceZone.IsBearish();
isVerificationPriceZoneBullish = x121SMCVerificationPriceZone.IsBullish();
//
XOHCL iBar;
bool isInited = iBar.Init(
symbol,
verificationXConditions.period,
cIndex //
);
//
if (hasBoundary)
{
//
XOHCL iBar;
bool isInited = iBar.Init(
symbol,
verificationXConditions.period,
cIndex //
);
//
isValidVerificationPriceZoneForPeak =
isVerificationPriceZoneValidForPeak =
verificationXConditions.peaksBuffer[1] <= verificationPriceZoneUpper &&
verificationXConditions.peaksBuffer[1] >= verificationPriceZoneLower;
//
isValidVerificationPriceZoneForVale =
isVerificationPriceZoneValidForVale =
verificationXConditions.valesBuffer[1] <= verificationPriceZoneUpper &&
verificationXConditions.valesBuffer[1] >= verificationPriceZoneLower;
@@ -684,6 +770,39 @@ bool DetectX121SMCGuards(
iBar //
);
}
//
// Clear Price Zone ...
bool canReset =
//
(!isInited ||
!hasBoundary)
//
||
//
(isInited &&
hasBoundary &&
(iBar.high < verificationPriceZoneLower ||
iBar.low > verificationPriceZoneUpper))
//
;
if (canReset)
{
//
x121SMCVerificationPriceZone.Clean();
//
verificationPriceZoneUpper = 0;
verificationPriceZoneLower = 0;
isVerificationPriceZoneBearish = false;
isVerificationPriceZoneBullish = false;
isVerificationPriceZoneValidForPeak = false;
isVerificationPriceZoneValidForVale = false;
isVerificationPriceZoneLowerRejected = false;
isVerificationPriceZoneUpperRejected = false;
isVerificationPriceZoneUpperBreakedUp = false;
isVerificationPriceZoneLowerBreakedDown = false;
}
}
//
@@ -691,7 +810,87 @@ bool DetectX121SMCGuards(
//
// Close ...
// TODO: Implement Force Close Position ...
//
double tpCloseDiff = (15 * points);
for (int i = 0; i < count; i++)
{
//
XPosition iPosition = ownPositions[i];
//
// Position Must be In Profit ...
if (iPosition.profit <= 0)
{
continue;
}
//
bool isPricePassed = MathAbs(iPosition.tp - iPosition.price) <= tpCloseDiff;
if (!isPricePassed)
{
continue;
}
//
bool isLong = IsLong(iPosition.type);
//
bool iHasGuard =
//
isLong
? //
(hasDecisionPriceZone &&
isDecisionPriceZoneBearish &&
isDecisionPriceZoneValidForPeak)
//
||
//
(hasAnalysePriceZone &&
isAnalysePriceZoneBearish &&
isAnalysePriceZoneValidForPeak)
//
||
//
(hasVerificationPriceZone &&
isVerificationPriceZoneBearish &&
isVerificationPriceZoneValidForPeak)
: //
(hasDecisionPriceZone &&
isDecisionPriceZoneBullish &&
isDecisionPriceZoneValidForVale)
//
||
//
(hasAnalysePriceZone &&
isAnalysePriceZoneBullish &&
isAnalysePriceZoneValidForVale)
//
||
//
(hasVerificationPriceZone &&
isVerificationPriceZoneBullish &&
isVerificationPriceZoneValidForVale)
//
;
if (iHasGuard)
{
//
X121SMCGuard iGuard;
//
iGuard.time = cTime;
iGuard.symbol = symbol;
iGuard.provider = provider;
iGuard.action = X_121_SMC_GUARD_ACTION_CLOSE;
//
AddGuard(
iGuard,
guards //
);
}
}
//
// Close All ...
@@ -699,13 +898,15 @@ bool DetectX121SMCGuards(
//
MqlDateTime mDate;
bool hasDate = TimeCurrent(mDate);
if (hasDate) {
if (hasDate)
{
//
ENUM_X_WEEK_DAYS dayOfWeek = GetDayOfWeek();
//
bool isWeekend = dayOfWeek == X_WEEK_DAY_FRIDAY;
if (isWeekend && mDate.hour == 23 && mDate.min == 30) {
if (isWeekend && mDate.hour == 23 && mDate.min == 30)
{
//
X121SMCGuard guard;
@@ -720,7 +921,7 @@ bool DetectX121SMCGuards(
guard,
guards //
);
}
}
}
//
@@ -797,6 +998,20 @@ bool DetectX121SMCGuards(
hasTriggerBearishTrend ||
!hasDecisionBullishTrend
//
// (hasAnalysePriceZone &&
// isAnalysePriceZoneBearish &&
// isAnalysePriceZoneValidForPeak &&
// (isAnalysePriceZoneUpperRejected ||
// isAnalysePriceZoneLowerBreakedDown))
// //
// ||
// //
// (hasVerificationPriceZone &&
// isVerificationPriceZoneBearish &&
// isVerificationPriceZoneValidForPeak &&
// (isVerificationPriceZoneUpperRejected ||
// isVerificationPriceZoneLowerBreakedDown))
//
;
//
@@ -839,6 +1054,20 @@ bool DetectX121SMCGuards(
hasTriggerBullishTrend ||
!hasDecisionBearishTrend
//
// (hasAnalysePriceZone &&
// isAnalysePriceZoneBullish &&
// isAnalysePriceZoneValidForVale &&
// (isAnalysePriceZoneLowerRejected ||
// isAnalysePriceZoneUpperBreakedUp))
// //
// ||
// //
// (hasVerificationPriceZone &&
// isVerificationPriceZoneBullish &&
// isVerificationPriceZoneValidForVale &&
// (isVerificationPriceZoneLowerRejected ||
// isVerificationPriceZoneUpperBreakedUp))
//
;
//
@@ -879,14 +1108,54 @@ bool DetectX121SMCGuards(
if (hasLongs)
{
//
bool hasGuard =
//
bool hasConsolidationGuard =
(hasConsolidationZone &&
isConsolidationZoneBreaked &&
isConsolidationZoneBreakedUp)
isConsolidationZoneBreakedUp);
//
bool hasDecisionPriceZoneGuard =
(hasDecisionPriceZone &&
isDecisionPriceZoneBullish &&
isDecisionPriceZoneValidForVale &&
isDecisionPriceZoneUpperBreakedUp);
//
bool hasAnalysePriceZoneGuard =
(hasAnalysePriceZone &&
isAnalysePriceZoneBullish &&
isAnalysePriceZoneValidForVale &&
isAnalysePriceZoneUpperBreakedUp);
//
bool hasVerificationPriceZoneGuard =
(hasVerificationPriceZone &&
isVerificationPriceZoneBullish &&
isVerificationPriceZoneValidForVale &&
isVerificationPriceZoneUpperBreakedUp);
//
bool hasGuard =
//
hasConsolidationGuard ||
hasDecisionPriceZoneGuard ||
hasAnalysePriceZoneGuard ||
hasVerificationPriceZoneGuard
//
;
//
double guardStop =
hasConsolidationGuard
? consolidationZoneLower
: hasDecisionPriceZoneGuard
? decisionPriceZoneLower
: hasAnalysePriceZoneGuard
? analysePriceZoneLower
: hasVerificationPriceZoneGuard
? verificationPriceZoneLower
: 0;
//
if (hasGuard)
{
@@ -905,14 +1174,14 @@ bool DetectX121SMCGuards(
//
// Price Must Greater than Zone Lower ...
if (iPosition.price < consolidationZoneLower)
if (iPosition.price < guardStop)
{
continue;
}
//
// Position Entry Must Lesser than Zone Lower ...
if (iPosition.entry > consolidationZoneLower)
if (iPosition.entry > guardStop)
{
continue;
}
@@ -920,7 +1189,7 @@ bool DetectX121SMCGuards(
//
// Position SL must be Zero or Lesser than Zone Lower ...
if (iPosition.sl != 0 &&
iPosition.sl > consolidationZoneLower)
iPosition.sl > guardStop)
{
continue;
}
@@ -938,7 +1207,7 @@ bool DetectX121SMCGuards(
iGuard.ticket = iPosition.ticket;
//
iGuard.sl = consolidationZoneLower;
iGuard.sl = guardStop;
//
AddGuard(
@@ -953,14 +1222,54 @@ bool DetectX121SMCGuards(
if (hasShorts)
{
//
bool hasGuard =
//
bool hasConsolidationGuard =
(hasConsolidationZone &&
isConsolidationZoneBreaked &&
isConsolidationZoneBreakedDown)
isConsolidationZoneBreakedDown);
//
bool hasDecisionPriceZoneGuard =
(hasDecisionPriceZone &&
isDecisionPriceZoneBearish &&
isDecisionPriceZoneValidForPeak &&
isDecisionPriceZoneLowerBreakedDown);
//
bool hasAnalysePriceZoneGuard =
(hasAnalysePriceZone &&
isAnalysePriceZoneBearish &&
isAnalysePriceZoneValidForPeak &&
isAnalysePriceZoneLowerBreakedDown);
//
bool hasVerificationPriceZoneGuard =
(hasVerificationPriceZone &&
isVerificationPriceZoneBearish &&
isVerificationPriceZoneValidForPeak &&
isVerificationPriceZoneLowerBreakedDown);
//
bool hasGuard =
//
hasConsolidationGuard ||
hasDecisionPriceZoneGuard ||
hasAnalysePriceZoneGuard ||
hasVerificationPriceZoneGuard
//
;
//
double guardStop =
hasConsolidationGuard
? consolidationZoneUpper
: hasDecisionPriceZoneGuard
? decisionPriceZoneUpper
: hasAnalysePriceZoneGuard
? analysePriceZoneUpper
: hasVerificationPriceZoneGuard
? verificationPriceZoneUpper
: 0;
//
if (hasGuard)
{
@@ -979,14 +1288,14 @@ bool DetectX121SMCGuards(
//
// Price Must Lesser than Zone Upper ...
if (iPosition.price > consolidationZoneUpper)
if (iPosition.price > guardStop)
{
continue;
}
//
// Position Entry Must Greater than Zone Upper ...
if (iPosition.entry < consolidationZoneUpper)
if (iPosition.entry < guardStop)
{
continue;
}
@@ -994,7 +1303,7 @@ bool DetectX121SMCGuards(
//
// Position SL must be Zero or Greater than Zone Upper ...
if (iPosition.sl != 0 &&
iPosition.sl < consolidationZoneUpper)
iPosition.sl < guardStop)
{
continue;
}
@@ -1012,7 +1321,7 @@ bool DetectX121SMCGuards(
iGuard.ticket = iPosition.ticket;
//
iGuard.sl = consolidationZoneUpper;
iGuard.sl = guardStop;
//
AddGuard(
@@ -1025,22 +1334,183 @@ bool DetectX121SMCGuards(
//
// Trail Target ...
// TODO: Implement Target Trail ...
//
if (hasLongs)
{
//
bool hasAnalyseGuard =
//
(hasAnalysePriceZone &&
isAnalysePriceZoneValidForPeak &&
isAnalysePriceZoneUpperRejected)
//
;
//
bool hasVerificationGuard =
//
(hasVerificationPriceZone &&
isVerificationPriceZoneValidForPeak &&
isVerificationPriceZoneUpperRejected)
//
;
//
bool hasGuard =
//
hasAnalyseGuard ||
hasVerificationGuard
//
;
//
double guardTP =
hasAnalyseGuard
? analysePriceZoneUpper
: hasVerificationGuard
? verificationPriceZoneUpper
: 0;
//
if (hasGuard)
{
//
for (int i = 0; i < longsCount; i++)
{
//
XPosition iPosition = ownLongPositions[i];
//
// Position Must Be In Profit ...
if (iPosition.profit <= 0)
{
continue;
}
//
X121SMCGuard iGuard;
//
iGuard.time = cTime;
iGuard.symbol = symbol;
iGuard.provider = provider;
iGuard.action = X_121_SMC_GUARD_ACTION_TRAIL_TARGET;
//
iGuard.ticket = iPosition.ticket;
//
iGuard.tp = guardTP;
//
AddGuard(
iGuard,
guards //
);
}
}
}
//
if (hasShorts)
{
//
bool hasAnalyseGuard =
//
(hasAnalysePriceZone &&
isAnalysePriceZoneValidForVale &&
isAnalysePriceZoneLowerRejected)
//
;
//
bool hasVerificationGuard =
//
(hasVerificationPriceZone &&
isVerificationPriceZoneValidForVale &&
isVerificationPriceZoneLowerRejected)
//
;
//
bool hasGuard =
//
hasAnalyseGuard ||
hasVerificationGuard
//
;
//
double guardTP =
hasAnalyseGuard
? analysePriceZoneLower
: hasVerificationGuard
? verificationPriceZoneLower
: 0;
//
if (hasGuard)
{
//
for (int i = 0; i < shortsCount; i++)
{
//
XPosition iPosition = ownShortPositions[i];
//
// Position Must Be In Profit ...
if (iPosition.profit <= 0)
{
continue;
}
//
X121SMCGuard iGuard;
//
iGuard.time = cTime;
iGuard.symbol = symbol;
iGuard.provider = provider;
iGuard.action = X_121_SMC_GUARD_ACTION_TRAIL_TARGET;
//
iGuard.ticket = iPosition.ticket;
//
iGuard.tp = guardTP;
//
AddGuard(
iGuard,
guards //
);
}
}
}
//
// Hedge ...
// TODO: Implement Hedge ...
//
// Release Arrays ...
ArrayFree(ownPositions);
ArrayFree(ownLongPositions);
ArrayFree(ownShortPositions);
ArrayFree(triggerPoiEvents);
ArrayFree(triggerCycleEvents);
ArrayFree(decisionPoiEvents);
ArrayFree(decisionCycleEvents);
ArrayFree(analysePoiEvents);
ArrayFree(analyseCycleEvents);
ArrayFree(verificationPoiEvents);
ArrayFree(verificationCycleEvents);
ArrayFree(consolidationPoiEvents);
ArrayFree(consolidationCycleEvents);
ArrayFree(visionPoiEvents);
ArrayFree(visionCycleEvents);
//
count = ArraySize(guards);
result = IsValidSize(count);
@@ -823,6 +823,23 @@ bool DetectX121SMCXPZSiganlSetup(
isBearish;
if (!result)
{
//
// Cleanup Arrays ...
ArrayFree(triggerPoiEvents);
ArrayFree(triggerCycleEvents);
ArrayFree(decisionPoiEvents);
ArrayFree(decisionCycleEvents);
ArrayFree(analysePoiEvents);
ArrayFree(analyseCycleEvents);
ArrayFree(verificationPoiEvents);
ArrayFree(verificationCycleEvents);
ArrayFree(consolidationPoiEvents);
ArrayFree(consolidationCycleEvents);
ArrayFree(visionPoiEvents);
ArrayFree(visionCycleEvents);
//
return result;
}
@@ -833,6 +850,21 @@ bool DetectX121SMCXPZSiganlSetup(
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
// Cleanup Arrays ...
ArrayFree(triggerPoiEvents);
ArrayFree(triggerCycleEvents);
ArrayFree(decisionPoiEvents);
ArrayFree(decisionCycleEvents);
ArrayFree(analysePoiEvents);
ArrayFree(analyseCycleEvents);
ArrayFree(verificationPoiEvents);
ArrayFree(verificationCycleEvents);
ArrayFree(consolidationPoiEvents);
ArrayFree(consolidationCycleEvents);
ArrayFree(visionPoiEvents);
ArrayFree(visionCycleEvents);
//
return result;
}
@@ -1193,6 +1225,21 @@ bool DetectX121SMCXPZSiganlTrigger(
conditions.Clean();
}
//
// Cleanup Arrays ...
ArrayFree(triggerPoiEvents);
ArrayFree(triggerCycleEvents);
ArrayFree(decisionPoiEvents);
ArrayFree(decisionCycleEvents);
ArrayFree(analysePoiEvents);
ArrayFree(analyseCycleEvents);
ArrayFree(verificationPoiEvents);
ArrayFree(verificationCycleEvents);
ArrayFree(consolidationPoiEvents);
ArrayFree(consolidationCycleEvents);
ArrayFree(visionPoiEvents);
ArrayFree(visionCycleEvents);
//
return result;
}
@@ -1488,6 +1535,21 @@ bool DetectX121SMCXPZSiganlTrigger(
? X_POSITION_TYPE_LONG
: X_POSITION_TYPE_SHORT;
//
// Cleanup Arrays ...
ArrayFree(triggerPoiEvents);
ArrayFree(triggerCycleEvents);
ArrayFree(decisionPoiEvents);
ArrayFree(decisionCycleEvents);
ArrayFree(analysePoiEvents);
ArrayFree(analyseCycleEvents);
ArrayFree(verificationPoiEvents);
ArrayFree(verificationCycleEvents);
ArrayFree(consolidationPoiEvents);
ArrayFree(consolidationCycleEvents);
ArrayFree(visionPoiEvents);
ArrayFree(visionCycleEvents);
//
return result;
}
@@ -883,6 +883,22 @@ bool DetectX121SMCXSTRPVSiganlSetup(
isBearish;
if (!result)
{
//
// Cleanup Arrays ...
ArrayFree(triggerPoiEvents);
ArrayFree(triggerCycleEvents);
ArrayFree(decisionPoiEvents);
ArrayFree(decisionCycleEvents);
ArrayFree(analysePoiEvents);
ArrayFree(analyseCycleEvents);
ArrayFree(verificationPoiEvents);
ArrayFree(verificationCycleEvents);
ArrayFree(consolidationPoiEvents);
ArrayFree(consolidationCycleEvents);
ArrayFree(visionPoiEvents);
ArrayFree(visionCycleEvents);
//
return result;
}
@@ -893,6 +909,21 @@ bool DetectX121SMCXSTRPVSiganlSetup(
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
// Cleanup Arrays ...
ArrayFree(triggerPoiEvents);
ArrayFree(triggerCycleEvents);
ArrayFree(decisionPoiEvents);
ArrayFree(decisionCycleEvents);
ArrayFree(analysePoiEvents);
ArrayFree(analyseCycleEvents);
ArrayFree(verificationPoiEvents);
ArrayFree(verificationCycleEvents);
ArrayFree(consolidationPoiEvents);
ArrayFree(consolidationCycleEvents);
ArrayFree(visionPoiEvents);
ArrayFree(visionCycleEvents);
//
return result;
}
@@ -1253,6 +1284,21 @@ bool DetectX121SMCXSTRPVSiganlTrigger(
conditions.Clean();
}
//
// Cleanup Arrays ...
ArrayFree(triggerPoiEvents);
ArrayFree(triggerCycleEvents);
ArrayFree(decisionPoiEvents);
ArrayFree(decisionCycleEvents);
ArrayFree(analysePoiEvents);
ArrayFree(analyseCycleEvents);
ArrayFree(verificationPoiEvents);
ArrayFree(verificationCycleEvents);
ArrayFree(consolidationPoiEvents);
ArrayFree(consolidationCycleEvents);
ArrayFree(visionPoiEvents);
ArrayFree(visionCycleEvents);
//
return result;
}
@@ -1548,6 +1594,21 @@ bool DetectX121SMCXSTRPVSiganlTrigger(
? X_POSITION_TYPE_LONG
: X_POSITION_TYPE_SHORT;
//
// Cleanup Arrays ...
ArrayFree(triggerPoiEvents);
ArrayFree(triggerCycleEvents);
ArrayFree(decisionPoiEvents);
ArrayFree(decisionCycleEvents);
ArrayFree(analysePoiEvents);
ArrayFree(analyseCycleEvents);
ArrayFree(verificationPoiEvents);
ArrayFree(verificationCycleEvents);
ArrayFree(consolidationPoiEvents);
ArrayFree(consolidationCycleEvents);
ArrayFree(visionPoiEvents);
ArrayFree(visionCycleEvents);
//
return result;
}
+4 -135
View File
@@ -27,7 +27,6 @@
#include "../Classes/x-121.smc.market.cycle.helper.class.mq5"
//
#include "../Signals/x-121.smc.test.signal.lib.mq5"
#include "../Signals/x-121.smc.xpz.signal.lib.mq5"
#include "../Signals/x-121.smc.xstrpv.signal.lib.mq5"
@@ -43,7 +42,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
public:
//
// Props ...
bool useTestSignal;
bool useXPZSignal;
bool useXSTRPVSignal;
@@ -64,6 +62,10 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// Deconstructur ...
void ~XCX121SMCStrategy()
{
//
Destroy();
ArrayFree(mXPZConditionsCollection);
ArrayFree(mXSTRPVConditionsCollection);
}
//
@@ -188,19 +190,9 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
bool hasSignal = false;
//
bool hasTestSignal = false;
bool hasXPZSignal = false;
bool hasXSTRPVSignal = false;
//
// Test Signal ...
if (useTestSignal && !hasSignal)
{
//
hasTestSignal = DetectTestSignal(conditions);
hasSignal = hasTestSignal;
}
//
// XOBGPV Signal ...
if (useXPZSignal && !hasSignal)
@@ -374,12 +366,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
return result;
}
//
// XTEST Guard Detection ...
if (useTestSignal)
{
}
//
// XSTRPV Guard Detection ...
if (useXSTRPVSignal)
@@ -452,122 +438,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
// Signalling Functions ...
//
// Test Signal ...
X121SMCStrategyTestSignalConditions mTestConditions;
bool DetectTestSignal(
X121SMCStrategyConditions &conditions //
)
{
//
bool result = false;
//
bool isBullish = false;
bool isBearish = false;
//
string symbol = GetSymbol();
ENUM_TIMEFRAMES period = GetPeriod();
//
datetime cTime = TimeCurrent();
//
ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_XTEST;
string providerStr = ToString(provider);
//
// Detect Setup Conditions ...
datetime setupTime = mTestConditions.setupTime;
bool isSetuped = mTestConditions.IsSetuped();
ENUM_X_DIRECTION setupDir = mTestConditions.dir;
if (!isSetuped)
{
//
// Detect Signal Setup ...
isSetuped = DetectX121SMCTestSiganlSetup(
symbol,
period,
mTestConditions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
setupDir = mTestConditions.dir;
setupTime = mTestConditions.setupTime;
}
//
result = isSetuped;
if (!result)
{
return result;
}
//
// Detect Trigger Conditions ...
bool canTrigger = mTestConditions.CanTrigger();
datetime triggerTime = mTestConditions.triggerTime;
if (!canTrigger)
{
//
// Detect Signal Trigger ...
canTrigger = DetectX121SMCTestSiganlTrigger(
mTestConditions,
symbol,
period,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
result = canTrigger;
if (!result)
{
return result;
}
//
triggerTime = mTestConditions.triggerTime;
}
//
// Check Signal Direction ...
//
isBullish = IsBullish(setupDir);
isBearish = IsBearish(setupDir);
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
//
// Issues Signal on Conditions ...
conditions.signalDir = setupDir;
conditions.provider = providerStr;
conditions.sl = mTestConditions.sl;
conditions.target = mTestConditions.target;
//
mTestConditions.Clean();
//
return result;
}
//
// XSTRPV Signal ...
bool DetectXSTRPVSignal(
@@ -1035,7 +905,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
void InitialHelpers()
{
//
useTestSignal = false;
useXPZSignal = true;
useXSTRPVSignal = true;