This commit is contained in:
2025-03-04 16:18:51 +03:30
parent ec006cd6b7
commit 52856ff815
4 changed files with 753 additions and 881 deletions
+429 -3
View File
@@ -47,6 +47,9 @@ enum ENUM_X121SMC_XWZ_PRIORITY
X121SMC_XWZ_PRIORITY_STRONG_HIGH,
};
//
// Definitions ...
//
struct X121SMCStrategyXWZWorkingZone
{
@@ -78,6 +81,7 @@ struct X121SMCStrategyXWZWorkingZone
XBoxZone insideBoxes[];
XBoxZone breakedBoxes[];
XBoxZone waitingBoxes[];
XBoxZone breakedInsideBoxes[];
XConsolidationZone consolidationZones[];
//
@@ -85,8 +89,10 @@ struct X121SMCStrategyXWZWorkingZone
CArrayObj mBreakedZoneObjects;
CArrayObj mWaitingZoneObjects;
CArrayObj mWorkingZoneObjects;
CArrayObj mBreakedInsideZoneObjects;
//
bool mUseSupDems;
bool mUseOrderBlocks;
bool mUseFairValueGaps;
@@ -134,10 +140,12 @@ struct X121SMCStrategyXWZWorkingZone
mBreakedZoneObjects.Clear();
mWaitingZoneObjects.Clear();
mWorkingZoneObjects.Clear();
mBreakedInsideZoneObjects.Clear();
//
mUseSupDems = false;
mUseOrderBlocks = true;
mUseFairValueGaps = false;
mUseFairValueGaps = true;
}
//
@@ -271,6 +279,10 @@ struct X121SMCStrategyXWZWorkingZone
}
}
//
//
//
//
// Supply Zones ...
has = HasSupplyZones();
@@ -581,6 +593,102 @@ struct X121SMCStrategyXWZWorkingZone
//
// Update Exists Zones ...
// //
// // Supply Zones ...
// has = mtfState.HasSupplyZones();
// if (has)
// {
// //
// XCSupplyZone *tmpZones[];
// count = mtfState.FilterSupplyZones(
// tmpZones,
// period,
// XZONE_STATE_PASSED,
// false,
// XZONE_STATE_FAILED,
// false,
// XZONE_STATE_FAILED,
// false,
// XZONE_STATE_IGNORED,
// false //
// );
// has = IsValidSize(count);
// if (has)
// {
// //
// for (int i = 0; i < count; i++)
// {
// //
// // Try to Validate Indexes ...
// //
// XCSupplyZone *iZone = tmpZones[i];
// has = IsSupplyExists(iZone);
// if (!has)
// {
// //
// Add(
// iZone,
// supplyZones //
// );
// }
// }
// }
// //
// Clean(tmpZones);
// }
// //
// // Demand Zones ...
// has = mtfState.HasDemandZones();
// if (has)
// {
// //
// XCDemandZone *tmpZones[];
// count = mtfState.FilterDemandZones(
// tmpZones,
// period,
// XZONE_STATE_PASSED,
// false,
// XZONE_STATE_FAILED,
// false,
// XZONE_STATE_FAILED,
// false,
// XZONE_STATE_IGNORED,
// false //
// );
// has = IsValidSize(count);
// if (has)
// {
// //
// for (int i = 0; i < count; i++)
// {
// //
// // Try to Validate Indexes ...
// //
// XCDemandZone *iZone = tmpZones[i];
// has = IsDemandExists(iZone);
// if (!has)
// {
// //
// Add(
// iZone,
// demandZones //
// );
// }
// }
// }
// //
// Clean(tmpZones);
// }
//
//
//
//
// Supply Zones ...
has = HasSupplyZones();
@@ -1647,7 +1755,7 @@ struct X121SMCStrategyXWZWorkingZone
{
//
XCBoxObject *iObj;
bool isCreated= drawer.DrawBox(
bool isCreated = drawer.DrawBox(
signalBox,
iObj //
);
@@ -1763,6 +1871,120 @@ struct X121SMCStrategyXWZWorkingZone
return result;
}
//
bool DetectOveralDirection(
ENUM_X_DIRECTION &dir //
)
{
//
bool result = false;
//
dir = X_DIRECTION_NONE;
//
result = IsValid() &&
HasSupplyZone() &&
HasDemandZone();
if (!result)
{
return result;
}
//
XBoxZone demBox;
XBoxZone supBox;
result = ToBox(
demBox,
demandZone //
);
if (!result)
{
//
supBox.Clean();
demBox.Clean();
//
return result;
}
result = ToBox(
supBox,
supplyZone //
);
if (!result)
{
//
supBox.Clean();
demBox.Clean();
//
return result;
}
//
XOHCL supPriceOutBar;
XOHCL demPriceOutBar;
result = DetectBoxNearestPriceOut(
supBox,
supPriceOutBar,
period //
);
if (!result)
{
//
demBox.Clean();
supBox.Clean();
supPriceOutBar.Clean();
demPriceOutBar.Clean();
//
return result;
}
result = DetectBoxNearestPriceOut(
demBox,
demPriceOutBar,
period //
);
if (!result)
{
//
demBox.Clean();
supBox.Clean();
supPriceOutBar.Clean();
demPriceOutBar.Clean();
//
return result;
}
//
// Specified Direction ...
dir =
(supPriceOutBar.IsValid() &&
demPriceOutBar.IsValid())
? supPriceOutBar.time > demPriceOutBar.time
? X_DIRECTION_BEARISH
: demPriceOutBar.time > supPriceOutBar.time
? X_DIRECTION_BULLISH
: X_DIRECTION_NONE
: X_DIRECTION_NONE;
//
result = HasDirection(dir);
//
// Clean Up Resources ...
//
demBox.Clean();
supBox.Clean();
supPriceOutBar.Clean();
demPriceOutBar.Clean();
//
return result;
}
//
bool HasInsideBox(
XBoxZone &box //
@@ -1868,6 +2090,199 @@ struct X121SMCStrategyXWZWorkingZone
return result;
}
//
bool IsExists(XBoxZone &box)
{
//
bool result = false;
//
result = box.IsValid();
if (!result)
{
return result;
}
//
int idx = -1;
bool has = false;
//
// Checking Index Waiting Box ...
has = HasWaitingBoxes();
if (has)
{
//
idx = FindIndex(
box,
waitingBoxes //
);
result = !IsValidIndex(idx);
if (!result)
{
return result;
}
}
//
// Checking Index Inside Boxes ...
has = HasInsideBoxes();
if (has)
{
//
idx = FindIndex(
box,
insideBoxes //
);
result = !IsValidIndex(idx);
if (!result)
{
return result;
}
}
//
// Checking Index Breaked Boxes ...
has = HasBreakedBoxes();
if (has)
{
//
idx = FindIndex(
box,
breakedBoxes //
);
result = !IsValidIndex(idx);
if (!result)
{
return result;
}
}
//
// Checking Index BreakedInside Boxes ...
has = HasBreakedInsideBoxes();
if (has)
{
//
idx = FindIndex(
box,
breakedInsideBoxes //
);
result = !IsValidIndex(idx);
if (!result)
{
return result;
}
}
//
return result;
}
//
bool IsSupplyExists(XCSupplyZone *zone)
{
//
bool result = false;
//
result = zone != NULL &&
zone.IsValid();
if (!result)
{
return result;
}
//
// Converts Zone to Box ...
XBoxZone box;
result = ToBox(
box,
zone //
);
if (!result)
{
//
box.Clean();
return result;
}
//
// Checking Index in SupplyZones ...
int idx = FindIndex(
zone,
supplyZones //
);
result = !IsValidIndex(idx);
if (!result)
{
//
box.Clean();
return result;
}
//
result = IsExists(box);
//
box.Clean();
//
return result;
}
//
bool IsDemandExists(XCDemandZone *zone)
{
//
bool result = false;
//
result = zone != NULL &&
zone.IsValid();
if (!result)
{
return result;
}
//
// Converts Zone to Box ...
XBoxZone box;
result = ToBox(
box,
zone //
);
if (!result)
{
//
box.Clean();
return result;
}
//
// Checking Index in SupplyZones ...
int idx = FindIndex(
zone,
demandZones //
);
result = !IsValidIndex(idx);
if (!result)
{
//
box.Clean();
return result;
}
//
result = IsExists(box);
//
box.Clean();
//
return result;
}
//
void UpdateTo(datetime value = NULL)
{
@@ -2486,11 +2901,22 @@ struct X121SMCStrategyXWZWorkingZone
return ArraySize(breakedBoxes);
}
//
bool HasBreakedInsideBoxes()
{
return HasChild(breakedInsideBoxes);
}
//
int CountBreakedInsideBoxes()
{
return ArraySize(breakedInsideBoxes);
}
//
};
//
// Definitions ...
struct X121SMCStrategyXWZSignalConditions
{
//