This commit is contained in:
2025-02-04 03:33:59 +03:30
parent 6984b8365f
commit 7e32ebab82
20 changed files with 31271 additions and 12329 deletions
+87 -542
View File
@@ -25,9 +25,6 @@
#include "../Libraries/x-121.smc.lib.mq5"
//
XPriceZones x121SMCDecisionPriceZone;
XPriceZones x121SMCAnalysePriceZone;
XPriceZones x121SMCVerificationPriceZone;
XConsolidationZone x121SMCConsolidationZone;
bool DetectX121SMCGuards(
string provider, // Provider ...
@@ -151,12 +148,6 @@ bool DetectX121SMCGuards(
Clean(ownLongPositions);
Clean(ownShortPositions);
//
x121SMCAnalysePriceZone.Clean();
x121SMCDecisionPriceZone.Clean();
x121SMCConsolidationZone.Clean();
x121SMCVerificationPriceZone.Clean();
//
return result;
}
@@ -349,51 +340,6 @@ bool DetectX121SMCGuards(
X121Conditions consolidationXConditions = consolidationConditions.x121Conditions;
X121Conditions visionXConditions = visionConditions.x121Conditions;
//
// Trigger ...
ENUM_X_DIRECTION triggerTrendDir;
bool hasTriggerTrend =
triggerCycleHelper
.DetectMarketStructure(
triggerTrendDir //
);
bool hasTriggerBullishTrend =
hasTriggerTrend &&
IsBullish(triggerTrendDir);
bool hasTriggerBearishTrend =
hasTriggerTrend &&
IsBearish(triggerTrendDir);
//
// Decision ...
ENUM_X_DIRECTION decisionTrendDir;
bool hasDecisionTrend =
decisionCycleHelper
.DetectMarketStructure(
decisionTrendDir //
);
bool hasDecisionBullishTrend =
hasDecisionTrend &&
IsBullish(decisionTrendDir);
bool hasDecisionBearishTrend =
hasDecisionTrend &&
IsBearish(decisionTrendDir);
//
// Analyse ...
ENUM_X_DIRECTION analyseTrendDir;
bool hasAnalyseTrend =
analyseCycleHelper
.DetectMarketStructure(
analyseTrendDir //
);
bool hasAnalyseBullishTrend =
hasAnalyseTrend &&
IsBullish(analyseTrendDir);
bool hasAnalyseBearishTrend =
hasAnalyseTrend &&
IsBearish(analyseTrendDir);
//
//
//
@@ -470,402 +416,6 @@ bool DetectX121SMCGuards(
}
}
//
// Detect Price Zones ...
//
// Decision ...
double decisionPriceZoneUpper = 0;
double decisionPriceZoneLower = 0;
bool isDecisionPriceZoneBearish = false;
bool isDecisionPriceZoneBullish = false;
bool isDecisionPriceZoneValidForPeak = false;
bool isDecisionPriceZoneValidForVale = false;
bool isDecisionPriceZoneLowerRejected = false;
bool isDecisionPriceZoneUpperRejected = false;
bool isDecisionPriceZoneUpperBreakedUp = false;
bool isDecisionPriceZoneLowerBreakedDown = false;
bool hasDecisionPriceZone = x121SMCDecisionPriceZone.IsValid();
//
if (!hasDecisionPriceZone)
{
//
hasDecisionPriceZone = CalculatePriceInsideZones(
x121SMCDecisionPriceZone,
decisionState,
cBar //
);
}
//
if (hasDecisionPriceZone)
{
//
bool hasBoundary = x121SMCDecisionPriceZone.GetBoundary(
X_DIRECTION_ALL,
decisionPriceZoneUpper,
decisionPriceZoneLower //
);
//
isDecisionPriceZoneBearish = x121SMCDecisionPriceZone.IsBearish();
isDecisionPriceZoneBullish = x121SMCDecisionPriceZone.IsBullish();
//
XOHCL iBar;
bool isInited = iBar.Init(
symbol,
decisionXConditions.period,
cIndex //
);
//
if (hasBoundary)
{
//
isDecisionPriceZoneValidForPeak =
decisionXConditions.peaksBuffer[1] <= decisionPriceZoneUpper &&
decisionXConditions.peaksBuffer[1] >= decisionPriceZoneLower;
//
isDecisionPriceZoneValidForVale =
decisionXConditions.valesBuffer[1] <= decisionPriceZoneUpper &&
decisionXConditions.valesBuffer[1] >= decisionPriceZoneLower;
//
isDecisionPriceZoneLowerRejected =
isInited &&
IsBarReject(
decisionPriceZoneLower,
X_DIRECTION_BULLISH,
iBar //
);
//
isDecisionPriceZoneUpperRejected =
isInited &&
IsBarReject(
decisionPriceZoneUpper,
X_DIRECTION_BEARISH,
iBar //
);
//
isDecisionPriceZoneUpperBreakedUp =
isInited &&
IsBarBreak(
decisionPriceZoneUpper,
X_DIRECTION_BULLISH,
iBar //
);
//
isDecisionPriceZoneLowerBreakedDown =
isInited &&
IsBarBreak(
decisionPriceZoneUpper,
X_DIRECTION_BEARISH,
iBar //
);
}
//
// Clear Price Zone ...
bool canReset =
//
(!isInited ||
!hasBoundary)
//
||
//
(isInited &&
hasBoundary &&
(iBar.high < decisionPriceZoneLower ||
iBar.low > decisionPriceZoneUpper))
//
;
if (canReset)
{
//
x121SMCDecisionPriceZone.Clean();
//
decisionPriceZoneUpper = 0;
decisionPriceZoneLower = 0;
isDecisionPriceZoneBearish = false;
isDecisionPriceZoneBullish = false;
isDecisionPriceZoneValidForPeak = false;
isDecisionPriceZoneValidForVale = false;
isDecisionPriceZoneLowerRejected = false;
isDecisionPriceZoneUpperRejected = false;
isDecisionPriceZoneUpperBreakedUp = false;
isDecisionPriceZoneLowerBreakedDown = false;
}
}
//
// Analyse ...
double analysePriceZoneUpper = 0;
double analysePriceZoneLower = 0;
bool isAnalysePriceZoneBearish = false;
bool isAnalysePriceZoneBullish = false;
bool isAnalysePriceZoneValidForPeak = false;
bool isAnalysePriceZoneValidForVale = false;
bool isAnalysePriceZoneLowerRejected = false;
bool isAnalysePriceZoneUpperRejected = false;
bool isAnalysePriceZoneUpperBreakedUp = false;
bool isAnalysePriceZoneLowerBreakedDown = false;
bool hasAnalysePriceZone = x121SMCAnalysePriceZone.IsValid();
//
if (!hasAnalysePriceZone)
{
//
hasAnalysePriceZone = CalculatePriceInsideZones(
x121SMCAnalysePriceZone,
analyseState,
cBar //
);
}
//
if (hasAnalysePriceZone)
{
//
bool hasBoundary = x121SMCAnalysePriceZone.GetBoundary(
X_DIRECTION_ALL,
analysePriceZoneUpper,
analysePriceZoneLower //
);
//
isAnalysePriceZoneBearish = x121SMCAnalysePriceZone.IsBearish();
isAnalysePriceZoneBullish = x121SMCAnalysePriceZone.IsBullish();
//
XOHCL iBar;
bool isInited = iBar.Init(
symbol,
analyseXConditions.period,
cIndex //
);
//
if (hasBoundary)
{
//
isAnalysePriceZoneValidForPeak =
analyseXConditions.peaksBuffer[1] <= analysePriceZoneUpper &&
analyseXConditions.peaksBuffer[1] >= analysePriceZoneLower;
//
isAnalysePriceZoneValidForVale =
analyseXConditions.valesBuffer[1] <= analysePriceZoneUpper &&
analyseXConditions.valesBuffer[1] >= analysePriceZoneLower;
//
isAnalysePriceZoneLowerRejected =
isInited &&
IsBarReject(
analysePriceZoneLower,
X_DIRECTION_BULLISH,
iBar //
);
//
isAnalysePriceZoneUpperRejected =
isInited &&
IsBarReject(
analysePriceZoneUpper,
X_DIRECTION_BEARISH,
iBar //
);
//
isAnalysePriceZoneUpperBreakedUp =
isInited &&
IsBarBreak(
analysePriceZoneUpper,
X_DIRECTION_BULLISH,
iBar //
);
//
isAnalysePriceZoneLowerBreakedDown =
isInited &&
IsBarBreak(
analysePriceZoneUpper,
X_DIRECTION_BEARISH,
iBar //
);
}
//
// Clear Price Zone ...
bool canReset =
//
(!isInited ||
!hasBoundary)
//
||
//
(isInited &&
hasBoundary &&
(iBar.high < analysePriceZoneLower ||
iBar.low > analysePriceZoneUpper))
//
;
if (canReset)
{
//
x121SMCAnalysePriceZone.Clean();
//
analysePriceZoneUpper = 0;
analysePriceZoneLower = 0;
isAnalysePriceZoneBearish = false;
isAnalysePriceZoneBullish = false;
isAnalysePriceZoneValidForPeak = false;
isAnalysePriceZoneValidForVale = false;
isAnalysePriceZoneLowerRejected = false;
isAnalysePriceZoneUpperRejected = false;
isAnalysePriceZoneUpperBreakedUp = false;
isAnalysePriceZoneLowerBreakedDown = false;
}
}
//
// Verification ...
double verificationPriceZoneUpper = 0;
double verificationPriceZoneLower = 0;
bool isVerificationPriceZoneBearish = false;
bool isVerificationPriceZoneBullish = false;
bool isVerificationPriceZoneValidForPeak = false;
bool isVerificationPriceZoneValidForVale = false;
bool isVerificationPriceZoneLowerRejected = false;
bool isVerificationPriceZoneUpperRejected = false;
bool isVerificationPriceZoneUpperBreakedUp = false;
bool isVerificationPriceZoneLowerBreakedDown = false;
bool hasVerificationPriceZone = x121SMCVerificationPriceZone.IsValid();
//
if (!hasVerificationPriceZone)
{
//
hasVerificationPriceZone = CalculatePriceInsideZones(
x121SMCVerificationPriceZone,
verificationState,
cBar //
);
}
//
if (hasVerificationPriceZone)
{
//
bool hasBoundary = x121SMCVerificationPriceZone.GetBoundary(
X_DIRECTION_ALL,
verificationPriceZoneUpper,
verificationPriceZoneLower //
);
//
isVerificationPriceZoneBearish = x121SMCVerificationPriceZone.IsBearish();
isVerificationPriceZoneBullish = x121SMCVerificationPriceZone.IsBullish();
//
XOHCL iBar;
bool isInited = iBar.Init(
symbol,
verificationXConditions.period,
cIndex //
);
//
if (hasBoundary)
{
//
isVerificationPriceZoneValidForPeak =
verificationXConditions.peaksBuffer[1] <= verificationPriceZoneUpper &&
verificationXConditions.peaksBuffer[1] >= verificationPriceZoneLower;
//
isVerificationPriceZoneValidForVale =
verificationXConditions.valesBuffer[1] <= verificationPriceZoneUpper &&
verificationXConditions.valesBuffer[1] >= verificationPriceZoneLower;
//
isVerificationPriceZoneLowerRejected =
isInited &&
IsBarReject(
verificationPriceZoneLower,
X_DIRECTION_BULLISH,
iBar //
);
//
isVerificationPriceZoneUpperRejected =
isInited &&
IsBarReject(
verificationPriceZoneUpper,
X_DIRECTION_BEARISH,
iBar //
);
//
isVerificationPriceZoneUpperBreakedUp =
isInited &&
IsBarBreak(
verificationPriceZoneUpper,
X_DIRECTION_BULLISH,
iBar //
);
//
isVerificationPriceZoneLowerBreakedDown =
isInited &&
IsBarBreak(
verificationPriceZoneUpper,
X_DIRECTION_BEARISH,
iBar //
);
}
//
// Clear Price Zone ...
bool canReset =
//
(!isInited ||
!hasBoundary)
//
||
//
(isInited &&
hasBoundary &&
(iBar.high < verificationPriceZoneLower ||
iBar.low > verificationPriceZoneUpper))
//
;
if (canReset)
{
//
x121SMCVerificationPriceZone.Clean();
//
verificationPriceZoneUpper = 0;
verificationPriceZoneLower = 0;
isVerificationPriceZoneBearish = false;
isVerificationPriceZoneBullish = false;
isVerificationPriceZoneValidForPeak = false;
isVerificationPriceZoneValidForVale = false;
isVerificationPriceZoneLowerRejected = false;
isVerificationPriceZoneUpperRejected = false;
isVerificationPriceZoneUpperBreakedUp = false;
isVerificationPriceZoneLowerBreakedDown = false;
}
}
//
// Here We Have all Requirements for Guarding Positions ...
@@ -906,37 +456,10 @@ bool DetectX121SMCGuards(
//
isLong
? //
(hasDecisionPriceZone &&
isDecisionPriceZoneBearish &&
isDecisionPriceZoneValidForPeak)
//
||
//
(hasAnalysePriceZone &&
isAnalysePriceZoneBearish &&
isAnalysePriceZoneValidForPeak)
//
||
//
(hasVerificationPriceZone &&
isVerificationPriceZoneBearish &&
isVerificationPriceZoneValidForPeak)
false
//
: //
(hasDecisionPriceZone &&
isDecisionPriceZoneBullish &&
isDecisionPriceZoneValidForVale)
//
||
//
(hasAnalysePriceZone &&
isAnalysePriceZoneBullish &&
isAnalysePriceZoneValidForVale)
//
||
//
(hasVerificationPriceZone &&
isVerificationPriceZoneBullish &&
isVerificationPriceZoneValidForVale)
false
//
;
if (iHasGuard)
@@ -969,7 +492,7 @@ bool DetectX121SMCGuards(
if (!ignoreCloseLongsOnBearishTrendGuard)
{
//
bool hasGuard = hasDecisionBearishTrend;
bool hasGuard = false; // hasDecisionBearishTrend;
//
if (hasGuard)
@@ -1016,7 +539,7 @@ bool DetectX121SMCGuards(
if (!ignoreCloseShortsOnBullishTrendGuard)
{
//
bool hasGuard = hasDecisionBullishTrend;
bool hasGuard = false; // hasDecisionBullishTrend;
//
if (hasGuard)
@@ -1100,8 +623,10 @@ bool DetectX121SMCGuards(
//
bool hasGuard =
//
hasAnalyseBearishTrend &&
hasDecisionBearishTrend
false
//
// hasAnalyseBearishTrend &&
// hasDecisionBearishTrend
//
;
@@ -1132,8 +657,10 @@ bool DetectX121SMCGuards(
//
bool hasGuard =
//
hasAnalyseBullishTrend &&
hasDecisionBullishTrend
false
//
// hasAnalyseBullishTrend &&
// hasDecisionBullishTrend
//
;
@@ -1169,8 +696,10 @@ bool DetectX121SMCGuards(
//
bool hasGuard =
//
hasTriggerBearishTrend ||
!hasDecisionBullishTrend
false
//
// hasTriggerBearishTrend ||
// !hasDecisionBullishTrend
//
;
@@ -1211,8 +740,10 @@ bool DetectX121SMCGuards(
//
bool hasGuard =
//
hasTriggerBullishTrend ||
!hasDecisionBearishTrend
false
//
// hasTriggerBullishTrend ||
// !hasDecisionBearishTrend
//
;
@@ -1256,7 +787,7 @@ bool DetectX121SMCGuards(
if (hasLongs)
{
//
bool hasTrendGuard = hasDecisionBearishTrend;
bool hasTrendGuard = false; // hasDecisionBearishTrend;
//
bool hasConsolidationGuard =
@@ -1266,24 +797,27 @@ bool DetectX121SMCGuards(
//
bool hasDecisionPriceZoneGuard =
(hasDecisionPriceZone &&
isDecisionPriceZoneBullish &&
isDecisionPriceZoneValidForVale &&
isDecisionPriceZoneUpperBreakedUp);
false;
// (hasDecisionPriceZone &&
// isDecisionPriceZoneBullish &&
// isDecisionPriceZoneValidForVale &&
// isDecisionPriceZoneUpperBreakedUp);
//
bool hasAnalysePriceZoneGuard =
(hasAnalysePriceZone &&
isAnalysePriceZoneBullish &&
isAnalysePriceZoneValidForVale &&
isAnalysePriceZoneUpperBreakedUp);
false;
// (hasAnalysePriceZone &&
// isAnalysePriceZoneBullish &&
// isAnalysePriceZoneValidForVale &&
// isAnalysePriceZoneUpperBreakedUp);
//
bool hasVerificationPriceZoneGuard =
(hasVerificationPriceZone &&
isVerificationPriceZoneBullish &&
isVerificationPriceZoneValidForVale &&
isVerificationPriceZoneUpperBreakedUp);
false;
// (hasVerificationPriceZone &&
// isVerificationPriceZoneBullish &&
// isVerificationPriceZoneValidForVale &&
// isVerificationPriceZoneUpperBreakedUp);
//
bool hasGuard =
@@ -1301,11 +835,11 @@ bool DetectX121SMCGuards(
hasConsolidationGuard
? consolidationZoneLower
: hasDecisionPriceZoneGuard
? decisionPriceZoneLower
? 0 // decisionPriceZoneLower
: hasAnalysePriceZoneGuard
? analysePriceZoneLower
? 0 // analysePriceZoneLower
: hasVerificationPriceZoneGuard
? verificationPriceZoneLower
? 0 // verificationPriceZoneLower
: 0;
//
@@ -1378,7 +912,7 @@ bool DetectX121SMCGuards(
if (hasShorts)
{
//
bool hasTrendGuard = hasDecisionBullishTrend;
bool hasTrendGuard = false; // hasDecisionBullishTrend;
//
bool hasConsolidationGuard =
@@ -1388,24 +922,27 @@ bool DetectX121SMCGuards(
//
bool hasDecisionPriceZoneGuard =
(hasDecisionPriceZone &&
isDecisionPriceZoneBearish &&
isDecisionPriceZoneValidForPeak &&
isDecisionPriceZoneLowerBreakedDown);
false;
// (hasDecisionPriceZone &&
// isDecisionPriceZoneBearish &&
// isDecisionPriceZoneValidForPeak &&
// isDecisionPriceZoneLowerBreakedDown);
//
bool hasAnalysePriceZoneGuard =
(hasAnalysePriceZone &&
isAnalysePriceZoneBearish &&
isAnalysePriceZoneValidForPeak &&
isAnalysePriceZoneLowerBreakedDown);
false;
// (hasAnalysePriceZone &&
// isAnalysePriceZoneBearish &&
// isAnalysePriceZoneValidForPeak &&
// isAnalysePriceZoneLowerBreakedDown);
//
bool hasVerificationPriceZoneGuard =
(hasVerificationPriceZone &&
isVerificationPriceZoneBearish &&
isVerificationPriceZoneValidForPeak &&
isVerificationPriceZoneLowerBreakedDown);
false;
// (hasVerificationPriceZone &&
// isVerificationPriceZoneBearish &&
// isVerificationPriceZoneValidForPeak &&
// isVerificationPriceZoneLowerBreakedDown);
//
bool hasGuard =
@@ -1423,11 +960,11 @@ bool DetectX121SMCGuards(
hasConsolidationGuard
? consolidationZoneUpper
: hasDecisionPriceZoneGuard
? decisionPriceZoneUpper
? 0 // decisionPriceZoneUpper
: hasAnalysePriceZoneGuard
? analysePriceZoneUpper
? 0 // analysePriceZoneUpper
: hasVerificationPriceZoneGuard
? verificationPriceZoneUpper
? 0 // verificationPriceZoneUpper
: 0;
//
@@ -1507,18 +1044,22 @@ bool DetectX121SMCGuards(
//
bool hasAnalyseGuard =
//
(hasAnalysePriceZone &&
isAnalysePriceZoneValidForPeak &&
isAnalysePriceZoneUpperRejected)
false
//
// (hasAnalysePriceZone &&
// isAnalysePriceZoneValidForPeak &&
// isAnalysePriceZoneUpperRejected)
//
;
//
bool hasVerificationGuard =
//
(hasVerificationPriceZone &&
isVerificationPriceZoneValidForPeak &&
isVerificationPriceZoneUpperRejected)
false
//
// (hasVerificationPriceZone &&
// isVerificationPriceZoneValidForPeak &&
// isVerificationPriceZoneUpperRejected)
//
;
@@ -1533,9 +1074,9 @@ bool DetectX121SMCGuards(
//
double guardTP =
hasAnalyseGuard
? analysePriceZoneUpper
? 0 // analysePriceZoneUpper
: hasVerificationGuard
? verificationPriceZoneUpper
? 0 // verificationPriceZoneUpper
: 0;
//
@@ -1582,18 +1123,22 @@ bool DetectX121SMCGuards(
//
bool hasAnalyseGuard =
//
(hasAnalysePriceZone &&
isAnalysePriceZoneValidForVale &&
isAnalysePriceZoneLowerRejected)
false
//
// (hasAnalysePriceZone &&
// isAnalysePriceZoneValidForVale &&
// isAnalysePriceZoneLowerRejected)
//
;
//
bool hasVerificationGuard =
//
(hasVerificationPriceZone &&
isVerificationPriceZoneValidForVale &&
isVerificationPriceZoneLowerRejected)
false
//
// (hasVerificationPriceZone &&
// isVerificationPriceZoneValidForVale &&
// isVerificationPriceZoneLowerRejected)
//
;
@@ -1608,9 +1153,9 @@ bool DetectX121SMCGuards(
//
double guardTP =
hasAnalyseGuard
? analysePriceZoneLower
? 0 // analysePriceZoneLower
: hasVerificationGuard
? verificationPriceZoneLower
? 0 // verificationPriceZoneLower
: 0;
//
@@ -1667,10 +1212,10 @@ bool DetectX121SMCGuards(
Clean(ownShortPositions);
//
x121SMCAnalysePriceZone.Clean();
x121SMCDecisionPriceZone.Clean();
x121SMCConsolidationZone.Clean();
x121SMCVerificationPriceZone.Clean();
// x121SMCAnalysePriceZone.Clean();
// x121SMCDecisionPriceZone.Clean();
// x121SMCConsolidationZone.Clean();
// x121SMCVerificationPriceZone.Clean();
//
// Release Arrays ...
File diff suppressed because it is too large Load Diff