This commit is contained in:
2025-03-07 03:56:11 +03:30
parent 6157bbe125
commit 5534bde7e5
6 changed files with 3636 additions and 3126 deletions
@@ -164,7 +164,8 @@ class XCX121SMCXWZSignalDetector : public XCBase
double targets[];
double reward = 0;
XBoxZone signalBox;
XOBFVG activatedZone;
int activatedFVGIDX = 0;
int activatedZoneIDX = 0;
double amountPercent = 0;
bool hasPriority = false;
bool hasSignalBox = false;
@@ -214,16 +215,8 @@ class XCX121SMCXWZSignalDetector : public XCBase
//
hasWaitingZones = workingZone.DetectZone(
drawer,
provider //
);
if (hasWaitingZones)
{
//
// Validate Waiting Zones ...
workingZone.ValidateWaitingZones(zIndex);
hasWaitingZones = HasChild(workingZone.waitingZones);
}
//
// Checking Working Zone Destory or not ...
@@ -239,7 +232,6 @@ class XCX121SMCXWZSignalDetector : public XCBase
//
result = false;
workingZone.Clean();
activatedZone.Clean();
hasWorkingZone = false;
//
@@ -255,13 +247,41 @@ class XCX121SMCXWZSignalDetector : public XCBase
}
}
//
// Start Draw ...
//
//
UpdateTo(cTime);
//
// Draw Working Zone ...
if (hasWorkingZone)
{
//
workingZone.Draw(
drawer,
//
true, // Draw Supply Zone ...
true, // Draw Demand Zone ...
true, // Draw Waiting Zones ...
true // Draw Waiting Zones Box Area ...
//
);
}
//
// End Draw ...
//
//
// Detect Signal Box ...
hasSignalBox =
hasWorkingZone &&
hasWaitingZones &&
workingZone.IsZoneActivated(
activatedZone,
activatedZoneIDX,
activatedFVGIDX,
provider,
zIndex //
);
@@ -269,7 +289,14 @@ class XCX121SMCXWZSignalDetector : public XCBase
{
//
signalBox.Clean();
hasSignalBox = activatedZone.ToZone(signalBox);
//
XOBFVG iOBFVG = workingZone.waitingZones[activatedZoneIDX];
XCFVG *activatedFVG = iOBFVG.fvgs[activatedFVGIDX];
hasSignalBox = ToBox(
signalBox,
activatedFVG //
);
if (hasSignalBox)
{
//
@@ -278,27 +305,42 @@ class XCX121SMCXWZSignalDetector : public XCBase
signalProvider = X121SMC_XWZ_PROVIDER_ACTIVATED_ZONE;
//
int idx = FindIndex(
activatedZone,
workingZone.waitingZones //
ArrayRemove(
workingZone.waitingZones[activatedZoneIDX].fvgs,
activatedFVGIDX,
1 //
);
bool has = IsValidIndex(idx);
if (has)
bool isValid = workingZone.waitingZones[activatedZoneIDX].IsValid();
if (!isValid)
{
//
ArrayRemove(
workingZone.waitingZones,
idx,
1 //
AddRef(
workingZone.waitingZones[activatedZoneIDX],
workingZone.unavailableZones //
);
//
AddRef(
activatedZone,
workingZone.unavailableZones //
ArrayRemove(
workingZone.waitingZones,
activatedZoneIDX,
1 //
);
}
}
//
iOBFVG.Clean();
ZeroMemory(activatedFVG);
}
//
// Remove Invalidate Zones ...
if (hasWaitingZones)
{
//
// Validate Waiting Zones ...
workingZone.ValidateWaitingZones(zIndex);
hasWaitingZones = workingZone.HasWaitingZones();
}
//
@@ -314,10 +356,6 @@ class XCX121SMCXWZSignalDetector : public XCBase
signalBoxDir = X_DIRECTION_NONE;
}
//
//
//
//
// Check Priority Exists ...
hasPriority = workingZone
@@ -732,37 +770,11 @@ class XCX121SMCXWZSignalDetector : public XCBase
mConditions.setupTime = cTime;
mConditions.dir = signalBoxDir;
mConditions.priority = priority;
mConditions.provider = signalProvider;
mConditions.signalBox = signalBox;
mConditions.provider = signalProvider;
mConditions.amountPercent = amountPercent;
}
//
UpdateTo(cTime);
//
// Draw Working Zone ...
if (hasWorkingZone)
{
//
workingZone.Draw(
drawer,
//
true, // Draw Supply Zone ...
true, // Draw Demand Zone ...
true, // Draw Waiting Zones ...
true // Draw Waiting Zones Box Area ...
//
);
//
if (hasSignalBox)
{
//
Print("Has Signal Box ...");
}
}
//
//
//
@@ -779,7 +791,6 @@ class XCX121SMCXWZSignalDetector : public XCBase
//
signalBox.Clean();
activatedZone.Clean();
consolidationZBar.Clean();
//
+257 -141
View File
@@ -273,7 +273,6 @@ struct X121SMCStrategyXWZWorkingZone
//
bool DetectZone(
XCPOIDrawer *drawer,
X121SMCStrategySignalProviderData &provider //
)
{
@@ -290,6 +289,7 @@ struct X121SMCStrategyXWZWorkingZone
//
int idx = -1;
int count = 0;
bool has = false;
datetime cTime = TimeCurrent();
@@ -461,15 +461,102 @@ struct X121SMCStrategyXWZWorkingZone
//
// Detect OB FVG ...
result =
hasNewOrderBlock &&
hasNewFairValueGap &&
ob.GetDirection() == fvg.GetDirection();
if (result)
if (hasNewOrderBlock)
{
//
obFVG.ob = ob;
obFVG.AddFVG(fvg);
XOHCL obStartedBar;
bool isOBStartedBodyOut = false;
bool isOBStarted = ob.IsStarted(
ob.GetDirection(),
obStartedBar,
isOBStartedBodyOut //
);
//
has = isOBStarted &&
isOBStartedBodyOut;
if (has)
{
//
obFVG.ob = ob;
//
// Select FVGs ...
count = provider
.analyseState
.CountFairValueGaps();
has = IsValidSize(count);
if (!has)
{
obFVG.Clean();
}
else
{
//
// Select FVG ...
for (int i = 0; i < count; i++)
{
//
XCFVG *iFVG = provider
.analyseState
.fairValueGaps[i];
bool isBullish = iFVG.IsBullish();
//
XOHCL iStartedBar;
bool isBodyOut = false;
bool isStarted = iFVG.IsStarted(
iFVG.GetDirection(),
iStartedBar,
isBodyOut //
);
iStartedBar.Clean();
//
bool isKindPassed = isStarted &&
isBodyOut;
bool isSameDir = iFVG.GetDirection() == ob.GetDirection();
bool isFromPassed = iFVG.From() >= obStartedBar.time;
bool isPlacePassed =
//
IsInsideOrDiff(
iFVG,
ob //
)
//
||
//
(isBullish
? IsAboveDiff(
iFVG,
ob,
true // Ignore Inside ...
)
: IsBelowDiff(
iFVG,
ob,
true // Ignore Inside ...
)
//
)
//
;
//
has = isSameDir &&
isKindPassed &&
isFromPassed &&
isPlacePassed;
if (has)
{
obFVG.AddFVG(iFVG);
}
//
ZeroMemory(iFVG);
}
}
}
//
has = obFVG.IsValid();
@@ -503,98 +590,12 @@ struct X121SMCStrategyXWZWorkingZone
}
}
}
//
obFVG.Clean();
obStartedBar.Clean();
}
//
// Detect SupDem FVG ...
// if (!result)
// {
// //
// result = hasNewFairValueGap &&
// (hasNewSupply ||
// hasNewDemand);
// if (result)
// {
// //
// // Converts Supply or Demand Zone to OrderBlock ...
// XOHCL bar;
// ob = new XCOrderBlock();
// if (hasNewSupply)
// {
// //
// has = supply.FillBar(bar);
// if (has)
// {
// //
// has = ob.Init(
// bar,
// X_DIRECTION_BEARISH //
// );
// if (has)
// {
// //
// ob.Upper(supply.Upper());
// ob.Lower(supply.Lower());
// }
// }
// }
// else if (hasNewDemand)
// {
// //
// has = demand.FillBar(bar);
// if (has)
// {
// //
// has = ob.Init(
// bar,
// X_DIRECTION_BULLISH //
// );
// if (has)
// {
// //
// ob.Upper(demand.Upper());
// ob.Lower(demand.Lower());
// }
// }
// }
// //
// obFVG.ob = ob;
// obFVG.AddFVG(fvg);
// //
// has = obFVG.IsValid();
// if (has)
// {
// //
// // Check Item Is not Exists ...
// idx = FindIndex(
// obFVG,
// waitingZones //
// );
// has = !IsValidIndex(idx);
// if (has)
// {
// //
// // New Waiting Zone ...
// AddRef(
// obFVG,
// waitingZones //
// );
// }
// else
// {
// //
// // Update Exists Waiting Zone ...
// waitingZones[idx].AddFVG(fvg);
// }
// }
// //
// bar.Clean();
// }
// }
//
result = HasWaitingZones();
@@ -635,6 +636,12 @@ struct X121SMCStrategyXWZWorkingZone
barIndex = 0;
}
//
if (barIndex == 0)
{
barIndex = 1;
}
//
has = IsValid() &&
HasWaitingZones();
@@ -649,12 +656,7 @@ struct X121SMCStrategyXWZWorkingZone
for (int i = 0; i < result; i++)
{
//
XOBFVG iOBFVG = waitingZones[i];
//
XOHCL iInvalidBar;
has = iOBFVG.IsValidZone(
iInvalidBar,
has = waitingZones[i].IsValidZone(
barIndex //
);
if (!has)
@@ -667,13 +669,10 @@ struct X121SMCStrategyXWZWorkingZone
//
AddRef(
iOBFVG,
waitingZones[i],
unavailableZones //
);
}
//
iInvalidBar.Clean();
}
//
@@ -697,7 +696,8 @@ struct X121SMCStrategyXWZWorkingZone
//
bool IsZoneActivated(
XOBFVG &zone,
int &zoneIDX,
int &fvgIDX,
X121SMCStrategySignalProviderData &provider,
int barIndex = 0 //
)
@@ -706,8 +706,10 @@ struct X121SMCStrategyXWZWorkingZone
bool result = false;
//
// Cleanup Result ...
zone.Clean();
zoneIDX = -1;
//
fvgIDX = -1;
//
// Normalize Bar Index ...
@@ -742,7 +744,6 @@ struct X121SMCStrategyXWZWorkingZone
{
//
bar.Clean();
zone.Clean();
//
return result;
@@ -752,6 +753,64 @@ struct X121SMCStrategyXWZWorkingZone
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;
//
//
//
//
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 = CountWaitingZones();
for (int i = 0; i < count; i++)
@@ -764,56 +823,112 @@ struct X121SMCStrategyXWZWorkingZone
bool isBullish = iOBFVG.IsBullish();
//
XBoxZone iBox;
result = iOBFVG.ToZone(iBox);
if (!result)
int fvgsCount = iOBFVG.CountFVGs();
bool has = IsValidSize(fvgsCount);
if (has)
{
//
iBox.Clean();
iOBFVG.Clean();
for (int j = 0; j < fvgsCount; j++)
{
//
XCFVG *jFVG = iOBFVG.fvgs[j];
//
continue;
//
XBoxZone iBox;
has = ToBox(
iBox,
jFVG //
);
if (has)
{
//
double iRange = iBox.lower + ((iBox.upper - iBox.lower) / 2);
//
// Activate Zone Using PV ...
bool isPVPassed =
isBullish
? vale < iBox.upper &&
vale > iBox.lower
: peak < iBox.upper &&
peak > iBox.lower;
bool isPV50Passed =
isBullish
? vale < iBox.upper &&
vale < iRange &&
vale > iBox.lower
: peak < iBox.upper &&
peak < iRange &&
peak > iBox.lower;
//
// Activate Zone using Rejection ...
bool isRejected =
isBullish
? bar.low <= iBox.upper &&
bar.GetDown() > iBox.upper
: bar.high >= iBox.lower &&
bar.GetUp() < iBox.lower;
//
// Combine Result ...
result = isPV50Passed;
// || isPV50Passed
// || isRejected;
if (result)
{
//
fvgIDX = j;
iBox.Clean();
zoneIDX = i;
//
break;
}
}
//
if (result)
{
//
iBox.Clean();
ZeroMemory(jFVG);
//
break;
}
//
iBox.Clean();
}
}
//
// XCFVG *fvg;
// result = iOBFVG.GetMainFVG(fvg);
// if (!result)
// {
// //
// iOBFVG.Clean();
// ZeroMemory(fvg);
// //
// continue;
// }
//
result =
isBullish
? vale < iBox.upper &&
vale > iBox.lower
: peak < iBox.upper &&
peak > iBox.lower;
if (result)
{
//
zone = iOBFVG;
iOBFVG.Clean();
break;
}
//
iBox.Clean();
iOBFVG.Clean();
}
//
result = zone.IsValid();
result =
IsValidIndex(fvgIDX) &&
IsValidIndex(zoneIDX);
//
bar.Clean();
//
if (result)
{
bar.Clean();
}
//
return result;
}
@@ -1466,6 +1581,7 @@ struct X121SMCStrategyXWZWorkingZone
iObjects,
true, // Draw Order Block ...
true, // Draw Fair Value Gaps ...
true, // Draw All Fair Value Gaps ...
//
true, // Draw OB StartedBar ...
true, // Draw OB ActivatedBar ...