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
@@ -164,12 +164,14 @@ class XCX121SMCXWZSignalDetector : public XCBase
double targets[];
double reward = 0;
XBoxZone signalBox;
int activatedFVGIDX = 0;
int activatedZoneIDX = 0;
double amountPercent = 0;
bool hasPriority = false;
int activatedFVGIDX = -1;
int activatedBoxIDX = -1;
int activatedZoneIDX = -1;
double amountPercent = -1;
bool hasSignalBox = false;
bool hasWaitingZones = false;
bool hasWaitingBoxes = false;
bool hasRewardAmount = false;
bool isSignalBoxReversal = false;
bool hasWorkingZoneOveralDirection = false;
@@ -214,10 +216,14 @@ class XCX121SMCXWZSignalDetector : public XCBase
.DetectOveralDirection(wzOveralDir);
//
// Detect Zones and Boxes ...
hasWaitingZones = workingZone.DetectZone(
provider //
);
//
hasWaitingBoxes = workingZone.HasWaitingBoxes();
//
// Checking Working Zone Destory or not ...
bool isWorkingZoneDestroyed = workingZone.IsDestroyed(
@@ -264,8 +270,7 @@ class XCX121SMCXWZSignalDetector : public XCBase
//
true, // Draw Supply Zone ...
true, // Draw Demand Zone ...
true, // Draw Waiting Zones ...
true // Draw Waiting Zones Box Area ...
true // Draw Waiting Zones ...
//
);
}
@@ -276,7 +281,9 @@ class XCX121SMCXWZSignalDetector : public XCBase
//
// Detect Signal Box ...
hasSignalBox =
//
bool isZoneActivated =
hasWorkingZone &&
hasWaitingZones &&
workingZone.IsZoneActivated(
@@ -285,23 +292,38 @@ class XCX121SMCXWZSignalDetector : public XCBase
provider,
zIndex //
);
//
bool isBoxActivated =
hasWorkingZone &&
hasWaitingBoxes &&
workingZone.IsBoxActivated(
activatedBoxIDX,
provider,
zIndex //
);
//
hasSignalBox =
isBoxActivated ||
isZoneActivated;
if (hasSignalBox)
{
//
signalBox.Clean();
//
XOBFVG iOBFVG = workingZone.waitingZones[activatedZoneIDX];
XCFVG *activatedFVG = iOBFVG.fvgs[activatedFVGIDX];
hasSignalBox = ToBox(
signalBox,
activatedFVG //
);
if (hasSignalBox)
if (isZoneActivated)
{
//
signalBox.to = cTime;
signalBoxDir = signalBox.dir;
XOBFVG iOBFVG = workingZone.waitingZones[activatedZoneIDX];
XCFVG *activatedFVG = iOBFVG.fvgs[activatedFVGIDX];
hasSignalBox = ToBox(
signalBox,
activatedFVG //
);
//
signalProvider = X121SMC_XWZ_PROVIDER_ACTIVATED_ZONE;
//
@@ -326,13 +348,48 @@ class XCX121SMCXWZSignalDetector : public XCBase
1 //
);
}
//
iOBFVG.Clean();
ZeroMemory(activatedFVG);
}
//
iOBFVG.Clean();
ZeroMemory(activatedFVG);
if (isBoxActivated)
{
//
signalBox = workingZone.waitingBoxes[activatedBoxIDX];
//
signalProvider = X121SMC_XWZ_PROVIDER_ACTIVATED_BOX;
//
AddRef(
signalBox,
workingZone.unavailableBoxes //
);
//
ArrayRemove(
workingZone.waitingBoxes,
activatedBoxIDX,
1 //
);
}
//
if (hasSignalBox)
{
//
signalBox.to = cTime;
signalBoxDir = signalBox.dir;
}
}
//
//
//
//
// Remove Invalidate Zones ...
if (hasWaitingZones)
@@ -343,6 +400,16 @@ class XCX121SMCXWZSignalDetector : public XCBase
hasWaitingZones = workingZone.HasWaitingZones();
}
//
// Remove InValidate Boxes ...
if (hasWaitingBoxes)
{
//
// Validate Waiting Boxes ...
workingZone.ValidateWaitingBoxes(zIndex);
hasWaitingBoxes = workingZone.HasWaitingBoxes();
}
//
//
//
@@ -413,6 +480,12 @@ class XCX121SMCXWZSignalDetector : public XCBase
? signalBox.upper
: signalBox.lower;
//
double entry = GetEntry(
signalBox.symbol,
signalBoxDir //
);
//
double iSL = 0;
@@ -432,6 +505,11 @@ class XCX121SMCXWZSignalDetector : public XCBase
// }
//
double iAtr = provider.decisionXConditions.atrBuffer[1];
iAtr *= 1.5;
//
// Default SL ...
iSL = pivot;
//
@@ -443,19 +521,13 @@ class XCX121SMCXWZSignalDetector : public XCBase
//
// Select Condition SL ...
//
double entry = GetEntry(
signalBox.symbol,
signalBoxDir //
);
//
double slsMin = GetMin(sls);
double slsMax = GetMax(sls);
//
double longSL = slsMin;
double shortSL = slsMax;
double longSL = slsMin - iAtr;
double shortSL = slsMax + iAtr;
//
sl = isBullish
+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);
}
//
};