This commit is contained in:
2026-02-13 23:37:58 +03:30
parent 5abca35202
commit 887d44511a
3 changed files with 195 additions and 9 deletions
@@ -297,6 +297,168 @@ class XCMarketPatternDetector : public XCBase
return result;
}
/**
* Detect Confluence Statck based on Given Bar ...
*
* @param bar: XOHCL, Specified Bar for Start Detection ...
* @param zone: XBoxZone, confluence Zone, if exists ...
* @param forDir: ENUM_X_DIRECTION, Specified Required Zone Confluence ...
* @param retests: int, Number of Zone retesting ...
* @param loopback: int, Max allowed Loopback for Confluence Detection ...
* @param rangeLength: int, Loopback for Range Detecttion ...
* @param upperPriceType: ENUM_X_PRICE, zone upper Price Type ...
* @param lowerPriceType: ENUM_X_PRICE,
* @return ( bool )
*/
bool HasConfluence(
XOHCL &bar,
XBoxZone &confluence,
ENUM_X_DIRECTION forDir,
int retests = 2,
int loopback = 15,
int rangeLength = 5,
ENUM_X_PRICE upperPriceType = X_PRICE_HIGH,
ENUM_X_PRICE lowerPriceType = X_PRICE_LOW //
)
{
//
bool result = false;
//
// Normalize ...
confluence.Clean();
if (retests < 0)
{
retests = 0;
}
if (loopback < 2)
{
loopback = 2;
}
if (rangeLength < 2)
{
rangeLength = 2;
}
//
// Validate ...
result =
bar.IsValid() &&
HasDirection(forDir) &&
IsXValid(upperPriceType) &&
IsXValid(lowerPriceType);
if (!result)
{
return result;
}
//
// Retrieve Upper and Lower ...
int mIndex = -1;
double upper = bar.FindHighest(
mIndex,
rangeLength,
upperPriceType //
);
double lower = bar.FindLowest(
mIndex,
rangeLength,
lowerPriceType //
);
//
// Validate Upper/Lower ...
result =
NotEmptyZero(upper) &&
NotEmptyZero(lower) &&
upper > lower;
if (!result)
{
return result;
}
//
// Validate Confluence ...
XOHCL tmpBar;
bool has = false;
int tmpCount = 0;
double tmpPrice = EMPTY_VALUE;
for (int i = bar.Index() + 1; i < bar.Index() + loopback; i++)
{
//
has = tmpBar.Init(bar.symbol, bar.period, i);
if (!has)
{
continue;
}
//
tmpPrice =
IsXBullish(forDir)
? tmpBar.GetPrice(upperPriceType)
: tmpBar.GetPrice(lowerPriceType);
has =
NotEmptyZero(tmpPrice) &&
(IsXBullish(forDir)
? tmpPrice < upper
: tmpPrice > lower);
if (!has)
{
//
tmpBar.Clean();
//
result = false;
break;
}
//
// Counting retests ...
has = IsXBullish(forDir)
? tmpPrice > lower
: tmpPrice > upper;
if (has)
{
tmpCount++;
}
//
tmpBar.Clean();
}
//
// Validating Retests ...
if (result && retests > 0)
{
//
result =
result &&
tmpCount >= retests;
}
//
if (!result)
{
return result;
}
//
result = confluence.Init(
bar.symbol,
bar.period,
upper,
lower,
GetBarTime(bar.symbol, bar.period, bar.Index() + loopback + 1),
bar.time,
forDir,
"XConfluence",
NULL // At ...
);
//
return result;
}
//
// Detectors ...