Add Support for Cleanup Unused Saved Changes in Cycle Helper class for prevent Memory Issues ...

This commit is contained in:
2024-12-29 08:30:23 +03:30
parent ecdba76c3f
commit e831ce8a91
2 changed files with 225 additions and 70 deletions
@@ -2163,6 +2163,9 @@ class XC121SMCCycleHelper : public XCBase
//
isInited = AddSarChange(sarChanged);
//
if (isInited)
{
//
Add(
SAR_CHANGE_DETECTED,
@@ -2170,6 +2173,7 @@ class XC121SMCCycleHelper : public XCBase
);
}
}
}
//
// Detect Peaks Changes ...
@@ -2208,6 +2212,9 @@ class XC121SMCCycleHelper : public XCBase
//
isInited = AddPeaksChange(peaksChanged);
//
if (isInited)
{
//
Add(
NEW_PEAK_DETECTED,
@@ -2215,6 +2222,7 @@ class XC121SMCCycleHelper : public XCBase
);
}
}
}
//
// Detect Vales Changes ...
@@ -2253,6 +2261,9 @@ class XC121SMCCycleHelper : public XCBase
//
isInited = AddValesChange(valesChanged);
//
if (isInited)
{
//
Add(
NEW_VALE_DETECTED,
@@ -2260,6 +2271,7 @@ class XC121SMCCycleHelper : public XCBase
);
}
}
}
//
// VWap Direction Change ...
@@ -2350,6 +2362,9 @@ class XC121SMCCycleHelper : public XCBase
//
isInited = AddVWapOrderChange(vwapOrderChanged);
//
if (isInited)
{
//
Add(
VWAP_ORDER_CHANGE_ETECTED,
@@ -2357,6 +2372,7 @@ class XC121SMCCycleHelper : public XCBase
);
}
}
}
//
// States Changed ...
@@ -2445,6 +2461,9 @@ class XC121SMCCycleHelper : public XCBase
//
isInited = AddVWapStateChange(vwapStateChanged);
//
if (isInited)
{
//
Add(
VWAP_STATE_CHANGE_DETCTED,
@@ -2452,6 +2471,7 @@ class XC121SMCCycleHelper : public XCBase
);
}
}
}
//
// Detect Consolidations ...
@@ -2499,11 +2519,9 @@ class XC121SMCCycleHelper : public XCBase
{
//
// Add Active to List ...
AddRef(
mActioveConsolidationZone,
mConsolidationZones //
);
bool isInited = AddConsolidationZone(mActioveConsolidationZone);
if (isInited)
{
//
// Clean Active Zone ...
mActioveConsolidationZone.Clean();
@@ -2516,6 +2534,7 @@ class XC121SMCCycleHelper : public XCBase
}
}
}
}
//
// Check Valid Peaks and Vales ...
@@ -2575,11 +2594,9 @@ class XC121SMCCycleHelper : public XCBase
pivotPoint.repetition = repetition;
//
AddRef(
pivotPoint,
mPivotPoints //
);
bool isInited = AddPivotPoint(pivotPoint);
if (isInited)
{
//
Add(
PIVOT_POINT_DETECTED,
@@ -2588,6 +2605,7 @@ class XC121SMCCycleHelper : public XCBase
}
}
}
}
//
// Calculate XPVPivot ...
@@ -2634,11 +2652,9 @@ class XC121SMCCycleHelper : public XCBase
if (mActivePeakPivot.repetition >= pvValidation)
{
//
AddRef(
mActivePeakPivot,
mPivots //
);
bool isInited = AddPivot(mActivePeakPivot);
if (isInited)
{
//
Add(
PEAK_PIVOT_ENDED,
@@ -2648,6 +2664,7 @@ class XC121SMCCycleHelper : public XCBase
//
mActivePeakPivot.Clean();
}
}
else
{
//
@@ -2705,11 +2722,9 @@ class XC121SMCCycleHelper : public XCBase
if (mActiveValePivot.repetition >= pvValidation)
{
//
AddRef(
mActiveValePivot,
mPivots //
);
bool isInited = AddPivot(mActiveValePivot);
if (isInited)
{
//
Add(
VALE_PIVOT_ENDED,
@@ -2719,6 +2734,7 @@ class XC121SMCCycleHelper : public XCBase
//
mActiveValePivot.Clean();
}
}
else
{
//
@@ -3368,5 +3384,143 @@ class XC121SMCCycleHelper : public XCBase
return result;
}
/**
* Add Specified Consolidation Zone to List ...
*
* @param zone: XConsolidationZone instance Reference ...
*
* @return ( bool )
*/
bool AddConsolidationZone(XConsolidationZone &zone)
{
//
bool result = false;
//
result = zone.IsValid();
//
int beforeCount = CountConsolidationZones();
//
AddRef(
zone,
mConsolidationZones //
);
//
int afterCount = CountConsolidationZones();
//
result = afterCount == beforeCount + 1;
if (result)
{
//
// Cleaning Up Unused Items ...
int maxAllowed = MaxAllowedSavedChanges();
CleanupArray(
mConsolidationZones,
maxAllowed //
);
}
//
return result;
}
/**
* Add Specified Pivot Point to List ...
*
* @param pivotPoint: XPVPivotPoint instance Reference ...
*
* @return ( bool )
*/
bool AddPivotPoint(XPVPivotPoint &pivotPoint)
{
//
bool result = false;
//
if (!pivotPoint.IsValid())
{
return result;
}
//
int beforeCount = CountPivotPoints();
//
AddRef(
pivotPoint,
mPivotPoints //
);
//
int afterCount = CountPivotPoints();
//
result = afterCount == beforeCount + 1;
if (result)
{
//
// Cleaning Up Unused Items ...
int maxAllowed = MaxAllowedSavedChanges();
CleanupArray(
mPivotPoints,
maxAllowed //
);
}
//
return result;
}
/**
* Add Specified Pivot to List ...
*
* @param pivot: XPVPivot instance Reference ...
*
* @return ( bool )
*/
bool AddPivot(XPVPivot &pivot)
{
//
bool result = false;
//
if (!pivot.IsValid())
{
return result;
}
//
int beforeCount = CountPivots();
//
AddRef(
pivot,
mPivots //
);
//
int afterCount = CountPivots();
//
result = afterCount == beforeCount + 1;
if (result)
{
//
// Cleaning Up Unused Items ...
int maxAllowed = MaxAllowedSavedChanges();
CleanupArray(
mPivots,
maxAllowed //
);
}
//
return result;
}
//
};
@@ -588,8 +588,9 @@ bool DetectX121SMCXTWPVSiganlSetup(
//
isBearish =
//
bearishConditions1 ||
bearishConditions2
bearishConditions1
// ||
// bearishConditions2
//
;