This commit is contained in:
2025-03-07 11:53:51 +03:30
parent 5534bde7e5
commit f050a00b44
5 changed files with 1119 additions and 68 deletions
+516 -38
View File
@@ -30,10 +30,8 @@
enum ENUM_X121SMC_XWZ_PROVIDERS
{
X121SMC_XWZ_PROVIDER_NONE,
X121SMC_XWZ_PROVIDER_PV_ZONE,
X121SMC_XWZ_PROVIDER_ACTIVATED_BOX,
X121SMC_XWZ_PROVIDER_ACTIVATED_ZONE,
X121SMC_XWZ_PROVIDER_ACTIVATED_CHOCH,
X121SMC_XWZ_PROVIDER_PRICE_INSIDE_ZONE,
};
//
@@ -73,6 +71,10 @@ struct X121SMCStrategyXWZWorkingZone
XOBFVG waitingZones[];
XOBFVG unavailableZones[];
//
XBoxZone waitingBoxes[];
XBoxZone unavailableBoxes[];
//
CArrayObj mDrawnObjects;
CArrayObj mWorkingZoneObjects;
@@ -101,6 +103,11 @@ struct X121SMCStrategyXWZWorkingZone
//
Clean(waitingZones);
Clean(unavailableZones);
//
Clean(waitingBoxes);
Clean(unavailableBoxes);
//
ZeroMemory(supplyZone);
@@ -461,7 +468,8 @@ struct X121SMCStrategyXWZWorkingZone
//
// Detect OB FVG ...
if (hasNewOrderBlock)
if (false &&
hasNewOrderBlock)
{
//
XOHCL obStartedBar;
@@ -596,6 +604,104 @@ struct X121SMCStrategyXWZWorkingZone
obStartedBar.Clean();
}
//
//
//
//
// Check New Order Block Detection Analyse ...
XBoxZone analyseOBBox;
XCOrderBlock *analyseOB = NULL;
bool hasNewAnalyseOrderBlock =
Contains(
X_BULLISH_ORDERBLOCK_DETECTED,
provider
.analysePoiEvents //
) ||
Contains(
X_BEARISH_ORDERBLOCK_DETECTED,
provider
.analysePoiEvents //
);
if (hasNewAnalyseOrderBlock)
{
//
idx = GetYoungest(provider
.analyseState
.orderBlocks //
);
has = IsValidIndex(idx);
if (has)
{
//
analyseOB = provider
.analyseState
.orderBlocks[idx];
has = ToBox(
analyseOBBox,
analyseOB //
);
if (has)
{
//
analyseOB.To(cTime);
analyseOBBox.to = cTime;
hasNewAnalyseOrderBlock = analyseOBBox.IsValid();
}
}
}
//
// Checking Analyse Order Block ...
if (hasNewAnalyseOrderBlock)
{
//
XCBaseObject *iObj;
has = provider
.visionCycleHelper
.mPOIDrawer
.CreateOrderBlock(
analyseOB,
iObj //
);
if (has)
{
//
XOHCL obStartedBar;
bool isOBStartedBodyOut = false;
bool isOBStarted = analyseOB.IsStarted(
analyseOB.GetDirection(),
obStartedBar,
isOBStartedBodyOut //
);
//
has = isOBStarted &&
isOBStartedBodyOut;
if (has)
{
//
has = IsExists(analyseOBBox);
if (!has)
{
//
AddRef(
analyseOBBox,
waitingBoxes //
);
}
}
}
}
//
analyseOBBox.Clean();
ZeroMemory(analyseOB);
//
//
//
//
result = HasWaitingZones();
@@ -694,6 +800,83 @@ struct X121SMCStrategyXWZWorkingZone
return result;
}
//
int ValidateWaitingBoxes(
int barIndex = 0 //
)
{
//
int result = 0;
//
bool has = false;
//
if (barIndex < 0)
{
barIndex = 0;
}
//
if (barIndex == 0)
{
barIndex = 1;
}
//
has = IsValid() &&
HasWaitingBoxes();
if (!has)
{
return result;
}
//
int removeIDX[];
result = CountWaitingBoxes();
for (int i = 0; i < result; i++)
{
//
has = IsValidBox(
waitingBoxes[i],
barIndex,
period //
);
if (!has)
{
//
Add(
i,
removeIDX //
);
//
AddRef(
waitingBoxes[i],
unavailableBoxes //
);
}
}
//
has = HasChild(removeIDX);
if (has)
{
//
CleanupArray(
removeIDX,
waitingBoxes //
);
}
Clean(removeIDX);
//
result = CountWaitingBoxes();
//
return result;
}
//
bool IsZoneActivated(
int &zoneIDX,
@@ -848,17 +1031,17 @@ struct X121SMCStrategyXWZWorkingZone
// Activate Zone Using PV ...
bool isPVPassed =
isBullish
? vale < iBox.upper &&
vale > iBox.lower
: peak < iBox.upper &&
peak > iBox.lower;
? vale <= iBox.upper &&
vale >= iBox.lower
: peak <= iBox.upper &&
peak >= iBox.lower;
bool isPV50Passed =
isBullish
? vale < iBox.upper &&
vale < iRange &&
vale <= iRange &&
vale > iBox.lower
: peak < iBox.upper &&
peak < iRange &&
peak >= iRange &&
peak > iBox.lower;
//
@@ -872,7 +1055,8 @@ struct X121SMCStrategyXWZWorkingZone
//
// Combine Result ...
result = isPV50Passed;
result = isPVPassed;
// || isPVPassed
// || isPV50Passed
// || isRejected;
if (result)
@@ -933,6 +1117,194 @@ struct X121SMCStrategyXWZWorkingZone
return result;
}
//
bool IsBoxActivated(
int &boxIDX,
X121SMCStrategySignalProviderData &provider,
int barIndex = 0 //
)
{
//
bool result = false;
//
boxIDX = -1;
//
if (barIndex < 0)
{
barIndex = 0;
}
//
result = IsValid() &&
HasWaitingBoxes();
if (!result)
{
return result;
}
//
XOHCL bar;
XOHCL cBar;
result = bar.Init(
symbol,
period,
barIndex //
);
result =
result &&
bar.GetPreviousBar(cBar);
if (!result)
{
//
bar.Clean();
cBar.Clean();
//
return result;
}
//
// Retrieve Some Required Data ...
//
double peak = provider.decisionXConditions.peaksBuffer[1];
double vale = provider.decisionXConditions.valesBuffer[1];
//
double analysePeak = provider.analyseXConditions.peaksBuffer[1];
double analyseVale = provider.analyseXConditions.valesBuffer[1];
//
double consolidationPeak = provider.consolidationXConditions.peaksBuffer[1];
double consolidationVale = provider.consolidationXConditions.valesBuffer[1];
//
double visionPeak = provider.visionXConditions.peaksBuffer[1];
double visionVale = provider.visionXConditions.valesBuffer[1];
//
bool isPeaksSame =
peak == analysePeak &&
analysePeak == consolidationPeak;
//
bool isValesSame =
vale == analyseVale &&
analyseVale == consolidationVale;
//
// Calculate Scores Conditions ...
//
bool isDecisionScoreBullish =
provider.decisionBullishScore > provider.decisionBearishScore;
//
bool isDecisionScoreBearish =
provider.decisionBearishScore > provider.decisionBullishScore;
//
bool isAnalyseScoreBullish =
provider.analyseBullishScore > provider.analyseBearishScore;
//
bool isAnalyseScoreBearish =
provider.analyseBearishScore > provider.analyseBullishScore;
//
bool isConsolidationScoreBullish =
provider.consolidationBullishScore > provider.consolidationBearishScore;
//
bool isConsolidationScoreBearish =
provider.consolidationBearishScore > provider.consolidationBullishScore;
//
bool isVisionScoreBullish =
provider.visionBullishScore > provider.visionBearishScore;
//
bool isVisionScoreBearish =
provider.visionBearishScore > provider.visionBullishScore;
//
int count = CountWaitingBoxes();
for (int i = 0; i < count; i++)
{
//
XBoxZone iBox = waitingBoxes[i];
bool isBullish = iBox.IsBullish();
//
// Checking Rejection ...
//
// Bullish ...
bool isBullishRejected =
isBullish &&
cBar.low <= iBox.upper &&
cBar.GetDown() > iBox.upper;
//
// Bearish ...
bool isBearishRejected =
!isBullish &&
cBar.high >= iBox.lower &&
cBar.GetUp() < iBox.lower;
//
// Rejection ...
bool isRejected = isBullishRejected ||
isBearishRejected;
//
// Checking Breaktion ...
//
// Bullish ...
bool isBullishBreaked =
isBullish &&
cBar.high > iBox.upper &&
cBar.GetUp() > iBox.upper &&
cBar.low >= iBox.lower;
//
// Bearish ...
bool isBearishBreaked =
!isBullish &&
cBar.low < iBox.lower &&
cBar.GetDown() < iBox.lower &&
cBar.high <= iBox.upper;
//
// Breaktion ...
bool isBreaked = isBullishBreaked ||
isBearishBreaked;
//
result = isRejected ||
isBreaked;
//
if (result)
{
//
boxIDX = i;
break;
}
//
}
//
bar.Clean();
cBar.Clean();
//
return result;
}
//
bool IsExists(XOBFVG &zone)
{
@@ -941,8 +1313,9 @@ struct X121SMCStrategyXWZWorkingZone
//
// Check Validation ...
result = HasWaitingZones() ||
HasUnavailableZones();
result = zone.IsValid() &&
(HasWaitingZones() ||
HasUnavailableZones());
if (!result)
{
return result;
@@ -979,6 +1352,53 @@ struct X121SMCStrategyXWZWorkingZone
return result;
}
//
bool IsExists(XBoxZone &box)
{
//
bool result = false;
//
// Check Validation ...
result = box.IsValid() &&
(HasWaitingBoxes() ||
HasUnavailableBoxes());
if (!result)
{
return result;
}
//
int idx = -1;
//
// Check Index in Waiting Zones ...
idx = FindIndex(
box,
waitingBoxes //
);
result = IsValidIndex(idx);
if (result)
{
return result;
}
//
// Check Index in Unavailable Zones ...
idx = FindIndex(
box,
unavailableBoxes //
);
result = IsValidIndex(idx);
if (result)
{
return result;
}
//
return result;
}
//
bool IsDestroyed(
int barIndex = 0,
@@ -1330,6 +1750,18 @@ struct X121SMCStrategyXWZWorkingZone
}
}
//
has = HasWaitingBoxes();
if (has)
{
//
count = CountWaitingBoxes();
for (int i = 0; i < count; i++)
{
waitingBoxes[i].to = value;
}
}
//
}
@@ -1338,9 +1770,7 @@ struct X121SMCStrategyXWZWorkingZone
XCPOIDrawer *drawer,
bool drawSupplyZone = false,
bool drawDemandZone = false,
bool drawWaitingZones = false,
bool drawWaitingZonesBoxArea = false //
)
bool drawWaitingZones = false)
{
//
if (drawer == NULL)
@@ -1605,30 +2035,54 @@ struct X121SMCStrategyXWZWorkingZone
}
//
if (drawWaitingZonesBoxArea)
{
//
XBoxZone iBox;
has = waitingZones[i].ToZone(
iBox //
);
if (has)
{
//
XCBoxObject *iBoxObj;
has = drawer.DrawBox(
iBox,
iBoxObj //
);
if (has)
{
mDrawnObjects.Add(iBoxObj);
}
}
// if (drawWaitingZonesBoxArea)
// {
// //
// XBoxZone iBox;
// has = waitingZones[i].ToZone(
// iBox //
// );
// if (has)
// {
// //
// XCBoxObject *iBoxObj;
// has = drawer.DrawBox(
// iBox,
// iBoxObj //
// );
// if (has)
// {
// mDrawnObjects.Add(iBoxObj);
// }
// }
//
iBox.Clean();
// //
// iBox.Clean();
// }
}
}
//
has = HasWaitingBoxes();
if (has)
{
//
count = CountWaitingBoxes();
for (int i = 0; i < count; i++)
{
//
XCBoxObject *iBoxObj;
has = drawer.DrawBox(
waitingBoxes[i],
iBoxObj //
);
if (has)
{
mDrawnObjects.Add(iBoxObj);
}
//
ZeroMemory(iBoxObj);
}
}
}
@@ -1678,6 +2132,30 @@ struct X121SMCStrategyXWZWorkingZone
return ArraySize(unavailableZones);
}
//
bool HasWaitingBoxes()
{
return HasChild(waitingBoxes);
}
//
int CountWaitingBoxes()
{
return ArraySize(waitingBoxes);
}
//
bool HasUnavailableBoxes()
{
return HasChild(unavailableBoxes);
}
//
int CountUnavailableBoxes()
{
return ArraySize(unavailableBoxes);
}
//
};