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
@@ -2164,10 +2164,14 @@ class XC121SMCCycleHelper : public XCBase
isInited = AddSarChange(sarChanged); isInited = AddSarChange(sarChanged);
// //
Add( if (isInited)
SAR_CHANGE_DETECTED, {
events // //
); Add(
SAR_CHANGE_DETECTED,
events //
);
}
} }
} }
@@ -2209,10 +2213,14 @@ class XC121SMCCycleHelper : public XCBase
isInited = AddPeaksChange(peaksChanged); isInited = AddPeaksChange(peaksChanged);
// //
Add( if (isInited)
NEW_PEAK_DETECTED, {
events // //
); Add(
NEW_PEAK_DETECTED,
events //
);
}
} }
} }
@@ -2254,10 +2262,14 @@ class XC121SMCCycleHelper : public XCBase
isInited = AddValesChange(valesChanged); isInited = AddValesChange(valesChanged);
// //
Add( if (isInited)
NEW_VALE_DETECTED, {
events // //
); Add(
NEW_VALE_DETECTED,
events //
);
}
} }
} }
@@ -2351,10 +2363,14 @@ class XC121SMCCycleHelper : public XCBase
isInited = AddVWapOrderChange(vwapOrderChanged); isInited = AddVWapOrderChange(vwapOrderChanged);
// //
Add( if (isInited)
VWAP_ORDER_CHANGE_ETECTED, {
events // //
); Add(
VWAP_ORDER_CHANGE_ETECTED,
events //
);
}
} }
} }
@@ -2446,10 +2462,14 @@ class XC121SMCCycleHelper : public XCBase
isInited = AddVWapStateChange(vwapStateChanged); isInited = AddVWapStateChange(vwapStateChanged);
// //
Add( if (isInited)
VWAP_STATE_CHANGE_DETCTED, {
events // //
); Add(
VWAP_STATE_CHANGE_DETCTED,
events //
);
}
} }
} }
@@ -2499,20 +2519,19 @@ class XC121SMCCycleHelper : public XCBase
{ {
// //
// Add Active to List ... // Add Active to List ...
AddRef( bool isInited = AddConsolidationZone(mActioveConsolidationZone);
mActioveConsolidationZone, if (isInited)
mConsolidationZones // {
); //
// Clean Active Zone ...
mActioveConsolidationZone.Clean();
// //
// Clean Active Zone ... Add(
mActioveConsolidationZone.Clean(); CONSOLIDATION_BREAKED_DETECTED,
events //
// );
Add( }
CONSOLIDATION_BREAKED_DETECTED,
events //
);
} }
} }
} }
@@ -2575,16 +2594,15 @@ class XC121SMCCycleHelper : public XCBase
pivotPoint.repetition = repetition; pivotPoint.repetition = repetition;
// //
AddRef( bool isInited = AddPivotPoint(pivotPoint);
pivotPoint, if (isInited)
mPivotPoints // {
); //
Add(
// PIVOT_POINT_DETECTED,
Add( events //
PIVOT_POINT_DETECTED, );
events // }
);
} }
} }
} }
@@ -2634,19 +2652,18 @@ class XC121SMCCycleHelper : public XCBase
if (mActivePeakPivot.repetition >= pvValidation) if (mActivePeakPivot.repetition >= pvValidation)
{ {
// //
AddRef( bool isInited = AddPivot(mActivePeakPivot);
mActivePeakPivot, if (isInited)
mPivots // {
); //
Add(
PEAK_PIVOT_ENDED,
events //
);
// //
Add( mActivePeakPivot.Clean();
PEAK_PIVOT_ENDED, }
events //
);
//
mActivePeakPivot.Clean();
} }
else else
{ {
@@ -2705,19 +2722,18 @@ class XC121SMCCycleHelper : public XCBase
if (mActiveValePivot.repetition >= pvValidation) if (mActiveValePivot.repetition >= pvValidation)
{ {
// //
AddRef( bool isInited = AddPivot(mActiveValePivot);
mActiveValePivot, if (isInited)
mPivots // {
); //
Add(
VALE_PIVOT_ENDED,
events //
);
// //
Add( mActiveValePivot.Clean();
VALE_PIVOT_ENDED, }
events //
);
//
mActiveValePivot.Clean();
} }
else else
{ {
@@ -3368,5 +3384,143 @@ class XC121SMCCycleHelper : public XCBase
return result; 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 = isBearish =
// //
bearishConditions1 || bearishConditions1
bearishConditions2 // ||
// bearishConditions2
// //
; ;