last works ...

This commit is contained in:
2025-09-26 19:48:34 +03:30
parent 353a204162
commit 21ce1ebf4f
12 changed files with 3029 additions and 544 deletions
@@ -564,21 +564,6 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
obs,
maxAllowedCollecting //
);
//
XOHCL pBar;
bool has = forBar.GetPreviousBar(pBar);
if (has)
{
//
structure.isOBTouched =
isBullishOB
? pBar.low < structure.ob.upper
: pBar.high > structure.ob.lower;
}
//
pBar.Clean();
}
}
@@ -612,21 +597,6 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
fvgs,
maxAllowedCollecting //
);
//
XOHCL pBar;
bool has = forBar.GetPreviousBar(pBar);
if (has)
{
//
structure.isFVGTouched =
isBullishFVG
? pBar.low < structure.fvg.upper
: pBar.high > structure.fvg.lower;
}
//
pBar.Clean();
}
}
@@ -891,16 +861,6 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
//
// Check for Support Touches ...
XOHCL pBar;
has = has &&
forBar.GetPreviousBar(pBar);
if (has)
{
structure.isSupportTouched = pBar.low < supportBox.upper;
}
//
pBar.Clean();
supportBox.Clean();
}
support.Clean();
@@ -951,17 +911,6 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
}
//
// Check for Resistance Touches ...
XOHCL pBar;
has = has &&
forBar.GetPreviousBar(pBar);
if (has)
{
structure.isResistanceTouched = pBar.high > resistanceBox.upper;
}
//
pBar.Clean();
resistanceBox.Clean();
}
resistance.Clean();
@@ -1047,46 +996,11 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
//
// COMPLEX Actions ...
//
// Lockup For Previous Zone ...
has = structure.isSupportTouched ||
structure.isResistanceTouched;
if (has)
{
//
if (structure.isSupportTouched)
{
//
idx = GetYoungestBefore(
structure.support.from,
supports //
);
has = IsValidIndex(idx);
if (has)
{
structure.prevZone = supports[idx];
}
}
else if (structure.isResistanceTouched)
{
//
idx = GetYoungestBefore(
structure.resistance.from,
resistances //
);
has = IsValidIndex(idx);
if (has)
{
structure.prevZone = resistances[idx];
}
}
}
//
// Detect Recently Tested Zones ...
if ((config.detectSupport ||
config.detectResistance) &&
config.recentlyTestedZonesMaxLookup > 0)
config.detectResistance) &&
config.recentlyZonesMaxLookupLength > 0)
{
//
XOHCL iBar;
@@ -1094,146 +1008,133 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
bool has = false;
//
int start = forBar.Index() + 1;
int end = start + config.recentlyTestedZonesMaxLookup;
for (int i = start; i < end; i++) {
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) {
if (!has)
{
continue;
}
//
// Selecting Support and Resistances ...
//
// Supports ...
idx = GetYoungestBefore(iBar.time, supports);
has = IsValidIndex(idx);
if (has) {
if (has)
{
//
// Check Testing ...
has = IsTested(iBar, supports[idx]);
if (has) {
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) {
if (has)
{
//
// Check Testing ...
has = IsTested(iBar, resistances[idx]);
if (has) {
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)
if ((config.detectSupport ||
config.detectResistance) &&
HasChild(structure.recentlyBreakedZones))
{
//
// Retrieve Previous Bar ...
int idx = -1;
XOHCL pForBar;
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;
XBoxZone pSupport;
XOHCL pBreakerBar;
XBoxZone pResistance;
//
// Selecting Previously Touched Support / Resistance ...
has = forBar.GetPreviousBar(pForBar);
if (has)
{
//
// Detecting Nearest Above Lows Support ...
idx = GetYoungestAbove(
pForBar.low,
supports //
);
has = IsValidIndex(idx) &&
IsBreaked(
forBar,
supports[idx] //
);
if (has)
{
pSupport = supports[idx];
}
//
// Detecting Nearest Below Highs Resistance ...
idx = GetYoungestBelow(
pForBar.high,
resistances //
);
has = IsValidIndex(idx) &&
IsBreaked(
forBar,
resistances[idx] //
);
if (has)
{
pResistance = resistances[idx];
}
}
//
// Check at least a zone Exists ...
// Selecting pTestedZone ...
has = pSupport.IsValid() ||
pResistance.IsValid();
if (has)
{
//
// Support ...
has = pSupport.IsValid();
if (has)
{
//
structure.isPTest = true;
structure.pTestedZone = pSupport;
}
//
// Resistance ...
has = pResistance.IsValid();
if (has)
{
//
structure.isPTest = true;
structure.pTestedZone = pResistance;
}
}
//
// Check pTestedZone Existance ...
has = structure.isPTest &&
structure.pTestedZone.IsValid();
if (has)
{
//
// Get Breaker Bars ...
XOHCL breakerBars[];
int breakerBarsCount = GetBreakerBars(
structure.pTestedZone,
structure.fakeBreakedZone,
breakerBars //
);
has = IsValidSize(breakerBarsCount);
@@ -1247,36 +1148,381 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
breakerBar = breakerBars[idx];
}
}
//
SpecifiedClean(breakerBars);
}
has = breakerBar.IsValid();
//
// Check Zone Breaker Bar Exists ...
// Validate Zone Fake Breake Langth ...
has = breakerBar.IsValid();
// Validate BreakerBars Length ...
if (has)
{
//
// Validate Breake Length ...
has = (breakerBar.Index() - pForBar.Index()) <= config.supportAndResistanceBreakeValidationLength;
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)
{
//
if (!has)
XOHCL iBar;
XPivot iPivot;
XBoxZone iBox;
bool has = false;
string iPrefix = NULL;
int start = forBar.Index();
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)
{
//
structure.isPTest = false;
structure.pTestedZone.Clean();
Copy(
obs,
structure.obs //
);
Sort(
structure.obs,
iSortBy,
iSortDir,
config.recentlyPatternsMaxAllowedCollecting //
);
}
pForBar.Clean();
pSupport.Clean();
breakerBar.Clean();
pBreakerBar.Clean();
pResistance.Clean();
//
// Fair Value Gaps ...
if (config.detectFVG)
{
//
Copy(
fvgs,
structure.fvgs //
);
Sort(
structure.fvgs,
iSortBy,
iSortDir,
config.recentlyPatternsMaxAllowedCollecting //
);
}
//
// Loop through Items ...
for (int i = start; i < end; i++)
{
//
iPivot.Clean();
//
// Initialize Indexed Bar ...
has = forBar.BarAt(i, iBar);
if (!has)
{
//
iBar.Clean();
continue;
}
//
// Bars Detecting ...
//
// Momentum Bars ...
if (config.detectMomentum)
{
//
iPrefix = "MomentumBar";
has = IsMomentumBar(
iBar,
iDir,
config.momentumBarRangeLength,
config.momentumBarApprovedMultiplier //
);
has = has &&
ToPivot(
iBar,
iPivot,
iDir,
iPrefix //
);
if (has)
{
//
AddIfNotExists(
iPivot,
structure.momentumBars //
);
}
iPivot.Clean();
}
//
// Engulfed Bars ...
if (config.detectEngulfed)
{
//
iPrefix = "EngulfedBar";
has = IsEngulfedBar(
iBar,
iDir //
);
has = has &&
ToPivot(
iBar,
iPivot,
iDir,
iPrefix //
);
if (has)
{
//
AddIfNotExists(
iPivot,
structure.engulfBars //
);
}
iPivot.Clean();
}
//
// TruGaped Bars ...
if (config.detectTrueGaped)
{
//
iPrefix = "TruGapedBar";
has = IsTrueGapedBar(
forBar,
iDir,
config.truwGapApprovedPointMultiplier //
);
has = has &&
ToPivot(
iBar,
iPivot,
iDir,
iPrefix //
);
if (has)
{
//
AddIfNotExists(
iPivot,
structure.trueGapBars //
);
}
iPivot.Clean();
}
//
// Pin Bars ...
if (config.detectTrueGaped)
{
//
iPrefix = "PinBar";
has = IsPinnedBar(
forBar,
iDir,
config.pinnedBaarShadowApprovedMultiplier,
config.pinnedBarMinimumPinBarRangeMultiplier,
config.pinnedBarForceDirection //
);
has = has &&
ToPivot(
iBar,
iPivot,
iDir,
iPrefix //
);
if (has)
{
//
AddIfNotExists(
iPivot,
structure.pinBars //
);
}
iPivot.Clean();
}
//
// Patterns Detecting ...
//
// Star Pattern ...
if (config.detectStarPattern)
{
//
iPrefix = "Star";
has = IsStartPattern(
forBar,
iDir //
);
has = has &&
ToBox(
forBar,
iBox,
iDir,
iPrefix //
);
if (has)
{
//
AddIfNotExists(
iBox,
structure.starPatterns //
);
}
iBox.Clean();
}
//
// Piercing Pattern ...
if (config.detectPiercingPattern)
{
//
iPrefix = "Piercing";
has = IsPiercingPattern(
forBar,
iDir //
);
has = has &&
ToBox(
forBar,
iBox,
iDir,
iPrefix //
);
if (has)
{
//
AddIfNotExists(
iBox,
structure.piercingPatterns //
);
}
iBox.Clean();
}
//
// Rising Pattern ...
if (config.detectRisingPattern)
{
//
iPrefix = "Rising";
has = IsRisingPattern(
forBar,
iDir //
);
has = has &&
ToBox(
forBar,
iBox,
iDir,
iPrefix //
);
if (has)
{
//
AddIfNotExists(
iBox,
structure.risingPatterns //
);
}
iBox.Clean();
}
//
// Flag Pattern ...
if (config.detectFlagPattern)
{
//
iPrefix = "Flag";
XOHCL swingBar;
has = IsFlagPattern(
forBar,
iDir,
swingBar,
config.flagPatternMinimumPullbackBars //
);
has = has &&
ToBox(
forBar,
iBox,
iDir,
iPrefix //
);
if (has)
{
//
AddIfNotExists(
iBox,
structure.flagPatterns //
);
}
iBox.Clean();
}
//
// SignalKey Bar Pattern ...
if (config.detectSignalKeyBarPattern)
{
//
iPrefix = "SignalKeyBar";
has = IsSignalKeyBarPattern(
forBar,
iDir,
config.signalKeyBarShadowApprovedMultiplier,
config.signalKeyBarMinimumPinBarRangeMultiplier,
config.signalKeyBarForceDirection //
);
has = has &&
ToBox(
forBar,
iBox,
iDir,
iPrefix //
);
if (has)
{
//
AddIfNotExists(
iBox,
structure.signalKeyBarPatterns //
);
}
iBox.Clean();
}
//
iBar.Clean();
}
//
// Cleanup Resources ...
iBar.Clean();
iBox.Clean();
iPivot.Clean();
}
}