This commit is contained in:
2025-03-23 03:46:13 +03:30
parent a84b0befe2
commit c49abe21db
10 changed files with 4204 additions and 2932 deletions
File diff suppressed because it is too large Load Diff
@@ -172,9 +172,8 @@ class XCX121SMCXWZSignalDetector : public XCBase
double point = 0;
double targets[];
double reward = 0;
XBoxZone signalBox;
XSignalBox signalBox;
bool hasTrend = false;
XBoxZone signalHolderBox;
bool hasPriority = false;
double amountPercent = -1;
bool hasSignalBox = false;
@@ -279,18 +278,14 @@ class XCX121SMCXWZSignalDetector : public XCBase
//
// Draw Working Zone ...
if (hasWorkingZone)
{
workingZone.Draw(
drawer,
//
workingZone.Draw(
drawer,
//
true, // Draw Supply Zone ...
true, // Draw Demand Zone ...
true, // Draw Waiting Zones ...
true // Draw Trend ...
);
}
false, // Draw Supply Zone ...
false, // Draw Demand Zone ...
true, // Draw Waiting Zones ...
false // Draw Trend ...
);
//
// Detect Signal Box ...
@@ -298,7 +293,6 @@ class XCX121SMCXWZSignalDetector : public XCBase
hasWorkingZone &&
workingZone.DetectSignalConditions(
signalBox,
signalHolderBox,
signalBoxDir,
signalProvider,
provider,
@@ -306,6 +300,10 @@ class XCX121SMCXWZSignalDetector : public XCBase
);
//
// Remove Signal Box form
// Waiting Boxes and Breaked Boxes
// if Exists on them, then add it to
// UnAvailable Boxes ...
if (hasSignalBox)
{
//
@@ -355,6 +353,13 @@ class XCX121SMCXWZSignalDetector : public XCBase
);
}
}
//
// Adding to UnAvailable Box ...
AddRef(
signalBox,
workingZone.unavailableBoxes //
);
}
//
@@ -367,27 +372,30 @@ class XCX121SMCXWZSignalDetector : public XCBase
{
//
signalBox.Clean();
signalHolderBox.Clean();
signalBoxDir = X_DIRECTION_NONE;
}
//
// Check Priority Exists ...
hasPriority = workingZone
.DetectPriority(
priority,
signalBoxDir,
zIndex,
period //
);
hasPriority =
hasWorkingZone &&
workingZone
.DetectPriority(
priority,
signalBoxDir,
zIndex,
period //
);
//
// Check Price Reward and Amount Exists ...
hasRewardAmount = CalculateRiskReward(
priority,
reward,
amountPercent //
);
hasRewardAmount =
hasWorkingZone &&
CalculateRiskReward(
priority,
reward,
amountPercent //
);
//
// Check Signal Conditions ...
@@ -399,37 +407,22 @@ class XCX121SMCXWZSignalDetector : public XCBase
//
// Draw Signal Box ...
XCBoxObject *iSignalBoxObj;
has = drawer.DrawBox(
XCBaseObject *objects[];
has = drawer.DrawSignalBox(
signalBox,
iSignalBoxObj //
objects,
clrYellow //
);
if (has)
{
//
iSignalBoxObj.BoxWidth(1);
iSignalBoxObj.BoxColor(clrYellow);
iSignalBoxObj.BoxStyle(STYLE_SOLID);
//
workingZone.mDrawnObjects.Add(iSignalBoxObj);
}
//
// Draw Signal Holder Box if Exists ...
if (signalHolderBox.IsValid())
{
//
XCBoxObject *iSignalHolderBoxObj;
has = drawer.DrawBox(
signalHolderBox,
iSignalHolderBoxObj //
);
if (has)
int count = ArraySize(objects);
for (int i = 0; i < count; i++)
{
workingZone.mDrawnObjects.Add(iSignalHolderBoxObj);
workingZone.mDrawnObjects.Add(objects[i]);
}
}
Clean(objects);
//
// Detect Signal Direction ...
@@ -438,17 +431,17 @@ class XCX121SMCXWZSignalDetector : public XCBase
//
pivot = isBullish
? signalBox.lower
: signalBox.upper;
? signalBox.ob.lower
: signalBox.ob.upper;
//
point = isBullish
? signalBox.upper
: signalBox.lower;
? signalBox.ob.upper
: signalBox.ob.lower;
//
double entry = GetEntry(
signalBox.symbol,
signalBox.ob.symbol,
signalBoxDir //
);
@@ -471,41 +464,12 @@ class XCX121SMCXWZSignalDetector : public XCBase
//
// Select and Provide SL Based on ...
double iAtr = 0;
if (signalProvider == X121SMC_XWZ_PROVIDER_XHKMA)
if (signalProvider == X121SMC_XWZ_PROVIDER_XREJECTED_BOX)
{
//
iAtr = provider.decisionXConditions.atrBuffer[1];
iAtr *= 0;
//
// Prepare Box fro SL ...
iSL = pivot;
Add(
iSL,
sls //
);
//
// Fix rf Reward ...
rfRewar = 2;
}
else if (signalProvider == X121SMC_XWZ_PROVIDER_XREJECTED_BOX)
{
//
iAtr = provider.decisionXConditions.atrBuffer[1];
iAtr *= 0;
//
Clean(sls);
//
// Prepare Box fro SL ...
iSL = signalBox.lower + ((signalBox.upper - signalBox.lower) / 2);
Add(
iSL,
sls //
);
//
// Fix rf Reward ...
rfRewar = 2;
@@ -900,7 +864,7 @@ class XCX121SMCXWZSignalDetector : public XCBase
mConditions.setupTime = cTime;
mConditions.dir = signalBoxDir;
mConditions.priority = priority;
mConditions.signalBox = signalBox;
mConditions.signalBox = signalBox.ob;
mConditions.provider = signalProvider;
mConditions.amountPercent = amountPercent;
}
@@ -921,7 +885,6 @@ class XCX121SMCXWZSignalDetector : public XCBase
//
signalBox.Clean();
signalHolderBox.Clean();
consolidationZBar.Clean();
//
+241 -385
View File
@@ -31,7 +31,6 @@
enum ENUM_X121SMC_XWZ_PROVIDERS
{
X121SMC_XWZ_PROVIDER_NONE,
X121SMC_XWZ_PROVIDER_XHKMA,
X121SMC_XWZ_PROVIDER_XBREAKED_BOX,
X121SMC_XWZ_PROVIDER_XREJECTED_BOX,
X121SMC_XWZ_PROVIDER_XACTIVATED_BOX,
@@ -488,6 +487,7 @@ struct X121SMCStrategyXWZWorkingZone
int idx = -1;
int count = 0;
bool has = false;
datetime cTime = TimeCurrent();
//
if (barIndex < 0)
@@ -559,235 +559,19 @@ struct X121SMCStrategyXWZWorkingZone
}
//
// Select Order Blocks ...
if (obStateEvents.hasNewOrderBlock)
{
//
idx = GetYoungest(obState.orderBlocks);
has = IsValidIndex(idx);
if (has)
{
//
XCFVG *iFVG = NULL;
XCOrderBlock *iOB = obState.orderBlocks[idx];
bool isBullish = iOB.IsBullish();
//
// Detecting Inside FVG ...
has = fvgState.HasFairValueGaps();
if (has)
{
//
XCFVG *tmpFVGs[];
count = fvgState.CountFairValueGaps();
for (int i = 0; i < count; i++)
{
//
XCFVG *jFVG = fvgState.fairValueGaps[i];
//
bool isDirPassed = jFVG.GetDirection() == iOB.GetDirection();
bool isFromPassed = jFVG.From() >= iOB.From();
bool isPlacePassed = IsInsideOrDiff(
jFVG,
iOB,
false //
);
//
has = isDirPassed &&
isFromPassed &&
isPlacePassed;
if (has)
{
//
Add(
jFVG,
tmpFVGs //
);
}
//
ZeroMemory(jFVG);
}
//
// Selecting iFVG Based on Direction of OB ...
has = HasChild(tmpFVGs);
if (has)
{
//
idx =
isBullish
? GetLowest(tmpFVGs)
: GetHighest(tmpFVGs);
has = IsValidIndex(idx);
if (has)
{
iFVG = tmpFVGs[idx];
}
}
//
Clean(tmpFVGs);
}
//
XBoxZone iOBBox;
XBoxZone iFVGBox;
if (iFVG != NULL)
{
//
has = ToBox(
iFVGBox,
iFVG //
);
}
//
has = ToBox(
iOBBox,
iOB //
);
//
has = iOBBox.IsValid() &&
iFVGBox.IsValid();
if (has)
{
//
XSignalBox iSignalBox;
//
iSignalBox.ob = iOBBox;
iSignalBox.fvg = iFVGBox;
//
// Here We Check Waiting Box Contains Other Zones ...
// Like Support/Resistances ...
bool forceVerification = false;
if (forceVerification)
{
//
XBoxZone iVerificationBox;
XBoxZone tmpBoxes[];
if (isBullish)
{
//
ToBox(
provider.decisionState.supportZones,
tmpBoxes //
);
}
else
{
//
ToBox(
provider.decisionState.resistanceZones,
tmpBoxes //
);
}
has = HasChild(tmpBoxes);
if (has)
{
//
while (HasChild(tmpBoxes))
{
//
idx = GetYoungest(tmpBoxes);
has = IsValidIndex(idx);
if (!has)
{
break;
}
//
// Select Box ...
XBoxZone iBox = tmpBoxes[idx];
ArrayRemove(
tmpBoxes,
idx,
1 //
);
//
// Validate Box ...
bool isValidPassed = !IsBoxValid(
iBox,
barIndex //
);
bool isDirPassed = iBox.dir == iOBBox.dir;
bool isPlacePassed =
IsBoxInside(
iBox,
iOBBox //
)
//
&&
//
(!iFVGBox.IsValid()
? true
: IsBoxInsideOr(
iBox,
iFVGBox //
));
//
has =
isDirPassed &&
isValidPassed &&
isPlacePassed;
if (has)
{
//
iVerificationBox = iBox;
iBox.Clean();
break;
}
//
iBox.Clean();
}
}
has = iVerificationBox.IsValid();
Clean(tmpBoxes);
iVerificationBox.Clean();
}
//
if (has)
{
//
AddRef(
iSignalBox,
waitingBoxes //
);
}
//
iSignalBox.Clean();
}
//
iOBBox.Clean();
iFVGBox.Clean();
ZeroMemory(iOB);
ZeroMemory(iFVG);
}
}
//
// Checking Other Senario for Waiting Boxes ...
// Detect a Sharp Zone Which Contains
// an Order Block and Also an FVG ...
if (obStateEvents.hasNewSharp)
{
//
XBoxZone ob;
XBoxZone fvg;
XBoxZone currSharp;
XBoxZone prevSharp;
XBoxZone sharpConsolidation;
//
// Retrieve Current Sharp ...
XCPOIDrawer *drawer = provider.visionCycleHelper.mPOIDrawer;
XBoxZone tmpBoxes[];
Copy(
obState.sharps,
@@ -906,37 +690,225 @@ struct X121SMCStrategyXWZWorkingZone
}
//
// Detect Order Block / FVG ...
has = sharpConsolidation.IsValid();
if (has)
{
//
// Check Direction ...
bool isBullish = sharpConsolidation.IsBullish();
//
// Find Inside Order Block ...
Clean(tmpBoxes);
if (isBullish)
{
//
ToBox(
obState.bullishOrderBlocks,
tmpBoxes //
);
}
else
{
//
ToBox(
obState.bearishOrderBlocks,
tmpBoxes //
);
}
//
// Select Order Block ...
has = HasChild(tmpBoxes);
if (has)
{
//
while (HasChild(tmpBoxes))
{
//
idx = GetYoungest(tmpBoxes);
has = IsValidIndex(idx);
if (!has)
{
break;
}
//
XBoxZone iBox = tmpBoxes[idx];
ArrayRemove(
tmpBoxes,
idx,
1 //
);
//
// Validate Selected Box ...
bool isDirPassed = iBox.dir == sharpConsolidation.dir;
bool isFromPassed = iBox.from > sharpConsolidation.from;
bool isInsidePassed = IsBoxInside(
iBox,
sharpConsolidation //
);
bool isValidationPassed = IsBoxValid(
iBox,
barIndex //
);
//
has = isDirPassed &&
isFromPassed &&
isInsidePassed &&
isValidationPassed;
if (has)
{
ob = iBox;
}
//
iBox.Clean();
//
if (ob.IsValid())
{
break;
}
}
}
Clean(tmpBoxes);
//
// Find Inside FVG ...
has = ob.IsValid();
if (has)
{
//
Clean(tmpBoxes);
if (isBullish)
{
//
ToBox(
fvgState.bullishFairValueGaps,
tmpBoxes //
);
}
else
{
//
ToBox(
fvgState.bearishFairValueGaps,
tmpBoxes //
);
}
//
// Select FVG ...
has = HasChild(tmpBoxes);
if (has)
{
//
while (HasChild(tmpBoxes))
{
//
idx = isBullish
? GetLowest(tmpBoxes)
: GetHighest(tmpBoxes);
has = IsValidIndex(idx);
if (!has)
{
break;
}
//
XBoxZone iBox = tmpBoxes[idx];
ArrayRemove(
tmpBoxes,
idx,
1 //
);
//
// Validate Selected Box ...
bool isDirPassed = iBox.dir == ob.dir;
bool isFromPassed = iBox.from > ob.from;
bool isInsidePassed = IsBoxInside(
iBox,
ob //
);
//
has = isDirPassed &&
isFromPassed &&
isInsidePassed;
if (has)
{
fvg = iBox;
}
//
iBox.Clean();
//
if (fvg.IsValid())
{
break;
}
}
}
Clean(tmpBoxes);
}
}
//
// Checking Validation of Boxes ...
has = ob.IsValid() &&
fvg.IsValid() &&
sharpConsolidation.IsValid();
if (has)
{
//
// Update Time ...
ob.to = cTime;
fvg.to = cTime;
sharpConsolidation.to = cTime;
//
XSignalBox iSBox;
//
iSBox.ob = ob;
iSBox.fvg = fvg;
iSBox.sharp = sharpConsolidation;
//
has = iSBox.IsValid();
if (has)
{
//
AddRef(
iSBox,
waitingBoxes //
);
}
//
iSBox.Clean();
}
//
ob.Clean();
fvg.Clean();
toBar.Clean();
currSharp.Clean();
prevSharp.Clean();
sharpConsolidation.Clean();
}
//
if (has)
{
//
XCBoxObject *iCurrObj;
XCBoxObject *iPrevObj;
XCBoxObject *iSharpConsolidationObj;
has = drawer.DrawBox(
currSharp,
iCurrObj //
);
has =
has &&
drawer.DrawBox(
prevSharp,
iPrevObj //
);
has =
has &&
drawer.DrawBox(
sharpConsolidation,
iSharpConsolidationObj //
);
if (has)
{
Print("Sharp Detection ...");
}
}
Clean(tmpBoxes);
currSharp.Clean();
prevSharp.Clean();
sharpConsolidation.Clean();
}
//
@@ -1017,15 +989,6 @@ struct X121SMCStrategyXWZWorkingZone
//
has = isInite &&
(
//
IsBoxBreaked(
iBox.fvg,
iBar.Index() - 1,
barIndex,
period //
)
//
||
//
IsBoxBreaked(
iBox.ob,
@@ -1335,14 +1298,7 @@ struct X121SMCStrategyXWZWorkingZone
count = CountWaitingBoxes();
for (int i = 0; i < count; i++)
{
//
waitingBoxes[i].ob.to = value;
//
if (waitingBoxes[i].fvg.IsValid())
{
waitingBoxes[i].fvg.to = value;
}
waitingBoxes[i].UpdateTo(value);
}
}
@@ -1443,7 +1399,6 @@ struct X121SMCStrategyXWZWorkingZone
* Detect Signal Box Conditions ...
*
* @param box: XBoxZone instance reference, Signalled Box ...
* @param holderBox: XBoxZone instance reference, Signalled Holder Box ...
* @param dir: ENUM_X_DIRECTION member, Specified Signal Direction ...
* @param signalProvider: ENUM_X121SMC_XWZ_PROVIDERS member, Specified Signal Type ...
* @param provider: X121SMCStrategySignalProviderData instance reference ...
@@ -1452,8 +1407,7 @@ struct X121SMCStrategyXWZWorkingZone
* @return ( bool )
*/
bool DetectSignalConditions(
XBoxZone &box,
XBoxZone &holderBox,
XSignalBox &box,
ENUM_X_DIRECTION &dir,
ENUM_X121SMC_XWZ_PROVIDERS &signalProvider,
X121SMCStrategySignalProviderData &provider,
@@ -1468,7 +1422,6 @@ struct X121SMCStrategyXWZWorkingZone
//
box.Clean();
holderBox.Clean();
dir = X_DIRECTION_NONE;
signalProvider = X121SMC_XWZ_PROVIDER_NONE;
@@ -1507,14 +1460,14 @@ struct X121SMCStrategyXWZWorkingZone
// ---------------------------------------------
// Rejected Box ...
// ---------------------------------------------
bool useSenario1 = true;
bool useSenario1 = false;
bool isSenario1Happend = false;
bool isSenario1Bullish = false;
bool isSenario1Bearish = false;
if (useSenario1)
{
//
isSenario1Happend = cParser.HasSenario1Conditions(
isSenario1Happend = cParser.HasRejectedBoxConditions(
X_CYCLE_DECISION,
box,
holderBox,
@@ -1553,32 +1506,6 @@ struct X121SMCStrategyXWZWorkingZone
if (!isSenario1Happend &&
useSenario2)
{
//
isSenario2Happend = cParser.HasSenario2Conditions(
X_CYCLE_DECISION,
box,
holderBox,
dir,
waitingBoxes,
provider,
barIndex //
);
//
isSenario2Bullish =
isSenario2Happend &&
IsBullish(dir);
//
isSenario2Bearish =
isSenario2Happend &&
IsBearish(dir);
//
if (isSenario2Happend)
{
signalProvider = X121SMC_XWZ_PROVIDER_XACTIVATED_BOX;
}
}
//
@@ -1594,32 +1521,6 @@ struct X121SMCStrategyXWZWorkingZone
!isSenario2Happend &&
useSenario3)
{
//
isSenario3Happend = cParser.HasSenario3Conditions(
X_CYCLE_DECISION,
box,
holderBox,
dir,
waitingBoxes,
provider,
barIndex //
);
//
isSenario3Bullish =
isSenario3Happend &&
IsBullish(dir);
//
isSenario3Bearish =
isSenario3Happend &&
IsBearish(dir);
//
if (isSenario3Happend)
{
signalProvider = X121SMC_XWZ_PROVIDER_XBREAKED_BOX;
}
}
//
@@ -1636,40 +1537,14 @@ struct X121SMCStrategyXWZWorkingZone
!isSenario3Happend &&
useSenario4)
{
//
isSenario4Happend = cParser.HasSenario4Conditions(
X_CYCLE_DECISION,
trend,
box,
holderBox,
dir,
waitingBoxes,
provider,
barIndex //
);
//
isSenario4Bullish =
isSenario4Happend &&
IsBullish(dir);
//
isSenario4Bearish =
isSenario4Happend &&
IsBearish(dir);
//
if (isSenario4Happend)
{
signalProvider = X121SMC_XWZ_PROVIDER_XHKMA;
}
}
//
// Senario 5:
// ---------------------------------------------
// XSHCNZ Signal Box Detection Conditions ...
// ---------------------------------------------
bool useSenario5 = false;
bool useSenario5 = true;
bool isSenario5Happend = false;
bool isSenario5Bullish = false;
bool isSenario5Bearish = false;
@@ -1708,7 +1583,8 @@ struct X121SMCStrategyXWZWorkingZone
isSenario2Bullish ||
isSenario3Bullish ||
isSenario4Bullish ||
isSenario5Bullish
isSenario5Bullish ||
isSenario6Bullish
//
;
@@ -1719,7 +1595,8 @@ struct X121SMCStrategyXWZWorkingZone
isSenario2Bearish ||
isSenario3Bearish ||
isSenario4Bearish ||
isSenario5Bearish
isSenario5Bearish ||
isSenario6Bearish
//
;
@@ -1876,13 +1753,13 @@ struct X121SMCStrategyXWZWorkingZone
*
* @param drawSupplyZone: boolean ...
* @param drawDemandZone: boolean ...
* @param drawWaitingZones: boolean ...
* @param drawWaitingBoxes: boolean ...
*/
void Draw(
XCPOIDrawer *drawer,
bool drawSupplyZone = false,
bool drawDemandZone = false,
bool drawWaitingZones = false,
bool drawWaitingBoxes = false,
bool drawTrend = false //
)
{
@@ -2108,7 +1985,7 @@ struct X121SMCStrategyXWZWorkingZone
//
// Waiting Zones ...
if (drawWaitingZones)
if (drawWaitingBoxes)
{
//
has = HasWaitingBoxes();
@@ -2119,42 +1996,21 @@ struct X121SMCStrategyXWZWorkingZone
for (int i = 0; i < count; i++)
{
//
// OB ...
XCBoxObject *iOBBoxObj;
has = drawer.DrawBox(
waitingBoxes[i].ob,
iOBBoxObj //
XCBaseObject *objects[];
has = drawer.DrawSignalBox(
waitingBoxes[i],
objects //
);
if (has)
{
mDrawnObjects.Add(iOBBoxObj);
}
//
// FVG ...
if (waitingBoxes[i].fvg.IsValid())
{
//
XCBoxObject *iFVGBoxObj;
has = drawer.DrawBox(
waitingBoxes[i].fvg,
iFVGBoxObj //
);
if (has)
count = ArraySize(objects);
for (int i = 0; i < count; i++)
{
//
iFVGBoxObj.BoxStyle(STYLE_SOLID);
//
mDrawnObjects.Add(iFVGBoxObj);
mWorkingZoneObjects.Add(objects[i]);
}
//
ZeroMemory(iFVGBoxObj);
}
//
ZeroMemory(iOBBoxObj);
Clean(objects);
}
}
}
@@ -835,8 +835,8 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
// XVWAP ...
x121Inputs.xvwapInputs.showVWapFast = showAll || false;
x121Inputs.xvwapInputs.showVWapMedium = showAll || false;
x121Inputs.xvwapInputs.showVWapFast = showAll || true;
x121Inputs.xvwapInputs.showVWapMedium = showAll || true;
x121Inputs.xvwapInputs.showVWapSlow = showAll || false;
//