This commit is contained in:
2025-03-11 01:42:32 +03:30
parent d00dcf9ca0
commit f952cd1d93
6 changed files with 1311 additions and 124 deletions
+192 -61
View File
@@ -1135,6 +1135,40 @@ bool IsInsideBox(
return result;
}
/**
* Check Bar is Inside Specified Box ...
*
* @param bar: XOHCL instance reference, Specified Bar ...
* @param box: XCBozZone instance Reference ...
*
* @return ( bool )
*/
bool IsInsideBox(
XOHCL &bar,
XBoxZone &box //
)
{
//
bool result = false;
//
// Validate Args ...
result = bar.IsValid() &&
box.IsValid();
if (!result)
{
return result;
}
//
result =
bar.close <= box.upper &&
bar.close >= box.lower;
//
return result;
}
/**
* Check Value is Above Specified Box ...
*
@@ -1235,6 +1269,7 @@ bool IsBoxUsed(
bool isBullish = IsBullish(forDir);
//
bool isTouched = false;
for (int i = fromIndex; i >= toIndex; i--)
{
//
@@ -1246,10 +1281,11 @@ bool IsBoxUsed(
);
//
bool isTouched =
isBullish
? iBar.high > box.lower
: iBar.low < box.upper;
isTouched =
isInited &&
(isBullish
? iBar.low > box.upper
: iBar.high < box.lower);
if (!isTouched)
{
continue;
@@ -1257,74 +1293,26 @@ bool IsBoxUsed(
//
iBar.Clean();
result = false;
break;
}
//
result = isTouched;
//
return result;
}
/**
* Find an Inside Box of source in a Collection ...
* Validate Box ...
*
* @param index: int, Founded Index ...
* @param source: XBoxZone instance ...
* @param dest: XBoxZone instance Collection ...
* @param box: XBoxZone instance ...
* @param barIndex: int, Current Bar Index ...
* @param forPeriod: Testing Period ...
*
* @return ( bool )
*/
bool HasInsideBox(
int &index,
XBoxZone &source,
XBoxZone &dest[] //
)
{
//
bool result = false;
//
index = -1;
//
result = source.IsValid() &&
HasChild(dest);
//
int count = ArraySize(dest);
for (int i = 0; i < count; i++)
{
//
XBoxZone iBox = dest[i];
//
bool isInside = !iBox.IsSameAs(source) &&
IsBoxInsideOr(
iBox,
source //
);
if (isInside)
{
//
index = i;
iBox.Clean();
//
break;
}
//
iBox.Clean();
}
//
result = IsValidIndex(index);
//
return result;
}
bool IsValidBox(
bool IsBoxValid(
XBoxZone &box,
int barIndex = 0,
ENUM_TIMEFRAMES forPeriod = NULL //
@@ -1401,6 +1389,149 @@ bool IsValidBox(
return result;
}
/**
* Check a Box is Breaked or not ...
*
* @param box: XBoxZone instance Reference ...
* @param fromIndex: int ...
* @param toIndex: int
* @param forPeriod: Specified Period ...
*
* @return ( bool )
*/
bool IsBoxBreaked(
XBoxZone &box,
int fromIndex,
int toIndex = 0,
ENUM_TIMEFRAMES forPeriod = NULL //
)
{
//
bool result = false;
//
if (toIndex < 0)
{
toIndex = 0;
}
//
result =
//
box.IsValid() &&
fromIndex > 0 &&
fromIndex > toIndex
//
;
if (!result)
{
return result;
}
//
if (!IsValid(forPeriod))
{
forPeriod = box.period;
}
//
ENUM_X_DIRECTION forDir = box.dir;
bool isBullish = IsBullish(forDir);
//
bool isBreaked = false;
for (int i = fromIndex; i >= toIndex; i--)
{
//
XOHCL iBar;
bool isInited = iBar.Init(
box.symbol,
forPeriod,
i //
);
//
isBreaked =
isInited &&
(isBullish
? iBar.high <= box.lower
: iBar.low >= box.upper);
if (!isBreaked)
{
continue;
}
//
iBar.Clean();
break;
}
//
result = isBreaked;
//
return result;
}
/**
* Find an Inside Box of source in a Collection ...
*
* @param index: int, Founded Index ...
* @param source: XBoxZone instance ...
* @param dest: XBoxZone instance Collection ...
*
* @return ( bool )
*/
bool HasInsideBox(
int &index,
XBoxZone &source,
XBoxZone &dest[] //
)
{
//
bool result = false;
//
index = -1;
//
result = source.IsValid() &&
HasChild(dest);
//
int count = ArraySize(dest);
for (int i = 0; i < count; i++)
{
//
XBoxZone iBox = dest[i];
//
bool isInside = !iBox.IsSameAs(source) &&
IsBoxInsideOr(
iBox,
source //
);
if (isInside)
{
//
index = i;
iBox.Clean();
//
break;
}
//
iBox.Clean();
}
//
result = IsValidIndex(index);
//
return result;
}
/**
* Converts to XBoxZone ...
*
@@ -3032,7 +3163,7 @@ bool DetectBoxNearestPriceOut(
//
int fromIndex = iBarShift(
box.symbol,
box.period,
forPeriod,
box.from //
);
result = IsValidIndex(fromIndex);