This commit is contained in:
2025-10-01 12:06:18 +03:30
parent c5a1e326b2
commit 684d3028c4
11 changed files with 4472 additions and 2379 deletions
@@ -527,79 +527,14 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
//
int idx = -1;
int count = 0;
XBoxZone iBox;
bool has = false;
int maxAllowedCollecting = 50;
ENUM_X_DIRECTION iDir = X_DIRECTION_NONE;
//
// Detecting POI Based on Config ...
//
// Order Block ...
if (config.detectOB)
{
//
bool isOB = HasOB(
forBar,
iDir,
structure.ob,
config.obLoopback //
);
bool isBullishOB = isOB &&
IsSpecifiedBullish(iDir);
bool isBearishOB = isOB &&
IsSpecifiedBearish(iDir);
if (!isOB)
{
structure.ob.Clean();
}
//
// Detect Touches ...
if (isOB)
{
//
AddIfNotExists(
structure.ob,
obs,
maxAllowedCollecting //
);
}
}
//
// Fair Value Gap ...
if (config.detectFVG)
{
//
bool isFVG = HasFVG(
forBar,
iDir,
structure.fvg,
config.fvgLoopback //
);
bool isBullishFVG = isFVG &&
IsSpecifiedBullish(iDir);
bool isBearishFVG = isFVG &&
IsSpecifiedBearish(iDir);
if (!isFVG)
{
structure.fvg.Clean();
}
//
// Detect Touches ...
if (isFVG)
{
//
AddIfNotExists(
structure.fvg,
fvgs,
maxAllowedCollecting //
);
}
}
//
// Checking Momentum Bar ...
if (config.detectMomentum)
@@ -815,107 +750,6 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
SpecifiedClean(swings);
}
//
// Detect Supports ...
if (config.detectSupport)
{
//
XOHCL support;
bool hasSupport = HasSupport(
forBar,
support,
config.supportAndResistanceValidationLength,
config.supportAndResistanceMaxAllowedLoopback //
);
if (hasSupport)
{
//
XBoxZone supportBox;
has = ToSupportBox(support, supportBox);
//
// Validate Zone Strength if Provided ...
if (config.minAllowdSupportAndResistanceStrength > 0)
{
//
has = has &&
ValidateStrength(
supportBox,
config.minAllowdSupportAndResistanceStrength //
);
}
//
if (has)
{
//
AddIfNotExists(
supportBox,
supports,
maxAllowedCollecting //
);
//
structure.support = supportBox;
}
//
// Check for Support Touches ...
supportBox.Clean();
}
support.Clean();
}
//
// Detect Resistance ...
if (config.detectResistance)
{
//
XOHCL resistance;
bool hasResistance = HasResistance(
forBar,
resistance,
config.supportAndResistanceValidationLength,
config.supportAndResistanceMaxAllowedLoopback //
);
if (hasResistance)
{
//
XBoxZone resistanceBox;
has = ToResistanceBox(resistance, resistanceBox);
//
// Validate Zone Strength if Provided ...
if (config.minAllowdSupportAndResistanceStrength > 0)
{
//
has = has &&
ValidateStrength(
resistanceBox,
config.minAllowdSupportAndResistanceStrength //
);
}
//
if (has)
{
//
AddIfNotExists(
resistanceBox,
resistances,
maxAllowedCollecting //
);
//
structure.resistance = resistanceBox;
}
//
resistanceBox.Clean();
}
resistance.Clean();
}
//
// Custom Indicator Pivots ...
@@ -935,9 +769,9 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
fimaHelper.ExtractMAPivots(
structure.maCrosses,
idx,
config.recentlyPatternsMaxAllowedCollecting,
config.zonesRequiredNumber,
config.validMACrossDiffMultiplier,
config.recentlyPatternsMaxLookupLength //
config.zonesMaxAllowedLoopbackLength //
);
}
@@ -956,14 +790,15 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
fimaHelper.ExtractHKPivots(
structure.hkSwitches,
idx,
config.recentlyPatternsMaxAllowedCollecting,
config.recentlyPatternsMaxLookupLength //
config.zonesRequiredNumber,
config.zonesMaxAllowedLoopbackLength //
);
}
//
// Detecting SAR Switches ...
if (config.detectSARSwitches) {
if (config.detectSARSwitches)
{
//
idx = forBar.Index();
has = fimaHelper.HasSARSwitch(
@@ -975,8 +810,8 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
fimaHelper.ExtractSARPivots(
structure.sarSwitches,
idx,
config.recentlyPatternsMaxAllowedCollecting,
config.recentlyPatternsMaxLookupLength //
config.zonesRequiredNumber,
config.zonesMaxAllowedLoopbackLength //
);
}
@@ -1002,24 +837,6 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
}
}
//
// Analyse Based on SAR ...
if (config.analyseFIMASARPivots)
{
//
XPivotAnalysis analysis;
has = AnalyseSARPivots(
analysis, // Result ...
forBar.Index(), // Bar Index ...
config.numberOfRequiredPivotsForAnalysis, // Required Number of Pivots ...
config.maxAllowedLoopbackLengthForAnalysis // Max Allowed Loopback ...
);
if (has)
{
structure.sarAnalysis = analysis;
}
}
//
// Analyse Based on ZigZag ...
if (config.analyseFIMAZigZagPivots)
@@ -1039,195 +856,16 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
}
//
// COMPLEX Actions ...
//
// Detect Recently Tested Zones ...
if ((config.detectSupport ||
config.detectResistance) &&
config.recentlyZonesMaxLookupLength > 0)
{
//
XOHCL iBar;
int idx = -1;
bool has = false;
//
int start = forBar.Index();
int end = start + config.recentlyZonesMaxLookupLength;
for (int i = start; i < end; i++)
{
//
// Initialize Indexed Bar ...
has = forBar.BarAt(i, iBar);
if (!has)
{
continue;
}
//
// Selecting Support and Resistances ...
//
// Supports ...
idx = GetYoungestBefore(iBar.time, supports);
has = IsValidIndex(idx);
if (has)
{
//
// Check Testing ...
has = IsTested(iBar, supports[idx]);
if (has)
{
//
AddIfNotExists(
supports[idx],
structure.recentlyTestedZones //
);
}
//
// Check Breaked ...
has = IsBreaked(iBar, supports[idx]);
if (has)
{
//
AddIfNotExists(
supports[idx],
structure.recentlyBreakedZones //
);
}
}
//
// Resistances ...
idx = GetYoungestBefore(iBar.time, resistances);
has = IsValidIndex(idx);
if (has)
{
//
// Check Testing ...
has = IsTested(iBar, resistances[idx]);
if (has)
{
//
AddIfNotExists(
resistances[idx],
structure.recentlyTestedZones //
);
}
//
// Check Breaked ...
has = IsBreaked(iBar, resistances[idx]);
if (has)
{
//
AddIfNotExists(
resistances[idx],
structure.recentlyBreakedZones //
);
}
}
}
}
//
// Checkup for FakeBreaked Zones ...
if ((config.detectSupport ||
config.detectResistance) &&
HasChild(structure.recentlyBreakedZones))
{
//
int idx = -1;
bool has = false;
//
// Detect Youngest Recently Breaked Zones ...
idx = GetYoungest(structure.recentlyBreakedZones);
has = IsValidIndex(idx);
if (has)
{
//
structure.fakeBreakedZone = structure.recentlyBreakedZones[idx];
//
// Update To Time ...
structure.fakeBreakedZone.to = forBar.time;
}
//
// Check Price Going Back to Zone Area ...
has = structure.fakeBreakedZone.IsValid();
if (has)
{
//
// Check Current Bar Acted Based on Zone ...
has = structure.fakeBreakedZone.IsBullish()
? forBar.close > structure.fakeBreakedZone.upper
: forBar.close < structure.fakeBreakedZone.lower;
}
//
// Try to Validate Breake Length ...
//
// Get Youngest Breaker Bar ...
XOHCL breakerBar;
if (has)
{
//
XOHCL breakerBars[];
int breakerBarsCount = GetBreakerBars(
structure.fakeBreakedZone,
breakerBars //
);
has = IsValidSize(breakerBarsCount);
if (has)
{
//
idx = GetYoungestBar(breakerBars);
has = IsValidIndex(idx);
if (has)
{
breakerBar = breakerBars[idx];
}
}
SpecifiedClean(breakerBars);
}
has = breakerBar.IsValid();
//
// Validate BreakerBars Length ...
if (has)
{
//
int diff = breakerBar.Index() - forBar.Index();
//
has =
config.supportAndResistanceBreakeValidationLength <= 0
? true
: diff <= config.supportAndResistanceBreakeValidationLength;
}
//
if (!has)
{
structure.fakeBreakedZone.Clean();
}
//
// Cleanup Resources ...
breakerBar.Clean();
}
//
// Detect Recently Patterns ...
if (config.recentlyPatternsMaxLookupLength > 0)
// Zones and Patterns Recent Actions ...
if (config.zonesRequiredNumber > 0 &&
config.zonesMaxAllowedLoopbackLength > 0)
{
//
// Detect Recent Patterns ...
//
XOHCL iBar;
XOHCL tmpBar;
XPivot iPivot;
XBoxZone iBox;
bool has = false;
@@ -1236,75 +874,7 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
ENUM_X_SORT_BY iSortBy = X_SORT_BY_DATE;
ENUM_X_DIRECTION iDir = X_DIRECTION_NONE;
ENUM_X_DIRECTION iSortDir = X_DIRECTION_BULLISH;
int end = start + config.recentlyPatternsMaxLookupLength;
//
// Order Blocks ...
if (config.detectOB)
{
//
Copy(
obs,
structure.obs //
);
Sort(
structure.obs,
iSortBy,
iSortDir,
config.recentlyPatternsMaxAllowedCollecting //
);
}
//
// Fair Value Gaps ...
if (config.detectFVG)
{
//
Copy(
fvgs,
structure.fvgs //
);
Sort(
structure.fvgs,
iSortBy,
iSortDir,
config.recentlyPatternsMaxAllowedCollecting //
);
}
//
// Supports ...
if (config.detectSupport)
{
//
Copy(
supports,
structure.supports //
);
Sort(
structure.supports,
iSortBy,
iSortDir,
config.recentlyPatternsMaxAllowedCollecting //
);
}
//
// Resistances ...
if (config.detectResistance)
{
//
Copy(
resistances,
structure.resistances //
);
Sort(
structure.resistances,
iSortBy,
iSortDir,
config.recentlyPatternsMaxAllowedCollecting //
);
}
int end = start + config.zonesMaxAllowedLoopbackLength;
//
// Loop through Items ...
@@ -1323,6 +893,112 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
continue;
}
//
// OB ...
has = HasOB(
iBar,
iDir,
iBox,
5 //
);
if (has)
{
//
AddIfNotExists(
iBox,
obs //
);
}
//
// FVG ...
has = HasFVG(
iBar,
iDir,
iBox,
5 //
);
if (has)
{
//
AddIfNotExists(
iBox,
fvgs //
);
}
//
// SUPPORT ...
tmpBar.Clean();
has = HasSupport(
iBar,
tmpBar,
config.zonesValidationLength,
config.zonesMaxAllowedLoopbackLength //
);
if (has)
{
//
has = ToSupportBox(tmpBar, iBox, iBar.time);
if (has)
{
//
// Check Strength ...
if (config.zonesMinAlloweStrength > 0)
{
has = (iBox.upper - iBox.lower) > (config.zonesMinAlloweStrength * GetPoints(iBar.symbol));
}
//
if (has)
{
//
AddIfNotExists(
iBox,
supports //
);
}
}
}
iBox.Clean();
tmpBar.Clean();
//
// RESISATNCE ...
tmpBar.Clean();
has = HasResistance(
iBar,
tmpBar,
config.zonesValidationLength,
config.zonesMaxAllowedLoopbackLength //
);
if (has)
{
//
has = ToResistanceBox(tmpBar, iBox, iBar.time);
if (has)
{
//
// Check Strength ...
if (config.zonesMinAlloweStrength > 0)
{
has = (iBox.upper - iBox.lower) > (config.zonesMinAlloweStrength * GetPoints(iBar.symbol));
}
//
if (has)
{
//
AddIfNotExists(
iBox,
resistances //
);
}
}
}
iBox.Clean();
tmpBar.Clean();
//
// Bars Detecting ...
@@ -1595,14 +1271,201 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
//
iBar.Clean();
iBox.Clean();
tmpBar.Clean();
iPivot.Clean();
}
//
// Zones Extractions ...
//
// XBARZONES ...
XBoxZone tmpZones[];
int tmpZonesCount = fimaHelper.ExtractBarZones(
tmpZones,
forBar.Index(),
config.zonesRequiredNumber,
config.zonesBreakValidationLength,
config.zonesBreakValidationLength > 0,
config.zonesBarShadowMultiplier,
config.zonesMinAlloweStrength,
config.zonesValidationLength,
config.zonesMaxAllowedLoopbackLength //
);
has = IsValidSize(tmpZonesCount);
if (has)
{
//
for (int i = 0; i < tmpZonesCount; i++)
{
//
if (tmpZones[i].IsBullish())
{
//
AddIfNotExists(
tmpZones[i],
supports //
);
}
else if (tmpZones[i].IsBearish())
{
//
AddIfNotExists(
tmpZones[i],
resistances //
);
}
}
}
//
// XHK ...
XClean(tmpZones);
tmpZonesCount = fimaHelper.ExtractHKZones(
tmpZones,
forBar.Index(),
config.zonesRequiredNumber,
config.zonesBreakValidationLength,
config.zonesBreakValidationLength > 0,
config.zonesBarShadowMultiplier,
config.zonesMinAlloweStrength,
config.zonesValidationLength,
config.zonesMaxAllowedLoopbackLength //
);
has = IsValidSize(tmpZonesCount);
if (has)
{
//
for (int i = 0; i < tmpZonesCount; i++)
{
//
if (tmpZones[i].IsBullish())
{
//
AddIfNotExists(
tmpZones[i],
supports //
);
}
else if (tmpZones[i].IsBearish())
{
//
AddIfNotExists(
tmpZones[i],
resistances //
);
}
}
}
//
// Cleanup Resources ...
iBar.Clean();
iBox.Clean();
tmpBar.Clean();
iPivot.Clean();
}
//
// Analysis Zones ...
//
// XPV ...
//
// Support ...
has = structure.pvAnalysis.IsValid() &&
structure.pvAnalysis.HasSupportBox(iBox);
if (has)
{
//
AddIfNotExists(
iBox,
supports //
);
}
//
// Resistance ...
has = structure.pvAnalysis.IsValid() &&
structure.pvAnalysis.HasResistanceBox(iBox);
if (has)
{
//
AddIfNotExists(
iBox,
resistances //
);
}
//
// XZG ...
//
// Support ...
has = structure.zigzagAnalysis.IsValid() &&
structure.zigzagAnalysis.HasSupportBox(iBox);
if (has)
{
//
AddIfNotExists(
iBox,
supports //
);
}
//
// Resistance ...
has = structure.zigzagAnalysis.IsValid() &&
structure.zigzagAnalysis.HasResistanceBox(iBox);
if (has)
{
//
AddIfNotExists(
iBox,
resistances //
);
}
//
// ZONES Specified ...
//
// OBS ...
CheckZones(forBar, obs);
Copy(
obs,
structure.obs //
);
//
// FVGS ...
CheckZones(forBar, fvgs);
Copy(
fvgs,
structure.fvgs //
);
//
// SUPPORTS ...
CheckZones(forBar, supports);
Copy(
supports,
structure.supports //
);
//
// RESISTANCES ...
CheckZones(forBar, resistances);
Copy(
resistances,
structure.resistances //
);
//
// Cleanup Resources ...
iBox.Clean();
}
//
@@ -1611,9 +1474,6 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
//
// Props ...
//
// Tools / Actions ...
//
// Private ...
private: