last ...
This commit is contained in:
@@ -1399,151 +1399,6 @@ 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 ...
|
||||
|
||||
@@ -2026,6 +1881,152 @@ class XCMarketPatternDetector : public XCBase
|
||||
protected:
|
||||
//
|
||||
|
||||
//
|
||||
// Tools / Actions ...
|
||||
|
||||
/**
|
||||
* Check Zones and Manage them ...
|
||||
*
|
||||
* @param forBar: XOHCL, reference to Specified Bar ...
|
||||
* @param zones: XBoxZone, reference to Specified Zone Collection ...
|
||||
* @param sortBy: X_SORT_BY_DATE, Sort Zones by ...
|
||||
* @param sortDir: ENUM_X_DIRECTION, Sort Zones in Direction ...
|
||||
* @param maxAllowed: int, Specified Max Allowed Zones ...
|
||||
*/
|
||||
void CheckZones(
|
||||
XOHCL &forBar,
|
||||
XBoxZone &zones[],
|
||||
ENUM_X_SORT_BY sortBy = X_SORT_BY_DATE,
|
||||
ENUM_X_DIRECTION sortDir = X_DIRECTION_BEARISH,
|
||||
int maxAllowed = 50 //
|
||||
)
|
||||
{
|
||||
//
|
||||
// Normalize ...
|
||||
maxAllowed = NormalizeInt(maxAllowed, 0);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool has = forBar.IsValid() &&
|
||||
HasChild(zones);
|
||||
if (!has)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Looping Through Zones ...
|
||||
int count = ArraySize(zones);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
// Check Break ...
|
||||
has = IsXValid(zones[i].breakAt);
|
||||
if (has)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
zones[i].to = forBar.time;
|
||||
|
||||
//
|
||||
// Check for Test ...
|
||||
has = IsTested(
|
||||
forBar,
|
||||
zones[i] //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
forBar.time,
|
||||
zones[i].tests //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Check for Inside ...
|
||||
has = IsInside(
|
||||
forBar,
|
||||
zones[i] //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
forBar.time,
|
||||
zones[i].insides //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Check for Break ...
|
||||
has = IsBreaked(
|
||||
forBar,
|
||||
zones[i] //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
forBar.time,
|
||||
zones[i].breaks //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Check for Act ...
|
||||
has = IsActed(
|
||||
forBar,
|
||||
zones[i] //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
forBar.time,
|
||||
zones[i].acteds //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Check for FakeBreakes ...
|
||||
has = IsFakeBreaked(
|
||||
forBar,
|
||||
zones[i] //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
forBar.time,
|
||||
zones[i].fakeBreaks //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Check for Valid Breakes ...
|
||||
has = IsValidBreaked(
|
||||
forBar,
|
||||
zones[i] //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
zones[i].breakAt = forBar.time;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Apply Sort and Cleanup ...
|
||||
Sort(
|
||||
zones,
|
||||
sortBy,
|
||||
sortDir,
|
||||
maxAllowed //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
|
||||
@@ -638,6 +638,7 @@ class XCPOIDrawer : public XCBase
|
||||
int DrawBoxes(
|
||||
XBoxZone &boxes[],
|
||||
CArrayObj *&objects,
|
||||
bool useTypeName = true,
|
||||
bool ignoreAt = true //
|
||||
)
|
||||
{
|
||||
@@ -658,14 +659,21 @@ class XCPOIDrawer : public XCBase
|
||||
//
|
||||
bool has = false;
|
||||
XCBoxObject *iObj;
|
||||
string name = NULL;
|
||||
int count = ArraySize(boxes);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
if (useTypeName) {
|
||||
name = boxes[i].type;
|
||||
}
|
||||
|
||||
//
|
||||
has = DrawBox(
|
||||
boxes[i],
|
||||
iObj,
|
||||
ignoreAt //
|
||||
ignoreAt,
|
||||
name //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user