This commit is contained in:
2025-04-24 09:09:22 +03:30
parent cd932c7648
commit e85a4afb69
6 changed files with 816 additions and 161 deletions
+397 -3
View File
@@ -611,9 +611,25 @@ class XCXCAEAPOIDetector : public XCBase
//
// Pivot Verifications and Max Allowed Holding Items ...
int maxAllowedPivots; // Max Allowed Holding Pibots ...
int pivotVerifications; // Pivots Verifications ...
int pivotDetectionLoopbac; // Pivots Detection Loopback ...
int maxAllowedPivots; // Max Allowed Holding Pibots ...
int pivotVerifications; // Pivots Verifications ...
int pivotDetectionLoopbac; // Pivots Detection Loopback ...
double ticksDividerInPoints; // Ticks and Volume Detection Divider in Point ...
ENUM_TIMEFRAMES ticksDetectionPerid; // Ticks and Volume Detection Loopback ...
//
// TICK Pivots ...
//
bool detectTickPivots;
XBoxZone tickPivots[];
//
// VOLUME Pivots ...
//
bool detectVolumePivots;
XBoxZone volumePivots[];
//
// RSI Peak Pivot ...
@@ -749,9 +765,13 @@ class XCXCAEAPOIDetector : public XCBase
//
maxAllowedPivots = 50;
pivotVerifications = 5;
ticksDividerInPoints = 15;
pivotDetectionLoopbac = 100;
ticksDetectionPerid = PERIOD_D1;
//
detectTickPivots = true;
detectVolumePivots = true;
detectRSIPeakPivots = true;
detectRSIValePivots = true;
detectCCIPeakPivots = true;
@@ -1016,6 +1036,161 @@ class XCXCAEAPOIDetector : public XCBase
//
// Checking Pivots ...
//
// Detect TICK and VOLUME Pivots ...
if (detectTickPivots || detectVolumePivots)
{
//
XOHCL ticksToBar;
XOHCL ticksFromBar;
XCTicksZone *ticksZone = NULL;
//
datetime ticksTo = GetPeriodStartTime(
zBar.symbol,
ticksDetectionPerid,
zBar.time //
);
bool isTicksBarInited = ticksToBar.Init(
zBar.symbol,
zBar.period,
ticksTo //
);
datetime ticksFrom = ticksTo - PeriodSeconds(ticksDetectionPerid);
isTicksBarInited = isTicksBarInited &&
ticksFromBar.Init(
zBar.symbol,
zBar.period,
ticksFrom //
);
bool hasValidTicksTimeRange = IsValid(ticksTo) &&
isTicksBarInited &&
IsValid(ticksFrom) &&
ticksFrom < ticksTo;
//
bool isTickPivotExists =
hasValidTicksTimeRange &&
IsExistsTickPivot(
ticksTo,
ticksFrom //
);
//
bool isVolumePivotExists =
hasValidTicksTimeRange &&
IsExistsVolumePivot(
ticksTo,
ticksFrom //
);
//
bool isInitializedZone = !isTickPivotExists ||
!isVolumePivotExists;
if (isInitializedZone)
{
//
isInitializedZone = InitializeTicksZone(
ticksZone,
ticksToBar,
ticksFromBar //
);
}
//
// TICK Pivots ...
if (detectTickPivots)
{
//
// Check Current Zone Exists or Not ...
if (isInitializedZone && !isTickPivotExists)
{
//
XBoxZone iBox;
XCTickZone *iZone;
has = ticksZone.GetMaxTickZone(iZone);
if (has)
{
//
// Try to Converts a Tick Zone to XBoxZone ...
iBox.to = ticksTo;
iBox.from = ticksFrom;
iBox.lower = iZone.low;
iBox.upper = iZone.high;
iBox.symbol = iZone.symbol;
iBox.period = iZone.period;
iBox.type = "XCA_MAX_TICK";
iBox.dir = X_DIRECTION_BULLISH; // Temparory ...
//
has = iBox.IsValid();
if (has)
{
//
AddBox(
iBox,
tickPivots //
);
}
}
//
iBox.Clean();
ZeroMemory(iZone);
}
}
//
// VOLUME Pivots ...
if (detectVolumePivots)
{
//
// Check Current Zone Exists or Not ...
if (isInitializedZone && !isVolumePivotExists)
{
//
XBoxZone iBox;
XCTickZone *iZone;
has = ticksZone.GetMaxVolumeZone(iZone);
if (has)
{
//
// Try to Converts a Tick Zone to XBoxZone ...
iBox.to = ticksTo;
iBox.from = ticksFrom;
iBox.lower = iZone.low;
iBox.upper = iZone.high;
iBox.symbol = iZone.symbol;
iBox.period = iZone.period;
iBox.type = "XCA_MAX_VOLUME";
iBox.dir = X_DIRECTION_BULLISH; // Temparory ...
//
has = iBox.IsValid();
if (has)
{
//
AddBox(
iBox,
volumePivots //
);
}
}
//
iBox.Clean();
ZeroMemory(iZone);
}
}
//
ticksToBar.Clean();
ticksFromBar.Clean();
ZeroMemory(ticksZone);
//
}
//
// RSI Peak Pivot ...
if (detectRSIPeakPivots)
@@ -1755,6 +1930,28 @@ class XCXCAEAPOIDetector : public XCBase
//
// Implement Validation Senarios ...
//
// TICK Pivots ...
//
// TODO: Complete this ...
has = HasTickPivots();
if (has)
{
//
}
//
// VOLUME Pivots ...
//
// TODO: Complete this ...
has = HasVolumePivots();
if (has)
{
//
}
//
// RSI Peak Pivot ...
@@ -2480,6 +2677,36 @@ class XCXCAEAPOIDetector : public XCBase
//
// Counters ...
//
// TICK Pivot ...
//
bool HasTickPivots()
{
return HasChild(tickPivots);
}
//
int CountTickPivots()
{
return ArraySize(tickPivots);
}
//
// VOLUME Pivots ...
//
bool HasVolumePivots()
{
return HasChild(volumePivots);
}
//
int CountVolumePivots()
{
return ArraySize(volumePivots);
}
//
// RSI Peak Pivot ...
@@ -2896,6 +3123,8 @@ class XCXCAEAPOIDetector : public XCBase
void CleanPivots()
{
//
Clean(tickPivots);
Clean(volumePivots);
Clean(rsiPeakPivots);
Clean(rsiValePivots);
Clean(cciPeakPivots);
@@ -2912,6 +3141,8 @@ class XCXCAEAPOIDetector : public XCBase
void ReversePivots()
{
//
ArrayReverse(tickPivots);
ArrayReverse(volumePivots);
ArrayReverse(rsiPeakPivots);
ArrayReverse(rsiValePivots);
ArrayReverse(cciPeakPivots);
@@ -2925,6 +3156,169 @@ class XCXCAEAPOIDetector : public XCBase
}
//
//
bool IsExistsTickPivot(
datetime to,
datetime from //
)
{
//
bool result = false;
//
// Validate Args ...
result = IsValid(to) &&
IsValid(from) &&
to > from;
if (!result)
{
return result;
}
//
result = HasTickPivots();
if (!result)
{
return result;
}
//
int idx = -1;
int count = CountTickPivots();
for (int i = 0; i < count; i++)
{
//
XBoxZone iBox = tickPivots[i];
//
result = iBox.to == to &&
iBox.from == from;
if (result)
{
//
idx = i;
iBox.Clean();
//
break;
}
//
iBox.Clean();
}
//
result = IsValidIndex(idx);
//
return result;
}
//
bool IsExistsVolumePivot(
datetime to,
datetime from //
)
{
//
bool result = false;
//
// Validate Args ...
result = IsValid(to) &&
IsValid(from) &&
to > from;
if (!result)
{
return result;
}
//
result = HasVolumePivots();
if (!result)
{
return result;
}
//
int idx = -1;
int count = CountVolumePivots();
for (int i = 0; i < count; i++)
{
//
XBoxZone iBox = volumePivots[i];
//
result = iBox.to == to &&
iBox.from == from;
if (result)
{
//
idx = i;
iBox.Clean();
//
break;
}
//
iBox.Clean();
}
//
result = IsValidIndex(idx);
//
return result;
}
//
bool InitializeTicksZone(
XCTicksZone *&zone,
XOHCL &toBar,
XOHCL &fromBar //
)
{
//
bool result = false;
//
result = zone == NULL;
if (!result)
{
return result;
}
//
int toIDX = toBar.Index();
int fromIDX = fromBar.Index();
int rangeLength = fromIDX - toIDX;
double rangeDivider = ticksDividerInPoints * GetPoints(toBar.symbol);
double rangeL = toBar.FindLowest(rangeLength, MODE_LOW);
double rangeH = toBar.FindHighest(rangeLength, MODE_HIGH);
double rangeDiff = (rangeH - rangeL);
int zoneLevels = (int)(rangeDiff / rangeDivider);
//
zone = new XCTicksZone();
zone.Levels(zoneLevels);
//
result = zone.Init(
fromBar,
toBar //
);
if (!result)
{
ZeroMemory(zone);
}
//
return result;
}
//
};
//