This commit is contained in:
2025-03-03 02:29:55 +03:30
parent c9861773ec
commit 6a3fb91e9c
10 changed files with 14692 additions and 4394 deletions
+290 -586
View File
@@ -301,6 +301,27 @@ class XCX121SMCXWZSignalDetector : public XCBase
X121Conditions consolidationXConditions = consolidationConditions.x121Conditions;
X121Conditions visionXConditions = visionConditions.x121Conditions;
//
// Scores ...
//
// Decision ...
double decisionBullishScore = 0;
double decisionBearishScore = 0;
decisionXConditions.GenerateScore(
decisionBullishScore,
decisionBearishScore //
);
//
// Analyse ...
double analyseBullishScore = 0;
double analyseBearishScore = 0;
analyseXConditions.GenerateScore(
analyseBullishScore,
analyseBearishScore //
);
//
// Select Drawer Class ...
XCPOIDrawer *drawer = visionCycleHelper.mPOIDrawer;
@@ -313,17 +334,12 @@ class XCX121SMCXWZSignalDetector : public XCBase
double targets[];
double reward = 0;
XBoxZone signalBox;
XOBFVG selectedZone;
double amountPercent = 0;
bool hasPriority = false;
bool hasSignalBox = false;
bool hasRewardAmount = false;
bool hasSelectedZone = false;
bool isSignalBoxReversal = false;
bool isSelectedZoneReversal = false;
bool hasSelectedConsolidationZone = false;
XConsolidationZone selectedConsolidationZone;
ENUM_X_DIRECTION selectedZoneDir = X_DIRECTION_NONE;
ENUM_X_DIRECTION signalBoxDir = X_DIRECTION_NONE;
ENUM_X121SMC_XWZ_PRIORITY priority = X121SMC_XWZ_PRIORITY_NONE;
ENUM_X121SMC_XWZ_PROVIDERS provider = X121SMC_XWZ_PROVIDER_NONE;
@@ -367,300 +383,165 @@ class XCX121SMCXWZSignalDetector : public XCBase
analyseState,
decisionState //
);
}
//
bool hasWaitingZones = hasWorkingZone &&
workingZone.HasWaitingZones();
//
//
//
//
// Check Conditions if Has Inside Zones ...
bool hasInsideZones = hasWorkingZone &&
workingZone.HasInsideZones();
if (hasInsideZones)
{
//
int selectedIDX = -1;
int count = workingZone.CountInsideZones();
for (int i = 0; i < count; i++)
{
//
bool has = DetectSelectedZoneConditions(
isSelectedZoneReversal,
workingZone.insideZones[i],
decisionState,
decisionXConditions //
);
//
if (has)
{
//
selectedIDX = i;
selectedZone = workingZone.insideZones[i];
//
break;
}
}
//
if (IsValidIndex(selectedIDX))
bool isDestroyed = workingZone.IsDestroyed(
zIndex,
period //
);
if (isDestroyed)
{
//
ArrayRemove(
workingZone.insideZones,
selectedIDX,
1 //
);
//
hasSelectedZone = selectedZone.IsValid();
provider = X121SMC_XWZ_PROVIDER_PRICE_INSIDE_ZONE;
result = false;
workingZone.Clean();
hasWorkingZone = false;
}
}
//
// Check Conditions if Has Breaked Zones ...
bool hasBreakedZones = hasWorkingZone &&
workingZone.HasBreakedZones();
if (hasBreakedZones)
{
// //
// if (!hasSelectedZone)
// {
// //
// int selectedIDX = -1;
// int count = workingZone.CountBreakedZones();
// for (int i = 0; i < count; i++)
// {
// //
// bool has = DetectSelectedZoneConditions(
// isSelectedZoneReversal,
// workingZone.breakedZones[i],
// decisionState,
// decisionXConditions //
// );
// //
// if (has)
// {
// //
// selectedIDX = i;
// selectedZone = workingZone.breakedZones[i];
// //
// break;
// }
// }
// //
// if (IsValidIndex(selectedIDX))
// {
// //
// ArrayRemove(
// workingZone.breakedZones,
// selectedIDX,
// 1 //
// );
// //
// hasSelectedZone = selectedZone.IsValid();
// provider = X121SMC_XWZ_PROVIDER_ACTIVATED_ZONE;
// }
// }
}
//
//
//
//
bool hasInsideBoxes = hasWorkingZone &&
workingZone.HasInsideBoxes();
if (hasInsideBoxes)
// Waiting Box Detected ...
bool hasWaitingBoxes = hasWorkingZone &&
workingZone.HasWaitingBoxes();
if (hasWaitingBoxes)
{
//
XOHCL zBar;
XOHCL cBar;
XOHCL pBar;
int count = 0;
int idx = -1;
bool has = false;
XBoxZone tmpSelectedBox;
int tmpSelectedBoxIDX = -1;
//
has = zBar.Init(
bool isInited = zBar.Init(
symbol,
period,
zIndex //
);
has = has &&
zBar.GetPreviousBar(cBar);
if (has)
isInited =
isInited &&
zBar.GetPreviousBar(cBar);
isInited =
isInited &&
cBar.GetPreviousBar(pBar);
//
count = workingZone.CountWaitingBoxes();
for (int i = 0; i < count; i++)
{
//
count = workingZone.CountInsideBoxes();
for (int i = 0; i < count; i++)
XBoxZone iBox = workingZone.waitingBoxes[i];
ENUM_X_DIRECTION iDir = iBox.dir;
bool isBullish = IsBullish(iDir);
//
// Check Price Rejection ...
//
bool hasBullishFiboPressure =
decisionCycleHelper
.mBarAnalyser
.HasFiboPressure(
cBar,
X_DIRECTION_BULLISH,
X_FIBO_LEVEL_382 //
);
//
bool hasBearishFiboPressure =
decisionCycleHelper
.mBarAnalyser
.HasFiboPressure(
cBar,
X_DIRECTION_BEARISH,
X_FIBO_LEVEL_382 //
);
//
// Bullish Rejection ...
bool isBullishRejected =
//
isInited &&
isBullish &&
cBar.low < pBar.low &&
zBar.low > iBox.upper &&
cBar.low <= iBox.upper &&
zBar.open > iBox.upper &&
hasBullishFiboPressure &&
cBar.GetLowShadow() > pBar.GetLowShadow()
//
;
//
// Bearish Rejection ...
bool isBearishhRejected =
//
isInited &&
!isBullish &&
cBar.high > pBar.high &&
zBar.open < iBox.lower &&
zBar.high < iBox.lower &&
hasBearishFiboPressure &&
cBar.high >= iBox.lower &&
cBar.GetHighShadow() > pBar.GetHighShadow()
//
;
//
has = isBullishRejected ||
isBearishhRejected;
if (has)
{
//
tmpSelectedBox = workingZone.insideBoxes[i];
//
bool isBullish = tmpSelectedBox.IsBullish();
bool isBearish = tmpSelectedBox.IsBearish();
//
bool hasFiboPressure =
visionCycleHelper
.mBarAnalyser
.HasFiboPressure(
cBar,
tmpSelectedBox.dir,
X_FIBO_LEVEL_382 //
);
//
bool isBullishRejectedUpper =
cBar.low < tmpSelectedBox.upper &&
cBar.GetDown() > tmpSelectedBox.upper;
//
bool isBullishRejectedLower =
cBar.low < tmpSelectedBox.lower &&
cBar.GetDown() > tmpSelectedBox.lower;
//
bool isBearishRejectedUpper =
cBar.high > tmpSelectedBox.upper &&
cBar.GetUp() < tmpSelectedBox.upper;
//
bool isBearishRejectedLower =
cBar.high > tmpSelectedBox.lower &&
cBar.GetUp() < tmpSelectedBox.lower;
//
bool isBullishRejected =
// isBullishRejectedUpper ||
isBullishRejectedLower;
//
bool isBearishRejected =
isBearishRejectedUpper
// || isBearishRejectedLower
;
//
bool isMaWapBullish =
//
(decisionXConditions.isX3MaBullishState &&
decisionXConditions.isX3MaBullishOrdered)
//
&&
//
(decisionXConditions.isVWapBullishState &&
decisionXConditions.isVWapBullishOrdered)
//
;
//
bool isMaWapBearish =
//
(decisionXConditions.isX3MaBearishState &&
decisionXConditions.isX3MaBearishOrdered)
//
&&
//
(decisionXConditions.isVWapBearishState &&
decisionXConditions.isVWapBearishOrdered)
//
;
//
bool isX2MaWapInside =
//
(decisionXConditions.x3maFastBuffer[cIndex] < tmpSelectedBox.upper &&
decisionXConditions.x3maMidBuffer[cIndex] < tmpSelectedBox.upper &&
decisionXConditions.x3maFastBuffer[cIndex] > tmpSelectedBox.lower &&
decisionXConditions.x3maMidBuffer[cIndex] > tmpSelectedBox.lower)
//
&&
//
(decisionXConditions.vwapFastBuffer[cIndex] < tmpSelectedBox.upper &&
decisionXConditions.vwapMidBuffer[cIndex] < tmpSelectedBox.upper &&
decisionXConditions.vwapFastBuffer[cIndex] > tmpSelectedBox.lower &&
decisionXConditions.vwapMidBuffer[cIndex] > tmpSelectedBox.lower)
//
;
//
bool isBullishConditions =
//
isBullish &&
isMaWapBearish &&
isX2MaWapInside &&
hasFiboPressure &&
isBullishRejected &&
cBar.low < cBar.GetDown()
//
;
//
bool isBearishConditions =
//
isBearish &&
isMaWapBullish &&
isX2MaWapInside &&
hasFiboPressure &&
isBearishRejected &&
cBar.high > cBar.GetUp()
//
;
//
has = isBullishConditions ||
isBearishConditions;
if (!has)
{
//
tmpSelectedBox.Clean();
continue;
}
//
tmpSelectedBoxIDX = i;
signalBox = tmpSelectedBox;
//
tmpSelectedBox.Clean();
break;
idx = i;
signalBox = iBox;
hasSignalBox = has;
signalBoxDir = iBox.dir;
isSignalBoxReversal = false;
provider = X121SMC_XWZ_PROVIDER_ACTIVATED_ZONE;
}
//
iBox.Clean();
}
//
isSignalBoxReversal = false;
hasSignalBox = signalBox.IsValid();
if (hasSignalBox)
// Remove Signal Box from Waiting Boxes of
// Working Zone ...
if (hasSignalBox &&
IsValidIndex(idx))
{
//
ArrayRemove(
workingZone.insideBoxes,
tmpSelectedBoxIDX,
workingZone.waitingBoxes,
idx,
1 //
);
}
//
// Cleanup Resources ...
//
zBar.Clean();
cBar.Clean();
tmpSelectedBox.Clean();
pBar.Clean();
}
//
// Check Conditions if Has Inside Boxes ...
bool hasInsideBoxes = hasWorkingZone &&
workingZone.HasInsideBoxes();
if (hasInsideBoxes)
{
}
//
// Check Conditions if has Breaked Boxes ...
bool hasBreakedBoxes = hasWorkingZone &&
workingZone.HasBreakedBoxes();
if (hasBreakedBoxes)
@@ -668,8 +549,124 @@ class XCX121SMCXWZSignalDetector : public XCBase
}
//
// Checking Other Conditions ...
if (!hasSignalBox)
{
//
// Score Conditions ...
double scoreMultiplier = 3;
bool isBullishScorePassed =
//
analyseBullishScore > (analyseBearishScore * scoreMultiplier) &&
decisionBullishScore > (decisionBearishScore * scoreMultiplier)
//
;
bool isBearishScorePassed =
//
analyseBearishScore > (analyseBullishScore * scoreMultiplier) &&
decisionBearishScore > (decisionBullishScore * scoreMultiplier)
//
;
//
// X3Ma ...
//
// X3Ma Bullish ...
bool isX3MaBullish =
//
decisionXConditions.isX3MaBullishState &&
decisionXConditions.isX3MaSwitchedToBullishOrdered &&
decisionXConditions.x3maMidBuffer[1] > decisionXConditions.x3maSlowBuffer[1]
//
;
//
// X3Ma Bearish ...
bool isX3MaBearish =
//
decisionXConditions.isX3MaBearishState &&
decisionXConditions.isX3MaSwitchedToBearishOrdered &&
decisionXConditions.x3maMidBuffer[1] < decisionXConditions.x3maSlowBuffer[1]
//
;
//
bool isX3MaHasCondition =
(isX3MaBullish &&
isBullishScorePassed) ||
(isX3MaBearish &&
isBearishScorePassed);
//
// VWap ...
//
// VWap Bullish ...
bool isVWapBullish =
//
decisionXConditions.isVWapBullishState &&
decisionXConditions.isVWapSwitchedToBullishOrdered &&
decisionXConditions.vwapMidBuffer[1] > decisionXConditions.vwapSlowBuffer[1]
//
;
//
// VWap Bearish ...
bool isVWapBearish =
//
decisionXConditions.isVWapBearishState &&
decisionXConditions.isVWapSwitchedToBearishOrdered &&
decisionXConditions.vwapMidBuffer[1] < decisionXConditions.vwapSlowBuffer[1]
//
;
//
bool isVWapHasCondition =
(isVWapBullish &&
isBullishScorePassed) ||
(isVWapBearish &&
isBearishScorePassed);
//
// Checking Other Conditions XWZ Reject on EMA 20 ...
//
// Check Has Conditions ...
bool hasXConditions =
(isX3MaHasCondition ||
isVWapHasCondition);
//
if (hasXConditions)
{
//
if (isX3MaHasCondition)
{
//
signalBoxDir =
isX3MaBullish
? X_DIRECTION_BULLISH
: isX3MaBearish
? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
}
//
if (isVWapHasCondition)
{
//
signalBoxDir =
isVWapBullish
? X_DIRECTION_BULLISH
: isVWapBearish
? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
}
//
Print("X Conditions ...");
}
}
//
@@ -677,285 +674,47 @@ class XCX121SMCXWZSignalDetector : public XCBase
//
//
// Double Check and Prepare Signal Conditions ...
// including Targets and SLs ...
// Check Priority Exists ...
hasPriority = workingZone
.DetectPriority(
priority,
signalBoxDir,
zIndex,
period //
);
//
if (hasSelectedZone)
// Check Price Reward and Amount Exists ...
hasRewardAmount = CalculateRiskReward(
priority,
reward,
amountPercent //
);
//
// Check Signal Conditions ...
if (hasSignalBox)
{
//
int idx = -1;
bool has = false;
//
// Check Consolidation Zones for SL Handling ...
selectedZoneDir =
!isSelectedZoneReversal
? selectedZone.GetDirection()
: Opposit(selectedZone.GetDirection());
bool isSelectedZonDirBullish = IsBullish(selectedZoneDir);
//
if (isSelectedZoneReversal)
{
provider = X121SMC_XWZ_PROVIDER_ACTIVATED_CHOCH;
}
//
// Calculate Priority ...
hasPriority =
hasWorkingZone &&
workingZone
.DetectPriority(
priority,
selectedZoneDir,
zIndex,
period //
);
//
// Calculate Risk Reward Ration based on Priority ...
hasRewardAmount = CalculateRiskReward(
priority,
reward,
amountPercent //
XCBoxObject *iObj;
has = drawer.DrawBox(
signalBox,
iObj //
);
//
// Calculate Pivot and Point ...
//
pivot =
isSelectedZonDirBullish
? selectedZone.ob.Lower()
: selectedZone.ob.Upper();
//
point =
isSelectedZonDirBullish
? selectedZone.ob.Upper()
: selectedZone.ob.Lower();
//
// Detect Targets ...
DetectSelectedZonesTargets(
targets,
selectedZone,
selectedZoneDir,
priority,
workingZone,
zIndex //
);
//
// Detect SLs ...
double iAtr = decisionXConditions.atrBuffer[0];
iAtr *= 1.5;
//
// Default SL is Pivot ...
if (pivot > 0)
if (has)
{
//
Add(
pivot,
sls //
);
iObj.BoxWidth(1);
iObj.BoxColor(clrYellow);
iObj.BoxStyle(STYLE_SOLID);
//
double iSL = iAtr * pivot;
Add(
iSL,
sls //
);
Print("Signal Box Exists ...");
}
//
DetectSelectedZoneSLCandidates(
sls,
selectedZone,
selectedZoneDir,
workingZone,
decisionXConditions,
zIndex,
maxAllowedSLDistanceInPoint //
);
//
// Summaries Conditions ...
result =
pivot > 0 &&
point > 0 &&
hasPriority &&
hasRewardAmount &&
HasDirection(selectedZoneDir);
if (result)
{
//
isBullish = IsBullish(selectedZoneDir);
isBearish = IsBearish(selectedZoneDir);
//
Copy(
sls,
mConditions.sls //
);
Copy(
targets,
mConditions.targets //
);
//
mConditions.pivot = pivot;
mConditions.point = point;
mConditions.reward = reward;
mConditions.setupTime = cTime;
mConditions.priority = priority;
mConditions.provider = provider;
mConditions.dir = selectedZoneDir;
mConditions.signalBox = signalBox;
mConditions.amountPercent = amountPercent;
}
//
// Cleanup Resources ...
//
Clean(sls);
Clean(targets);
selectedZone.Clean();
selectedConsolidationZone.Clean();
}
//
if (hasSignalBox)
{
// //
// workingZone.mInsideZoneObjects.Clear();
// workingZone.mBreakedZoneObjects.Clear();
// workingZone.mWaitingZoneObjects.Clear();
// workingZone.mWorkingZoneObjects.Clear();
// //
// XCBoxObject *iObj;
// signalBox.to = cTime;
// bool isCreated = drawer.CreateBox(
// signalBox,
// iObj //
// );
// //
// if (isCreated)
// {
// //
// iObj.BoxWidth(2);
// iObj.BoxColor(clrYellow);
// iObj.BoxStyle(STYLE_SOLID);
// }
// //
// bool isSignalBoxBullishDir = signalBox.IsBullish();
// //
// // Calculate Priority ...
// hasPriority =
// hasWorkingZone &&
// workingZone
// .DetectPriority(
// priority,
// signalBox.dir,
// zIndex,
// period //
// );
// //
// // Calculate Risk Reward Ration based on Priority ...
// hasRewardAmount = CalculateRiskReward(
// priority,
// reward,
// amountPercent //
// );
// //
// // Calculate Pivot and Point ...
// //
// pivot =
// isSignalBoxBullishDir
// ? signalBox.lower
// : signalBox.upper;
// //
// point =
// isSignalBoxBullishDir
// ? signalBox.upper
// : signalBox.lower;
// //
// double defaultTarget =
// isSignalBoxBullishDir
// ? signalBox.upper
// : signalBox.lower;
// Add(
// defaultTarget,
// targets //
// );
// //
// // Detect SLs ...
// double iAtr = decisionXConditions.atrBuffer[0];
// iAtr *= 1.5;
// //
// double defaultSL =
// isSignalBoxBullishDir
// ? decisionXConditions.valesBuffer[0] - iAtr
// : decisionXConditions.peaksBuffer[0] + iAtr;
// //
// Add(
// defaultSL,
// sls //
// );
// //
// // Summaries Conditions ...
// result =
// pivot > 0 &&
// point > 0 &&
// hasPriority &&
// hasRewardAmount;
// if (result)
// {
// //
// isBullish = signalBox.IsBullish();
// isBearish = signalBox.IsBearish();
// //
// Copy(
// sls,
// mConditions.sls //
// );
// Copy(
// targets,
// mConditions.targets //
// );
// //
// mConditions.pivot = pivot;
// mConditions.point = point;
// mConditions.reward = reward;
// mConditions.setupTime = cTime;
// mConditions.priority = priority;
// mConditions.provider = provider;
// mConditions.dir = signalBox.dir;
// mConditions.signalBox = signalBox;
// mConditions.amountPercent = amountPercent;
// }
// //
// signalBox.Clean();
// hasSignalBox = false;
}
//
@@ -968,73 +727,18 @@ class XCX121SMCXWZSignalDetector : public XCBase
//
workingZone.Draw(
drawer,
true, // Draw Waiting Zones ...
true, // Draw Inside Zones ...
true, // Draw Breaked Zones ...
true, // Draw Supply Zone ...
true, // Draw Demand Zone ...
false, // Draw Supply Zones ...
false, // Draw Demand Zones ...
false, // Draw Support Zones ...
false // Draw Resistance Zones ...
//
true, // Draw Waiting Boxes ...
true, // Draw Inside Boxes ...
true, // Draw Breaked Boxes ...
//
true, // Draw Supply Zone ...
true, // Draw Demand Zone ...
true, // Draw Supply Zones ...
true, // Draw Demand Zones ...
true, // Draw Support Zones ...
true // Draw Resistance Zones ...
);
//
// XCBaseObject *objects[];
// drawer.DrawState(
// decisionState,
// objects,
// false, // DrawT icksZone ...
// true, // Ignore SwingHighs ...
// true, // Ignore SwingLows ...
// true, // Ignore SupportZones ...
// true, // Ignore ResistanceZones ...
// true, // Ignore SupplyZones ...
// true, // Ignore DemandZones ...
// true, // Ignore BullishOrderBlocks ...
// true, // Ignore BearishOrderBlocks ...
// true, // Ignore BullishFairValueGaps ...
// true, // Ignore BearishFairValueGaps ...
// true, // Ignore BullishRejectionBars ...
// true, // Ignore BearishRejectionBars ...
// true, // Ignore BullishMomentumBars ...
// true, // Ignore BearishMomentumBars ...
// true, // Ignore BullishConsolidationZones ...
// true // Ignore BearishConsolidationZones ...
// );
// //
// int count = 0;
// bool has = false;
// //
// has = workingZone.HasSupplyZones();
// if (has)
// {
// }
// //
// has = workingZone.HasDemandZones();
// if (has)
// {
// //
// count = workingZone.CountDemandZones();
// for (int i = 0; i < count; i++)
// {
// //
// XCDemandZone *iZone = workingZone.demandZones[i];
// //
// XCDemandZoneObject *iObj;
// bool isCreated = drawer.CreateDemandZone(
// iZone,
// iObj //
// );
// }
// }
// //
// Print("");
}
//
File diff suppressed because it is too large Load Diff