This commit is contained in:
2025-05-19 15:13:49 +03:30
parent ebc437a2f2
commit 8451bcdd6e
5 changed files with 2794 additions and 200 deletions
+228
View File
@@ -2040,6 +2040,234 @@ class XCBarAnalyser : public XCBase
return result;
}
bool IsTrigger(
XOHCL &bar,
XBoxZone &box,
bool forceFVGBarType = false,
bool forceOBTwoBar = false, //
int loopback = 5 //
)
{
//
bool result = false;
//
// Normalize Args ...
box.Clean();
loopback = NormalizeInt(loopback, 5);
//
// Validate Args ...
result = bar.IsValid();
if (!result)
{
return result;
}
//
XOHCL pBar; // Previous of Provided Bar ...
XOHCL iBar;
XOHCL iPBar;
int barIndex;
int pBarIndex;
//
result = bar.GetPreviousBar(pBar);
if (!result)
{
//
box.Clean();
pBar.Clean();
iBar.Clean();
iPBar.Clean();
//
return result;
}
//
barIndex = bar.Index();
pBarIndex = pBar.Index();
//
// Loopback to Find a Block ...
for (int i = pBarIndex; i < pBarIndex + loopback; i++)
{
//
// Inital IBar ...
result = iBar.Init(
bar.symbol,
bar.period,
i //
);
if (!result)
{
break;
}
//
// Detect Block ...
result = IsOB(
iBar,
box,
forceFVGBarType,
forceOBTwoBar //
);
if (result)
{
break;
}
//
iBar.Clean();
}
iBar.Clean();
//
// Validate Block Detected ...
result = box.IsValid();
if (!result)
{
//
box.Clean();
pBar.Clean();
iBar.Clean();
iPBar.Clean();
//
return result;
}
//
int toIDX = box.ToIndex();
int fromIDX = box.FromIndex();
bool isBullish = box.IsBullish();
bool isBearish = box.IsBearish();
//
// Detect Swing Bar ...
XOHCL swingBar;
int swingBarIDX = -1;
int swingLoopback = fromIDX - barIndex;
if (isBullish)
{
//
// Looking for Swing Low ...
swingBarIDX = bar.FindLowestIndex(swingLoopback, MODE_LOW);
}
else if (isBearish)
{
//
// Looking for Swing High ...
swingBarIDX = bar.FindLowestIndex(swingLoopback, MODE_LOW);
}
result = IsValidIndex(swingBarIDX);
if (!result)
{
//
box.Clean();
iBar.Clean();
iPBar.Clean();
swingBar.Clean();
//
return result;
}
//
// Initialize Swing Bar ...
result = swingBar.Init(
bar.symbol,
bar.period,
swingBarIDX //
);
if (!result)
{
//
box.Clean();
iBar.Clean();
iPBar.Clean();
swingBar.Clean();
//
return result;
}
//
// Now we Have to Check Spike from Swing Bar Next till Current Bar ...
// To Validate Highs and Lows ...
for (int i = pBarIndex; i < pBarIndex + (swingBarIDX - pBarIndex) - 1; i++)
{
//
// Initialize iBar ...
result = iBar.Init(
bar.symbol,
bar.period,
i //
);
result =
result &&
iBar.GetPreviousBar(iPBar);
if (!result)
{
break;
}
//
// Since we Go Backward Bars from Current Bar ...
// for Bullish: each Bar Low Must over Prev Bar Low ...
// for Bearish: each Bar High Must Under Prev Bar High ...
if (isBullish)
{
result = iBar.low > iPBar.low;
}
else if (isBearish)
{
result = iBar.high < iPBar.high;
}
if (!result)
{
break;
}
//
iBar.Clean();
iPBar.Clean();
}
iBar.Clean();
iPBar.Clean();
//
// Ensure Spike Happens ...
if (!result)
{
//
box.Clean();
pBar.Clean();
iBar.Clean();
iPBar.Clean();
//
return result;
}
//
// Cleanup Resources ...
//
iBar.Clean();
swingBar.Clean();
//
if (!result)
{
box.Clean();
}
//
return result;
}
//
// Candlestick ...