This commit is contained in:
2024-12-30 03:08:21 +03:30
parent b5003968bc
commit 4094a92949
9 changed files with 833 additions and 267 deletions
@@ -92,7 +92,8 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
/**
* Retrieve POI Drawer Instance Pointer ...
**/
XCPOIDrawer* GetDrawer() {
XCPOIDrawer *GetDrawer()
{
return mPOIDrawer;
}
@@ -423,7 +424,6 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
// Update Last Issued Tick ...
mLastTick = cTick;
SaveTickData();
CleanupTicks();
//
// Update POIs ...
@@ -1015,35 +1015,6 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
mBarTracker.Clean();
}
/**
* Cleanup Ticks Size ...
*/
void CleanupTicks()
{
//
int maxRequiredTicks = MaxAllowedSaveTicks();
int ticksCount = ArraySize(mTicks);
if (!IsValidSize(ticksCount) ||
ticksCount <= maxRequiredTicks)
{
return;
}
//
int removeCount = ticksCount - maxRequiredTicks;
if (!IsValidSize(removeCount))
{
return;
}
//
ArrayRemove(
mTicks,
0,
removeCount //
);
}
/**
* Add new Tick Data to Collection ...
*/
@@ -1057,11 +1028,30 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
return;
}
//
int beforeCount = ArraySize(mTicks);
//
AddRef(
tick,
mTicks //
);
//
int afterCount = ArraySize(mTicks);
//
bool isAdded = afterCount == beforeCount + 1;
if (isAdded)
{
//
// Cleaning Up Unused Items ...
int maxAllowed = MaxAllowedSaveTicks();
CleanupArray(
mTicks,
maxAllowed //
);
}
}
/**
+1 -161
View File
@@ -28,168 +28,8 @@
enum ENUM_X121SMC_CHARTOBJECTS
{
X_XPVPIVOT_OBJ, // XPVPivot Object ...
X_121_NONE_OBJ
};
//
// Implementations ...
//
// XPVPivot Object ...
class XCXPVPivotObject : public XCBaseObject
{
//
public:
//
/**
* Creator ...
*
* @param chart_id: Long, Specified Chart ID ...
* @param window: Integer, Specified Chart Window ID ...
* @param pivot: XPVPivot instance ...
* @param prefix: String ...
*
* @return ( bool )
*/
bool Create(
long chart_id,
int window,
XPVPivot &pivot,
string prefix = NULL //
)
{
//
bool result = false;
//
result = pivot.IsValid();
if (!result)
{
return result;
}
//
string name = pivot.GetTag();
if (IsValid(prefix))
{
name = prefix + "_" + name;
}
//
result = mRect.Create(
chart_id,
name,
window,
pivot.from,
pivot.upper,
pivot.to,
pivot.lower //
);
//
if (result)
{
ObjName(name);
}
//
string mTrendName = "MID_" + name;
double mid = pivot.CalculateMid();
result = mTrend.Create(
chart_id,
mTrendName,
window,
pivot.from,
mid,
pivot.to,
mid //
);
if (!result)
{
//
mRect.Delete();
mRect.Detach();
}
//
return result;
}
//
// Getter(s) / Setter(s) ...
/**
* Set Pivot Width ...
*
* @param value: Integer ...
*/
void PivotWidth(int value)
{
//
if (value < 1)
{
value = 1;
}
//
mRect.Width(value);
mTrend.Width(value);
}
/**
* Set Pivot Color ...
*
* @param value: Color ...
*/
void PivotColor(color value)
{
//
mRect.Color(value);
mTrend.Color(value);
}
/**
* Set Pivot Style ...
*
* @param value: ENUM_LINE_STYLE member ...
*/
void PivotStyle(ENUM_LINE_STYLE value)
{
//
mRect.Style(value);
mTrend.Style(value);
}
/**
* Set Pivot Fill ...
*
* @param value: Boolean ...
*/
void PivotFill(bool value)
{
mRect.Fill(value);
}
//
// Virtual ...
/**
* Retrieve Object Type ...
*
* @return ( ENUM_X121SMC_CHARTOBJECTS )
*/
virtual ENUM_X121SMC_CHARTOBJECTS Type()
{
return X_XPVPIVOT_OBJ;
}
//
private:
//
//
// Props ...
CChartObjectRectangle mRect;
CChartObjectTrend mTrend;
};
@@ -1398,6 +1398,53 @@ class XC121SMCCycleHelper : public XCBase
return result;
}
/**
* Detect Market Structure based on Peaks and Vales ...
*
* @param dir: ENUM_X_DIRECTION member Reference ...
* @param minVerification: Integer ...
*
* @return ( bool )
*/
bool HasPVDirection(
ENUM_X_DIRECTION &dir,
int minVerification = 12 //
)
{
//
bool result = false;
//
if (minVerification < 7)
{
minVerification = 7;
}
//
dir = X_DIRECTION_NONE;
//
int bullishSum = mBullishPeaks + mBullishVales;
int bearishSum = mBearishPeaks + mBearishVales;
//
int diff = MathAbs(bullishSum - bearishSum);
bool isDiffPassed = diff >= minVerification;
result = isDiffPassed;
if (!result)
{
return result;
}
//
dir = bullishSum > bearishSum
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
return result;
}
//
// Change Values Actions ...
@@ -2180,7 +2227,9 @@ class XC121SMCCycleHelper : public XCBase
//
bool isNewPeak = conditions.x121Conditions.isNewPeak;
double peak = conditions.x121Conditions.peaksBuffer[0];
double peak = conditions.x121Conditions.peaksBuffer[1];
double peakPrev = conditions.x121Conditions.peaksBuffer[2];
bool isPeakSameAsPrev = peak == peakPrev;
bool isNewPeakOverLast = conditions.x121Conditions.isNewPeakOverLast;
bool isNewPeakUnderLast = conditions.x121Conditions.isNewPeakUnderLast;
@@ -2229,7 +2278,9 @@ class XC121SMCCycleHelper : public XCBase
//
bool isNewVale = conditions.x121Conditions.isNewVale;
double vale = conditions.x121Conditions.valesBuffer[0];
double vale = conditions.x121Conditions.valesBuffer[1];
double valePrev = conditions.x121Conditions.valesBuffer[2];
bool isValeSameAsPrev = vale == valePrev;
bool isNewValeOverLast = conditions.x121Conditions.isNewValeOverLast;
bool isNewValeUnderLast = conditions.x121Conditions.isNewValeUnderLast;
@@ -2273,6 +2324,99 @@ class XC121SMCCycleHelper : public XCBase
}
}
//
// Count Bullish / Bearish Peaks and Vales ...
//
// Peaks ...
//
if (isNewPeakOverLast)
{
//
mBullishPeaks++;
mIsLastPeakBullish = true;
}
//
if (isNewPeakUnderLast)
{
//
mBearishPeaks++;
mIsLastPeakBullish = false;
}
//
if (isPeakSameAsPrev)
{
//
if (mIsLastPeakBullish)
{
//
mBullishPeaks++;
mBearishPeaks--;
if (mBearishPeaks < 0)
{
mBearishPeaks = 0;
}
}
else
{
//
mBullishPeaks--;
mBearishPeaks++;
if (mBullishPeaks < 0)
{
mBullishPeaks = 0;
}
}
}
//
// Vales ...
//
if (isNewValeOverLast)
{
//
mBullishVales++;
mIsLastValeBullish = true;
}
//
if (isNewValeUnderLast)
{
//
mBearishVales++;
mIsLastValeBullish = false;
}
//
if (isValeSameAsPrev)
{
//
if (mIsLastValeBullish)
{
//
mBullishVales++;
mBearishVales--;
if (mBearishVales < 0)
{
mBearishVales = 0;
}
}
else
{
//
mBullishVales--;
mBearishVales++;
if (mBullishVales < 0)
{
mBullishVales = 0;
}
}
}
//
// VWap Direction Change ...
@@ -2962,6 +3106,16 @@ class XC121SMCCycleHelper : public XCBase
//
// Props ...
//
bool mIsLastPeakBullish;
int mBullishPeaks; // Count Bullish Peaks ...
int mBearishPeaks; // Count Bearish Peaks ...
//
bool mIsLastValeBullish;
int mBullishVales; // Count Bullish Vales ...
int mBearishVales; // Count Bearish Vales ...
//
// Change Holders ...
int mMaxAllowedSavedChanges; // Max llowed Changes to Save ...