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, iBar,
ob, ob,
true, // Force FVG Bar Type ... true, // Force FVG Bar Type ...
true // Force OB First Two Bar InDirection ... true // Force OB First Two Bar InDirection ...
); );
if (!has) if (!has)
{ {
@@ -1224,6 +1224,151 @@ class XCMarketPatternDetector : public XCBase
return result; 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 ... // Trending ...
+90 -68
View File
@@ -456,38 +456,45 @@ void OnTick()
fima1Signaller.OnTick(); fima1Signaller.OnTick();
fima2Signaller.OnTick(); fima2Signaller.OnTick();
// // //
// // Initial Bar for Analysis ... // Initial Bar for Analysis ...
// XOHCL cBar; XOHCL cBar;
// bool isInited = cBar.Init( bool isInited = cBar.Init(
// _Symbol, _Symbol,
// _Period, _Period,
// 1 // 1 //
// ); );
//
// Here We Apply Custom Detecting ...
detectorConfig.OffDetectors();
detectorConfig.detectSupport = true;
detectorConfig.detectResistance = true;
detectorConfig.detectSignalKeyBarPattern = false;
detectorConfig.supportAndResistanceValidationLength = 21;
// //
// Analyse Market ... // Analyse Market ...
// fima2Signaller.poiDetector.AnalyseMarket( fima2Signaller.poiDetector.AnalyseMarket(
// cBar, cBar,
// marketStructure, marketStructure,
// detectorConfig // detectorConfig //
// ); );
// CArrayObj *iObjects; CArrayObj *iObjects;
// int drawnsCount = fima2Signaller.poiDrawer.DrawMarketStructure( int drawnsCount = fima2Signaller.poiDrawer.DrawMarketStructure(
// marketStructure, marketStructure,
// marketStructureDrawerConfig, marketStructureDrawerConfig,
// iObjects // iObjects //
// ); );
// if (IsValidSize(drawnsCount)) if (IsValidSize(drawnsCount))
// { {
// // //
// AddObjects( AddObjects(
// iObjects, iObjects,
// eaDraws // eaDraws //
// ); );
// } }
// // //
// if (HasDirection(marketStructure.signalKeyBarPatternDir)) // if (HasDirection(marketStructure.signalKeyBarPatternDir))
// { // {
// Print("Detected ..."); // Print("Detected ...");
@@ -496,10 +503,25 @@ void OnTick()
// { // {
// Print("Detected ..."); // Print("Detected ...");
// } // }
// if (marketStructure.support.IsValid() || marketStructure.resistance.IsValid()) if (marketStructure.support.IsValid() || marketStructure.resistance.IsValid())
// { {
// Print("Detected ..."); //
// } // 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); eaDraws.Add(iObj);
} }
// // //
// Here We Apply Custom Detecting ... // // Here We Apply Custom Detecting ...
detectorConfig.OffDetectors(); // detectorConfig.OffDetectors();
detectorConfig.detectSupport = true; // detectorConfig.detectSupport = true;
detectorConfig.detectResistance= true; // detectorConfig.detectResistance= true;
detectorConfig.detectSignalKeyBarPattern = true; // detectorConfig.detectSignalKeyBarPattern = true;
// // //
// Initial Bar for Analysis ... // // Initial Bar for Analysis ...
// at Signal Time ... // // at Signal Time ...
XOHCL signalBar; // XOHCL signalBar;
bool isInited = signalBar.Init( // bool isInited = signalBar.Init(
signal.symbol, // signal.symbol,
signal.period, // signal.period,
signal.time // // signal.time //
); // );
// // //
// Analyse Market ... // // Analyse Market ...
fima1Signaller.poiDetector.AnalyseMarket( // fima1Signaller.poiDetector.AnalyseMarket(
signalBar, // signalBar,
marketStructure, // marketStructure,
detectorConfig // // detectorConfig //
); // );
CArrayObj *iObjects; // CArrayObj *iObjects;
int drawnsCount = fima2Signaller.poiDrawer.DrawMarketStructure( // int drawnsCount = fima2Signaller.poiDrawer.DrawMarketStructure(
marketStructure, // marketStructure,
marketStructureDrawerConfig, // marketStructureDrawerConfig,
iObjects // // iObjects //
); // );
if (IsValidSize(drawnsCount)) // if (IsValidSize(drawnsCount))
{ // {
// // //
AddObjects( // AddObjects(
iObjects, // iObjects,
eaDraws // // eaDraws //
); // );
} // }
// //
// Alert Issued Signal ... // Alert Issued Signal ...