This commit is contained in:
2025-05-07 23:53:37 +03:30
parent 32f895407f
commit 2ba019e1f0
5 changed files with 746 additions and 49 deletions
+310 -15
View File
@@ -79,6 +79,10 @@ struct XCAEAStrategyConditions
datetime setupTime;
datetime triggerTime;
//
double partialCloseOnTPLevel;
double partialCloseMultiplier;
//
ENUM_X_DIRECTION dir;
XBoxZone decisionZone;
@@ -118,6 +122,10 @@ struct XCAEAStrategyConditions
setupTime = NULL;
triggerTime = NULL;
//
partialCloseOnTPLevel = 0;
partialCloseMultiplier = 0;
//
Clean(targets);
@@ -711,6 +719,14 @@ bool DetectDecisionZone(
double p2FastState = conditions.fastStateBuffer[p2IDX];
double p3FastState = conditions.fastStateBuffer[p3IDX];
//
// RSI ...
double zRSI = conditions.rsiBuffer[zIDX];
double cRSI = conditions.rsiBuffer[cIDX];
double pRSI = conditions.rsiBuffer[pIDX];
double p2RSI = conditions.rsiBuffer[p2IDX];
double p3RSI = conditions.rsiBuffer[p3IDX];
//
// Create Custom Conditions ...
@@ -912,7 +928,19 @@ bool DetectDecisionZone(
bool isSarSwitchedToBearish =
cFastState < 0 &&
isSarSwitchedInFiboStrongBearish;
;
//
// RSI Conditions ...
//
bool isRSICrossedOverOS =
p3RSI < conditions.rsiOSLevel &&
cRSI > conditions.rsiOSLevel;
//
bool isRSICrossedUnderOB =
p3RSI > conditions.rsiOBLevel &&
cRSI < conditions.rsiOBLevel;
//
// Testing Conditions ...
@@ -1047,12 +1075,14 @@ bool DetectDecisionZone(
//
bool isCond1Bullish =
isCIsValePivot &&
isRSICrossedOverOS &&
!isFiboSectionChanged &&
isSarSwitchedToBullish;
//
bool isCond1Bearish =
isCIsPeakPivot &&
isRSICrossedUnderOB &&
!isFiboSectionChanged &&
isSarSwitchedToBearish;
@@ -1167,18 +1197,12 @@ bool DetectDecisionZone(
}
//
bool isCond2 =
(cPeak == pPeak &&
cPeak == cSWH &&
cPeak == cResistance) &&
(cVale == pVale &&
cVale == cSWL &&
cVale == cSupport);
if (isCond2)
{
//
Print("Decision Zone Full Cond1");
}
// bool isCond2 = isFiboSectionChanged;
// if (isCond2)
// {
// //
// Print("Decision Zone Full Cond1");
// }
//
// Summarise Result ...
@@ -1232,6 +1256,275 @@ bool DetectDecisionZone(
//
// Trigger Conditions ...
//
// Detect Trigger Based On Decision Zone's
// Volume and Score ...
bool CanTriggerCond0(
XCXCAEAHelper *helper,
XBoxZone &box,
ENUM_X_DIRECTION &dir,
double &sl,
double &tp,
int barIndex = 0,
int loopback = 5,
double scorePassMultiplier = 1 //
)
{
//
bool result = false;
//
// Normalize Args ...
sl = 0;
tp = 0;
dir = X_DIRECTION_NONE;
loopback = NormalizeInt(loopback, 5);
barIndex = NormalizeInt(barIndex, 0);
//
// Validate Decision Box ...
result = box.IsValid() &&
helper != NULL;
if (!result)
{
return result;
}
//
// Define Requirements ...
//
bool isBullish = box.IsBullish();
bool isBearish = box.IsBearish();
//
// Scores ...
double bullScores[];
double bearScores[];
//
// Volumes ...
double bullVolumes[];
double bearVolumes[];
//
// Create a Loop through Loopack ...
XOHCL iBar;
bool has = false;
int start = barIndex;
XCAEAConditions iConditions;
int end = barIndex + loopback;
for (int i = end; i >= start; i--)
{
//
// Retrieve Bar ...
has = iBar.Init(
box.symbol,
box.period,
i //
);
if (!has)
{
//
iBar.Clean();
iConditions.Clean();
//
continue;
}
//
// Retrieve Conditions ...
has = helper.GetConditions(
iConditions,
i //
);
if (!has)
{
//
iBar.Clean();
iConditions.Clean();
//
continue;
}
//
// Retrieve Scores ...
double iBullScore = 0;
double iBearScore = 0;
iConditions
.GenerateScore(
iBullScore,
iBearScore //
);
Add(
iBullScore,
bullScores //
);
Add(
iBearScore,
bearScores //
);
//
// Retrieve Volumes ...
double iBullVolume = 0;
double iBearVolume = 0;
helper
.barAnalyser
.CalculateRangeVolume(
iBar,
iBullVolume,
iBearVolume,
2 // Loopback ...
);
Add(
iBullVolume,
bullVolumes //
);
Add(
iBearVolume,
bearVolumes //
);
//
iBar.Clean();
iConditions.Clean();
}
//
// Calculating Requirements ...
//
// Scores ...
//
// Bullish ...
double bullScore = GetSum(bullScores);
double bullScoreMax = GetMax(bullScores);
double bullScoreMin = GetMin(bullScores);
//
// Bearish ...
double bearScore = GetSum(bearScores);
double bearScoreMax = GetMax(bearScores);
double bearScoreMin = GetMin(bearScores);
//
// Volumes ...
//
// Bullish ...
double bullVolume = GetSum(bullVolumes);
double bullVolumeMax = GetMax(bullVolumes);
double bullVolumeMin = GetMin(bullVolumes);
//
// Bearish ...
double bearVolume = GetSum(bearVolumes);
double bearVolumeMax = GetMax(bearVolumes);
double bearVolumeMin = GetMin(bearVolumes);
//
// Creating Result Conditions ...
//
bool isBullishPassed =
isBullish &&
bullScore >= (scorePassMultiplier * bearScore) &&
bullVolume >= (scorePassMultiplier * bearVolume);
//
bool isBearishPassed =
isBearish &&
bearScore >= (scorePassMultiplier * bullScore) &&
bearVolume >= (scorePassMultiplier * bullVolume);
//
result = isBullishPassed ||
isBearishPassed;
if (!result)
{
//
iBar.Clean();
Clean(bullScores);
Clean(bearScores);
Clean(bullVolumes);
Clean(bearVolumes);
iConditions.Clean();
//
return result;
}
//
// Validating Box to Find a Rejection ...
//
// Validating Box to Has a Gap ...
//
// Validating Box to Has a Block ...
//
bool isPassed =
isBullishPassed ||
isBearishPassed;
if (isPassed)
{
//
// Preparing TP and SL ...
//
sl = isBullishPassed
? box.lower
: box.upper;
//
tp = 0;
}
//
// Summarizing ...
//
bool canTriggerLong =
isBullishPassed;
//
bool canTriggerShort =
isBearishPassed;
//
result = canTriggerLong ||
canTriggerShort;
if (result)
{
//
dir = canTriggerLong
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
Print("Triggered ...");
}
//
// Cleanup Resources ...
//
iBar.Clean();
Clean(bullScores);
Clean(bearScores);
Clean(bullVolumes);
Clean(bearVolumes);
iConditions.Clean();
//
return result;
}
//
// Detect Trigger Based On Decision Zone's
// Fake Breaked out ...
@@ -1258,7 +1551,8 @@ bool CanTriggerCond1(
//
// Validate Decision Box ...
result = box.IsValid();
result = box.IsValid() &&
helper != NULL;
if (!result)
{
return result;
@@ -1373,7 +1667,8 @@ bool CanTriggerCond2(
//
// Validate Decision Box ...
result = box.IsValid();
result = box.IsValid() &&
helper != NULL;
if (!result)
{
return result;