This commit is contained in:
2025-09-25 01:07:32 +03:30
parent a1a49449f0
commit 696d3a55da
2 changed files with 236 additions and 69 deletions
+146 -1
View File
@@ -1179,7 +1179,7 @@ class XCMarketPatternDetector : public XCBase
iBar,
ob,
true, // Force FVG Bar Type ...
true // Force OB First Two Bar InDirection ...
true // Force OB First Two Bar InDirection ...
);
if (!has)
{
@@ -1224,6 +1224,151 @@ class XCMarketPatternDetector : public XCBase
return result;
}
/**
* Detect Liquidity Sweeps ...
*
* @param bar: XOHCL, Specified Bar ...
* @param dir: ENUM_X_DIRECTION a reference for Direction ...
* @param sweeperBar: XOHCL, reference for Holding Sweeper Bar ...
* @param zone: XBoxZone, reference for Holding new Support/Resistance after Liquidity Sweeped ...
* @param sweepedLiquidity: XBoxZone, reference for Holding Sweeped Liquidity Zone ...
* @param liquidityLoopbackLength: int, Max Allowed Length to Sweep a Liquidity ...
* @param zoneValidationLength: int, Liquidity Detection Validatio Length ...
* @param zodeMaxAllowedLoopback: int, Max Allowed Loopback Length to Detect Liquidity ...
*
* @return ( bool )
*/
bool HasSweepedLiquidity(
XOHCL &bar,
ENUM_X_DIRECTION &dir,
XOHCL &sweeperBar,
XBoxZone &zone,
XBoxZone &sweepedLiquidity,
int liquidityLoopbackLength = 21,
int zoneValidationLength = 21,
int zodeMaxAllowedLoopback = 1500 //
)
{
//
bool result = false;
//
// Prepare ...
zone.Clean();
sweeperBar.Clean();
CleanDirection(dir);
sweepedLiquidity.Clean();
//
// Normalize ...
zoneValidationLength = NormalizeInt(zoneValidationLength, 7);
liquidityLoopbackLength = NormalizeInt(liquidityLoopbackLength, 5);
zodeMaxAllowedLoopback = NormalizeInt(zodeMaxAllowedLoopback, 21, 1500);
//
// Validate ...
result = bar.IsValid();
if (!result)
{
return result;
}
//
XOHCL supportBar;
XOHCL resistanceBar;
datetime barBeofreOn = bar.BeforeOn();
//
// Current Bar must has Support / Resistance ...
//
// Support ...
bool hasSupport = HasSupport(
bar,
supportBar,
zoneValidationLength,
zodeMaxAllowedLoopback //
);
//
// Validate Fresh Support ...
hasSupport =
hasSupport &&
supportBar.time == barBeofreOn;
//
// Validate Support Box Exists ...
hasSupport =
hasSupport &&
ToSupportBox(supportBar, zone);
//
// Resistance ...
bool hasResistance = HasResistance(
bar,
resistanceBar,
zoneValidationLength,
zodeMaxAllowedLoopback //
);
//
// Validate Fresh Resistance ...
hasResistance =
hasResistance &&
resistanceBar.time == barBeofreOn;
//
// Validate Resistance Box Existx ...
hasResistance =
hasResistance &&
ToResistanceBox(resistanceBar, zone);
//
result =
hasSupport ||
hasResistance;
if (!result)
{
//
zone.Clean();
sweeperBar.Clean();
supportBar.Clean();
CleanDirection(dir);
resistanceBar.Clean();
sweepedLiquidity.Clean();
//
return result;
}
//
//
// Validate ...
result = bar.IsValid();
if (!result)
{
return result;
}
//
result = HasDirection(dir);
//
// Cleanup Resources ...
if (!result)
{
//
zone.Clean();
sweeperBar.Clean();
CleanDirection(dir);
sweepedLiquidity.Clean();
}
//
return result;
}
//
// Trending ...
+90 -68
View File
@@ -456,38 +456,45 @@ void OnTick()
fima1Signaller.OnTick();
fima2Signaller.OnTick();
// //
// // Initial Bar for Analysis ...
// XOHCL cBar;
// bool isInited = cBar.Init(
// _Symbol,
// _Period,
// 1 //
// );
//
// Initial Bar for Analysis ...
XOHCL cBar;
bool isInited = cBar.Init(
_Symbol,
_Period,
1 //
);
//
// Here We Apply Custom Detecting ...
detectorConfig.OffDetectors();
detectorConfig.detectSupport = true;
detectorConfig.detectResistance = true;
detectorConfig.detectSignalKeyBarPattern = false;
detectorConfig.supportAndResistanceValidationLength = 21;
//
// Analyse Market ...
// fima2Signaller.poiDetector.AnalyseMarket(
// cBar,
// marketStructure,
// detectorConfig //
// );
// CArrayObj *iObjects;
// int drawnsCount = fima2Signaller.poiDrawer.DrawMarketStructure(
// marketStructure,
// marketStructureDrawerConfig,
// iObjects //
// );
// if (IsValidSize(drawnsCount))
// {
// //
// AddObjects(
// iObjects,
// eaDraws //
// );
// }
fima2Signaller.poiDetector.AnalyseMarket(
cBar,
marketStructure,
detectorConfig //
);
CArrayObj *iObjects;
int drawnsCount = fima2Signaller.poiDrawer.DrawMarketStructure(
marketStructure,
marketStructureDrawerConfig,
iObjects //
);
if (IsValidSize(drawnsCount))
{
//
AddObjects(
iObjects,
eaDraws //
);
}
// //
//
// if (HasDirection(marketStructure.signalKeyBarPatternDir))
// {
// Print("Detected ...");
@@ -496,10 +503,25 @@ void OnTick()
// {
// Print("Detected ...");
// }
// if (marketStructure.support.IsValid() || marketStructure.resistance.IsValid())
// {
// Print("Detected ...");
// }
if (marketStructure.support.IsValid() || marketStructure.resistance.IsValid())
{
//
// Check Conditions ...
datetime beforeTime = cBar.BeforeOn();
bool hasSupport =
(marketStructure.support.IsValid() &&
marketStructure.support.from == beforeTime);
bool hasResistance =
(marketStructure.resistance.IsValid() &&
marketStructure.resistance.from == beforeTime);
bool has =
hasSupport ||
hasResistance;
if (has)
{
Print("Detected ...");
}
}
}
//
@@ -680,44 +702,44 @@ void OnSignalTriggered(XSignal &signal)
eaDraws.Add(iObj);
}
//
// Here We Apply Custom Detecting ...
detectorConfig.OffDetectors();
detectorConfig.detectSupport = true;
detectorConfig.detectResistance= true;
detectorConfig.detectSignalKeyBarPattern = true;
// //
// // Here We Apply Custom Detecting ...
// detectorConfig.OffDetectors();
// detectorConfig.detectSupport = true;
// detectorConfig.detectResistance= true;
// detectorConfig.detectSignalKeyBarPattern = true;
//
// Initial Bar for Analysis ...
// at Signal Time ...
XOHCL signalBar;
bool isInited = signalBar.Init(
signal.symbol,
signal.period,
signal.time //
);
// //
// // Initial Bar for Analysis ...
// // at Signal Time ...
// XOHCL signalBar;
// bool isInited = signalBar.Init(
// signal.symbol,
// signal.period,
// signal.time //
// );
//
// Analyse Market ...
fima1Signaller.poiDetector.AnalyseMarket(
signalBar,
marketStructure,
detectorConfig //
);
CArrayObj *iObjects;
int drawnsCount = fima2Signaller.poiDrawer.DrawMarketStructure(
marketStructure,
marketStructureDrawerConfig,
iObjects //
);
if (IsValidSize(drawnsCount))
{
//
AddObjects(
iObjects,
eaDraws //
);
}
// //
// // Analyse Market ...
// fima1Signaller.poiDetector.AnalyseMarket(
// signalBar,
// marketStructure,
// detectorConfig //
// );
// CArrayObj *iObjects;
// int drawnsCount = fima2Signaller.poiDrawer.DrawMarketStructure(
// marketStructure,
// marketStructureDrawerConfig,
// iObjects //
// );
// if (IsValidSize(drawnsCount))
// {
// //
// AddObjects(
// iObjects,
// eaDraws //
// );
// }
//
// Alert Issued Signal ...