This commit is contained in:
2025-05-08 13:07:25 +03:30
parent 6b95e10890
commit c013e593ad
5 changed files with 233 additions and 33 deletions
+163
View File
@@ -1868,6 +1868,169 @@ class XCBarAnalyser : public XCBase
return result;
}
/**
* Check a Bar is End of an OrderBlock Bar or Not ...
*
* @param bar: XOHCL ...
* @param box: XBoxZone ...
* @param forceFVGBarType: bool, Force all Bars must be Same as Direction ...
* @param forceOBTwoBar: bool, Force Two Bars of OB Start must be InDirection ...
*
* @return ( bool )
*/
bool IsOrderBlock(
XOHCL &bar,
XBoxZone &box,
bool forceFVGBarType = false,
bool forceOBTwoBar = false //
)
{
//
bool result = false;
//
box.Clean();
//
result = bar.IsValid();
if (!result)
{
return result;
}
//
// Check Bar Must be FVG ...
result = IsFVG(
bar,
box,
forceFVGBarType //
);
if (!result)
{
//
box.Clean();
//
return result;
}
//
box.type = "XOB";
//
bool isBullish = box.IsBullish();
bool isBearish = box.IsBearish();
//
// Order Block Includes an FVG which Starts by atleast One
// or More Indirectional Bars ...
XOHCL fvgLastBar;
XOHCL fvgLastBarPrev;
//
int barIndex = bar.Index();
int fvgLastBarIndex = barIndex + 3;
result = fvgLastBar.Init(
bar.symbol,
bar.period,
fvgLastBarIndex //
);
result =
result &&
fvgLastBar.GetPreviousBar(fvgLastBarPrev);
if (!result)
{
//
box.Clean();
fvgLastBar.Clean();
fvgLastBarPrev.Clean();
//
return result;
}
//
// Check FVG Last Bar ...
//
bool isBullishBlock =
isBullish &&
fvgLastBar.IsBearish();
//
bool isBearishBlock =
isBearish &&
fvgLastBar.IsBullish();
//
// Update Box ...
//
if (isBullishBlock ||
isBearishBlock)
{
//
box.from = fvgLastBar.time;
//
box.lower = MathMin(box.lower, fvgLastBar.low);
box.upper = MathMax(box.upper, fvgLastBar.high);
}
//
// Apply Force Two Bar ...
if (forceOBTwoBar)
{
//
isBullishBlock =
isBullishBlock &&
fvgLastBarPrev.IsBearish();
//
isBearishBlock =
isBearishBlock &&
fvgLastBarPrev.IsBullish();
//
// Update Box ...
if (isBullishBlock ||
isBearishBlock)
{
//
box.from = fvgLastBarPrev.time;
box.lower = MathMin(box.lower, fvgLastBarPrev.low);
box.upper = MathMax(box.upper, fvgLastBarPrev.high);
}
}
//
result = isBullishBlock ||
isBearishBlock;
if (!result)
{
//
box.Clean();
fvgLastBar.Clean();
fvgLastBarPrev.Clean();
//
return result;
}
//
result = box.IsValid();
//
// Cleanup Resources ...
//
fvgLastBar.Clean();
fvgLastBarPrev.Clean();
//
return result;
}
//
// Candlestick ...