This commit is contained in:
2026-08-14 07:49:18 +03:30
parent 9d23e2cba1
commit 4707856302
6 changed files with 3833 additions and 56 deletions
@@ -3722,6 +3722,125 @@ bool IsBoxValid(
return result;
}
/**
* Validate a Box based on Price ...
*
* @param box: XBoxZone instance, box to Validate ...
* @param barIndex: int, Start Validating Bar's Index ...
* @param pType: ENUM_X_BOUNDARY_PRICE, Price Type for Validation ...
*
* @return ( bool )
*/
bool IsBoxValid(
XBoxZone &box,
int barIndex = 0,
ENUM_X_BOUNDARY_PRICE pType = X_BOUNDARY_PRICE_UP_DOWN //
)
{
//
bool result = false;
//
// Normalize Bar Index ...
barIndex = NormalizeInt(barIndex, 0);
//
// Validaet ...
result =
box.IsValid() &&
IsXValid(pType);
if (!result)
{
return result;
}
//
bool isBullish = box.IsBullish();
//
int fromIDX = box.FromIndex();
result =
IsValidIndex(fromIDX) &&
barIndex < fromIDX;
if (!result)
{
return result;
}
//
// Loop through ...
XOHCL iBar;
bool has = false;
double appliedPrice = EMPTY_VALUE;
for (int i = barIndex; i < fromIDX; i++)
{
//
// Initialize Bar ...
iBar.Clean();
has = iBar.Init(box.symbol, box.period, i);
if (!has)
{
//
result = false;
break;
}
//
// Calculate Applied Price ...
switch (pType)
{
//
case X_BOUNDARY_PRICE_UP_DOWN:
//
appliedPrice =
isBullish
? iBar.GetDown()
: iBar.GetUp();
break;
//
case X_BOUNDARY_PRICE_HIGH_LOW:
//
appliedPrice =
isBullish
? iBar.low
: iBar.high;
break;
//
default:
appliedPrice = EMPTY_VALUE;
break;
}
has = NotEmptyZero(appliedPrice);
if (!has)
{
//
result = false;
break;
}
//
has =
has &&
result &&
(isBullish
? appliedPrice >= box.lower
: appliedPrice <= box.upper);
if (!has) {
//
result = false;
break;
}
//
iBar.Clean();
}
//
return result;
}
//
void SortBoxes(
XBoxZone &items[],