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
File diff suppressed because it is too large Load Diff
+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
+4 -578
View File
@@ -54,10 +54,6 @@ struct X121SMCStrategyXSignalConditions
double pivot;
double point;
//
XCOrderBlock *bullishOBs[];
XCOrderBlock *bearishOBs[];
//
// Constructor ...
X121SMCStrategyXSignalConditions()
@@ -180,34 +176,6 @@ struct X121SMCStrategyXSignalConditions
point = 0;
//
Clean(bullishOBs);
Clean(bearishOBs);
//
}
//
int CountBullishOBs()
{
return ArraySize(bullishOBs);
}
//
bool HasBullishOBs()
{
return IsValidSize(CountBullishOBs());
}
//
int CountBearishOBs()
{
return ArraySize(bearishOBs);
}
//
bool HasBearishOBs()
{
return IsValidSize(CountBearishOBs());
}
//
@@ -434,69 +402,6 @@ bool DetectX121SMCXSignalSetup(
//
// Setup Conditions ...
//
// Detect Trend ...
//
// Consolidation ...
ENUM_X_DIRECTION consolidationTrendDir;
bool hasConsolidationTrend =
consolidationCycleHelper
.DetectMarketStructure(
consolidationTrendDir //
);
bool hasConsolidationBullishTrend =
hasConsolidationTrend &&
IsBullish(consolidationTrendDir);
bool hasConsolidationBearishTrend =
hasConsolidationTrend &&
IsBearish(consolidationTrendDir);
//
// Verification ...
ENUM_X_DIRECTION verificationTrendDir;
bool hasVerificationTrend =
verificationCycleHelper
.DetectMarketStructure(
verificationTrendDir //
);
bool hasVerificationBullishTrend =
hasVerificationTrend &&
IsBullish(verificationTrendDir);
bool hasVerificationBearishTrend =
hasVerificationTrend &&
IsBearish(verificationTrendDir);
//
// Analyse ...
ENUM_X_DIRECTION analyseTrendDir;
bool hasAnalyseTrend =
analyseCycleHelper
.DetectMarketStructure(
analyseTrendDir //
);
bool hasAnalyseBullishTrend =
hasAnalyseTrend &&
IsBullish(analyseTrendDir);
bool hasAnalyseBearishTrend =
hasAnalyseTrend &&
IsBearish(analyseTrendDir);
//
// Decision ...
ENUM_X_DIRECTION decisionTrendDir;
bool hasDecisionTrend =
decisionCycleHelper
.DetectMarketStructure(
decisionTrendDir //
);
bool hasDecisionBullishTrend =
hasDecisionTrend &&
IsBullish(decisionTrendDir);
bool hasDecisionBearishTrend =
hasDecisionTrend &&
IsBearish(decisionTrendDir);
//
// Detect Bar State ...
@@ -714,457 +619,6 @@ bool DetectX121SMCXSignalSetup(
//
;
//
// Detect Order Block ...
//
bool hasBullishOrderBlocks = conditions.HasBullishOBs();
int bullishOrderBlocksCount = conditions.CountBullishOBs();
//
bool hasBearishOrderBlocks = conditions.HasBearishOBs();
int bearishOrderBlocksCount = conditions.CountBearishOBs();
//
bool hasOrderBlocks = hasBullishOrderBlocks &&
hasBearishOrderBlocks;
if (!hasOrderBlocks)
{
//
XCOrderBlock *bullishOBs[];
XCOrderBlock *bearishOBs[];
bool hasOrderBlocks = visionCycleHelper.DetectOrderBlocks(
bullishOBs,
bearishOBs //
);
//
if (!hasBullishOrderBlocks)
{
//
Copy(
bullishOBs,
conditions.bullishOBs //
);
}
//
if (!hasBearishOrderBlocks)
{
//
Copy(
bearishOBs,
conditions.bearishOBs //
);
}
//
hasBullishOrderBlocks = conditions.HasBullishOBs();
bullishOrderBlocksCount = conditions.CountBullishOBs();
//
hasBearishOrderBlocks = conditions.HasBearishOBs();
bearishOrderBlocksCount = conditions.CountBearishOBs();
}
//
bool hasOldestBullishOB = false;
bool hasYoungestBullishOB = false;
XCOrderBlock *oldestBullishOB = NULL;
XCOrderBlock *youngestBullishOB = NULL;
if (hasBullishOrderBlocks)
{
//
XCZone *zones[];
bool isConverted = ToZone(
conditions.bullishOBs,
zones //
);
//
int oldestIDX = GetOldest(zones);
hasOldestBullishOB = IsValidIndex(oldestIDX);
if (hasOldestBullishOB)
{
oldestBullishOB = conditions.bullishOBs[oldestIDX];
}
//
int youngestIDX = GetYoungest(zones);
hasYoungestBullishOB = IsValidIndex(youngestIDX);
if (hasYoungestBullishOB)
{
youngestBullishOB = conditions.bullishOBs[youngestIDX];
}
}
//
bool hasOldestBearishOB = false;
bool hasYoungestBearishOB = false;
XCOrderBlock *oldestBearishOB = NULL;
XCOrderBlock *youngestBearishOB = NULL;
if (hasBearishOrderBlocks)
{
//
XCZone *zones[];
bool isConverted = ToZone(
conditions.bearishOBs,
zones //
);
//
int oldestIDX = GetOldest(zones);
hasOldestBearishOB = IsValidIndex(oldestIDX);
if (hasOldestBearishOB)
{
oldestBearishOB = conditions.bearishOBs[oldestIDX];
}
//
int youngestIDX = GetYoungest(zones);
hasYoungestBearishOB = IsValidIndex(youngestIDX);
if (hasYoungestBearishOB)
{
youngestBearishOB = conditions.bearishOBs[youngestIDX];
}
}
//
bool hasPriceInsideOB = false;
XCOrderBlock *priceInsideOB = NULL;
//
if (!hasPriceInsideOB &&
hasBullishOrderBlocks)
{
//
for (int i = 0; i < bullishOrderBlocksCount; i++)
{
//
XCOrderBlock *iOb = conditions.bullishOBs[i];
//
bool isInside = IsPriceInsideZone(
decisionXConditions.valesBuffer[1],
(XCZone *)iOb //
);
if (isInside)
{
//
hasPriceInsideOB = true;
priceInsideOB = iOb;
break;
}
}
}
//
if (!hasPriceInsideOB &&
hasBearishOrderBlocks)
{
//
for (int i = 0; i < bearishOrderBlocksCount; i++)
{
//
XCOrderBlock *iOb = conditions.bearishOBs[i];
//
bool isInside = IsPriceInsideZone(
decisionXConditions.peaksBuffer[1],
(XCZone *)iOb //
);
if (isInside)
{
//
hasPriceInsideOB = true;
priceInsideOB = iOb;
break;
}
}
}
//
XStateZones obState;
bool hasOBState = false;
XOHCL priceInsideOBBreakerBar;
if (hasPriceInsideOB)
{
//
XOHCL toBar;
XOHCL fromBar;
ENUM_X_DIRECTION forDir =
priceInsideOB.IsBullish()
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
bool hasBreakerBar = HasBreakerBar(
toBar,
fromBar,
priceInsideOBBreakerBar,
forDir,
priceInsideOB.GetSymbol(),
priceInsideOB.GetPeriod(),
priceInsideOB.Upper(),
priceInsideOB.Lower(),
priceInsideOB.From(),
priceInsideOB.To() //
);
if (hasBreakerBar)
{
//
CalculateStateZones(
obState,
consolidationState,
priceInsideOB.Upper(),
priceInsideOB.Lower(),
priceInsideOBBreakerBar.time //
);
}
//
hasOBState = obState.IsValid();
}
//
bool isSameCyclesPeak =
//
triggerXConditions.peaksBuffer[1] == decisionXConditions.peaksBuffer[1] &&
decisionXConditions.peaksBuffer[1] == analyseXConditions.peaksBuffer[1] &&
analyseXConditions.peaksBuffer[1] == verificationXConditions.peaksBuffer[1] &&
verificationXConditions.peaksBuffer[1] == consolidationXConditions.peaksBuffer[1]
//
;
//
bool isSameCyclesVale =
//
triggerXConditions.valesBuffer[1] == decisionXConditions.valesBuffer[1] &&
decisionXConditions.valesBuffer[1] == analyseXConditions.valesBuffer[1] &&
analyseXConditions.valesBuffer[1] == verificationXConditions.valesBuffer[1] &&
verificationXConditions.valesBuffer[1] == consolidationXConditions.valesBuffer[1]
//
;
//
bool hasSameCyclesPV =
hasOBState &&
hasPriceInsideOB &&
(isSameCyclesPeak ||
isSameCyclesVale);
//
// DRAW ...
//
//
XCBaseObject *drawnObjects[];
//
if (hasBullishOrderBlocks)
{
//
for (int i = 0; i < bullishOrderBlocksCount; i++)
{
//
XCOrderBlock *iOb = conditions.bullishOBs[i];
//
XCBullishOrderBlockObject *iObObj;
bool isCreated = visionCycleHelper
.mPOIDrawer
.CreateBullishOrderBlock(
iOb,
iObObj //
);
if (isCreated)
{
//
Add(
(XCBaseObject *)iObObj,
drawnObjects //
);
}
}
}
//
if (hasBearishOrderBlocks)
{
//
for (int i = 0; i < bearishOrderBlocksCount; i++)
{
//
XCOrderBlock *iOb = conditions.bearishOBs[i];
//
XCBearishOrderBlockObject *iObObj;
bool isCreated = visionCycleHelper
.mPOIDrawer
.CreateBearishOrderBlock(
iOb,
iObObj //
);
if (isCreated)
{
//
Add(
(XCBaseObject *)iObObj,
drawnObjects //
);
}
}
}
//
// if (hasOldestBullishOB)
// {
// //
// XCBullishOrderBlockObject *iObj;
// bool isCreated = visionCycleHelper
// .mPOIDrawer
// .CreateBullishOrderBlock(
// oldestBullishOB,
// iObj //
// );
// if (isCreated)
// {
// }
// }
// //
// if (hasYoungestBullishOB)
// {
// //
// XCBullishOrderBlockObject *iObj;
// bool isCreated = visionCycleHelper
// .mPOIDrawer
// .CreateBullishOrderBlock(
// youngestBullishOB,
// iObj //
// );
// if (isCreated)
// {
// }
// }
// //
// if (hasOldestBearishOB)
// {
// //
// XCBearishOrderBlockObject *iObj;
// bool isCreated = visionCycleHelper
// .mPOIDrawer
// .CreateBearishOrderBlock(
// oldestBearishOB,
// iObj //
// );
// if (isCreated)
// {
// }
// }
// //
// if (hasYoungestBearishOB)
// {
// //
// XCBearishOrderBlockObject *iObj;
// bool isCreated = visionCycleHelper
// .mPOIDrawer
// .CreateBearishOrderBlock(
// youngestBearishOB,
// iObj //
// );
// if (isCreated)
// {
// }
// }
//
if (hasPriceInsideOB)
{
//
bool isBullish = priceInsideOB.IsBullish();
//
bool isCreated = false;
XCBaseObject *iObObj = NULL;
if (isBullish)
{
//
XCBullishOrderBlockObject *iObj;
isCreated = visionCycleHelper
.mPOIDrawer
.CreateBullishOrderBlock(
priceInsideOB,
iObj //
);
//
if (isCreated)
{
//
iObj.ZoneColor(clrYellow);
iObObj = (XCBaseObject *)iObj;
}
}
else
{
//
XCBearishOrderBlockObject *iObj;
isCreated = visionCycleHelper
.mPOIDrawer
.CreateBearishOrderBlock(
priceInsideOB,
iObj //
);
//
if (isCreated)
{
//
iObj.ZoneColor(clrOrangeRed);
iObObj = (XCBaseObject *)iObj;
}
}
//
if (isCreated)
{
//
Add(
iObObj,
drawnObjects //
);
}
}
//
if (hasOBState)
{
//
XCBaseObject *stateObjects[];
int stateObjectsCount = consolidationCycleHelper
.mPOIDrawer
.DrawStateZones(
obState,
stateObjects //
);
if (IsValidSize(stateObjectsCount))
{
//
Copy(
stateObjects,
drawnObjects,
false //
);
}
}
//
int drawnCount = ArraySize(drawnObjects);
if (IsValidSize(drawnCount))
{
}
//
//
//
@@ -1175,42 +629,14 @@ bool DetectX121SMCXSignalSetup(
//
bool isCondition1Bullish =
//
hasSameCyclesPV &&
isCBarBullishFormed &&
priceInsideOB.IsBullish() &&
//
(decisionXConditions.isBreakedUpPrevSar ||
decisionXConditions.isBreakedUpPrevStr ||
decisionXConditions.isVWapMaxBreakedUp ||
decisionXConditions.isBreakedUpPrevCheMax ||
decisionXConditions.isBreakedUpPrevAtrLower) &&
//
(decisionXConditions.isSarSwitchedToBullish ||
decisionXConditions.isStrSwitchedToBullish ||
decisionXConditions.isCheSwitchedToBullish ||
decisionXConditions.isVWapSwitchedToBullishState ||
decisionXConditions.isVWapSwitchedToBullishOrdered)
false
//
;
//
bool isCondition1Bearish =
//
hasSameCyclesPV &&
isCBarBearishFormed &&
priceInsideOB.IsBearish() &&
//
(decisionXConditions.isBreakedDownPrevSar ||
decisionXConditions.isBreakedDownPrevStr ||
decisionXConditions.isVWapMinBreakedDown ||
decisionXConditions.isBreakedDownPrevCheMin ||
decisionXConditions.isBreakedDownPrevAtrUpper) &&
//
(decisionXConditions.isSarSwitchedToBearish ||
decisionXConditions.isStrSwitchedToBearish ||
decisionXConditions.isCheSwitchedToBearish ||
decisionXConditions.isVWapSwitchedToBearishState ||
decisionXConditions.isVWapSwitchedToBearishOrdered)
false
//
;
@@ -1243,8 +669,8 @@ bool DetectX121SMCXSignalSetup(
//
conditions.pivot =
isCondition1Bullish
? priceInsideOB.Upper()
: priceInsideOB.Lower();
? 0 // priceInsideOB.Upper()
: 0; // priceInsideOB.Lower();
}
//
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+303 -434
View File
@@ -26,6 +26,53 @@
#include "../Libraries/x-121.smc.guard.lib.mq5"
#include "../Libraries/x-121.smc.lib.mq5"
//
struct XOBTest
{
//
// Props ...
//
string symbol;
ENUM_TIMEFRAMES period;
//
XCOrderBlock *ob;
XCFVG *fvg;
//
datetime fvgActivatedAt;
datetime rewardedAt;
//
double reward;
//
// Constructor ...
XOBTest()
{
Clean();
}
//
// Tools ...
//
void Clean()
{
//
ob = NULL;
fvg = NULL;
symbol = NULL;
period = NULL;
rewardedAt = NULL;
fvgActivatedAt = NULL;
//
reward = 0;
}
};
//
// Definitions ...
struct X121SMCStrategyXOBSSignalConditions
@@ -56,18 +103,7 @@ struct X121SMCStrategyXOBSSignalConditions
//
// Extwnsion ...
//
datetime cOBAt;
XCOrderBlock *cOB;
bool isCOBActivated;
datetime cOBActivatedAt;
//
datetime aOBAt;
XCOrderBlock *aOB;
bool isAOBActivated;
datetime aOBActivatedAt;
XOBTest obTests[];
//
// Constructor ...
@@ -191,16 +227,7 @@ struct X121SMCStrategyXOBSSignalConditions
point = 0;
//
cOB = NULL;
cOBAt = NULL;
cOBActivatedAt = NULL;
isCOBActivated = false;
//
aOB = NULL;
aOBAt = NULL;
aOBActivatedAt = NULL;
isAOBActivated = false;
Clean(obTests);
}
//
@@ -434,84 +461,6 @@ bool DetectX121SMCXOBSSignalSetup(
//
// Setup Conditions ...
//
// Detect Trend ...
//
// Vision ...
ENUM_X_DIRECTION visionTrendDir;
bool hasVisionTrend =
visionCycleHelper
.DetectMarketStructure(
visionTrendDir //
);
bool hasVisionBullishTrend =
hasVisionTrend &&
IsBullish(visionTrendDir);
bool hasVisionBearishTrend =
hasVisionTrend &&
IsBearish(visionTrendDir);
//
// Consolidation ...
ENUM_X_DIRECTION consolidationTrendDir;
bool hasConsolidationTrend =
consolidationCycleHelper
.DetectMarketStructure(
consolidationTrendDir //
);
bool hasConsolidationBullishTrend =
hasConsolidationTrend &&
IsBullish(consolidationTrendDir);
bool hasConsolidationBearishTrend =
hasConsolidationTrend &&
IsBearish(consolidationTrendDir);
//
// Verification ...
ENUM_X_DIRECTION verificationTrendDir;
bool hasVerificationTrend =
verificationCycleHelper
.DetectMarketStructure(
verificationTrendDir //
);
bool hasVerificationBullishTrend =
hasVerificationTrend &&
IsBullish(verificationTrendDir);
bool hasVerificationBearishTrend =
hasVerificationTrend &&
IsBearish(verificationTrendDir);
//
// Analyse ...
ENUM_X_DIRECTION analyseTrendDir;
bool hasAnalyseTrend =
analyseCycleHelper
.DetectMarketStructure(
analyseTrendDir //
);
bool hasAnalyseBullishTrend =
hasAnalyseTrend &&
IsBullish(analyseTrendDir);
bool hasAnalyseBearishTrend =
hasAnalyseTrend &&
IsBearish(analyseTrendDir);
//
// Decision ...
ENUM_X_DIRECTION decisionTrendDir;
bool hasDecisionTrend =
decisionCycleHelper
.DetectMarketStructure(
decisionTrendDir //
);
bool hasDecisionBullishTrend =
hasDecisionTrend &&
IsBullish(decisionTrendDir);
bool hasDecisionBearishTrend =
hasDecisionTrend &&
IsBearish(decisionTrendDir);
//
// Detect Bar State ...
@@ -730,350 +679,36 @@ bool DetectX121SMCXOBSSignalSetup(
;
//
// Detect OrderBlocks ...
// Detect Order Flow ...
//
bool hasCOB =
conditions.cOB != NULL &&
conditions.cOB.IsValid() &&
IsValid(conditions.cOBAt);
//
if (!hasCOB)
// Test Market For Order Flow ...
int obTestsCount = ArraySize(conditions.obTests);
bool isOBTested = obTestsCount == 2;
if (!isOBTested)
{
//
int poiEvntsCount = ArraySize(consolidationPoiEvents);
bool hasEvent = IsValidSize(poiEvntsCount);
if (hasEvent)
XOBTest test;
bool hasTest = ReTestMarket(
test,
conditions.obTests,
consolidationState,
analyseState,
decisionState,
visionCycleHelper.mPOIDrawer //
);
if (hasTest)
{
//
bool hasNewBullOB = Contains(
X_BULLISH_ORDERBLOCK_DETECTED,
consolidationPoiEvents //
);
//
bool hasNewBearOB = Contains(
X_BEARISH_ORDERBLOCK_DETECTED,
consolidationPoiEvents //
);
//
bool hasNewOB =
hasNewBullOB ||
hasNewBearOB;
//
if (hasNewOB)
{
//
XCOrderBlock *ob = NULL;
if (hasNewBullOB)
{
//
int lastIDX = consolidationState.CountBullishOrderBlocks() - 1;
ob = consolidationState.bullishOrderBlocks[lastIDX];
//
// Validate OB ...
}
else if (hasNewBearOB)
{
//
int lastIDX = consolidationState.CountBearishOrderBlocks() - 1;
ob = consolidationState.bearishOrderBlocks[lastIDX];
//
// Validate OB ...
}
//
if (ob != NULL && ob.IsValid())
{
//
conditions.cOB = ob;
//
conditions.cOBAt = cTime;
//
hasCOB =
conditions.cOB != NULL &&
conditions.cOB.IsValid() &&
IsValid(conditions.cOBAt);
}
}
AddRef(
test,
conditions.obTests);
}
}
//
if (hasCOB)
{
conditions.cOB.To(cTime);
}
//
bool hasAOB =
conditions.aOB != NULL &&
conditions.aOB.IsValid() &&
IsValid(conditions.aOBAt);
//
if (hasCOB &&
!hasAOB)
{
//
int poiEvntsCount = ArraySize(analysePoiEvents);
bool hasEvent = IsValidSize(poiEvntsCount);
if (hasEvent)
{
//
bool hasNewBullOB = Contains(
X_BULLISH_ORDERBLOCK_DETECTED,
analysePoiEvents //
);
//
bool hasNewBearOB = Contains(
X_BEARISH_ORDERBLOCK_DETECTED,
analysePoiEvents //
);
//
bool hasNewOB =
hasNewBullOB ||
hasNewBearOB;
//
if (hasNewOB)
{
//
XCOrderBlock *ob = NULL;
if (hasNewBullOB)
{
//
int lastIDX = analyseState.CountBullishOrderBlocks() - 1;
ob = analyseState.bullishOrderBlocks[lastIDX];
//
// Validate OB ...
}
else if (hasNewBearOB)
{
//
int lastIDX = analyseState.CountBearishOrderBlocks() - 1;
ob = analyseState.bearishOrderBlocks[lastIDX];
//
// Validate OB ...
}
//
if (ob != NULL && ob.IsValid())
{
//
conditions.aOB = ob;
//
conditions.aOBAt = cTime;
//
hasAOB =
conditions.aOB != NULL &&
conditions.aOB.IsValid() &&
IsValid(conditions.aOBAt);
}
}
}
}
//
if (hasAOB)
{
conditions.aOB.To(cTime);
}
//
result = hasCOB &&
hasAOB;
if (!result)
{
return result;
}
//
// DRAW ...
//
//
// Draw Orer Block ...
bool isBullishCOB = conditions.cOB.IsBullish();
if (isBullishCOB)
{
//
XCBullishOrderBlockObject *iObj;
bool isCreated = consolidationCycleHelper
.mPOIDrawer
.CreateBullishOrderBlock(
conditions.cOB,
iObj //
);
}
else
{
//
XCBearishOrderBlockObject *iObj;
bool isCreated = consolidationCycleHelper
.mPOIDrawer
.CreateBearishOrderBlock(
conditions.cOB,
iObj //
);
}
bool isBullishAOB = conditions.aOB.IsBullish();
if (isBullishAOB)
{
//
XCBullishOrderBlockObject *iObj;
bool isCreated = analyseCycleHelper
.mPOIDrawer
.CreateBullishOrderBlock(
conditions.aOB,
iObj //
);
}
else
{
//
XCBearishOrderBlockObject *iObj;
bool isCreated = analyseCycleHelper
.mPOIDrawer
.CreateBearishOrderBlock(
conditions.aOB,
iObj //
);
}
//
// Draw From Bar ...
XOHCL cOBFromBar;
bool hasCOBFromBar = cOBFromBar.Init(
conditions.cOB.GetSymbol(),
conditions.cOB.GetPeriod(),
conditions.cOB.From() //
);
if (hasCOBFromBar)
{
//
XCOHCLObject *barObject;
bool iCreated = consolidationCycleHelper
.mPOIDrawer
.CreateBar(
cOBFromBar,
barObject //
);
}
//
// Draw From Bar ...
XOHCL aOBFromBar;
bool hasAOBFromBar = aOBFromBar.Init(
conditions.aOB.GetSymbol(),
conditions.aOB.GetPeriod(),
conditions.aOB.From() //
);
if (hasAOBFromBar)
{
//
XCOHCLObject *barObject;
bool iCreated = analyseCycleHelper
.mPOIDrawer
.CreateBar(
aOBFromBar,
barObject //
);
}
//
// END DRAW ...
//
//
// Check AOB Activation ...
if (!conditions.isAOBActivated)
{
//
int aPeakRepetition = analyseCycleHelper.CountPrevPeakRepetition();
int aValeRepetition = analyseCycleHelper.CountPrevValeRepetition();
//
bool isActivated =
//
bid >= conditions.aOB.Lower() &&
bid <= conditions.aOB.Upper() &&
//
cBar.low >= conditions.aOB.Lower() &&
cBar.high <= conditions.aOB.Upper() &&
//
(conditions.aOB.IsBullish()
? decisionXConditions.valesBuffer[1] >= conditions.aOB.Lower() &&
decisionXConditions.valesBuffer[1] <= conditions.aOB.Upper()
: decisionXConditions.peaksBuffer[1] >= conditions.aOB.Lower() &&
decisionXConditions.peaksBuffer[1] <= conditions.aOB.Upper())
//
;
//
if (isActivated)
{
//
conditions.aOBActivatedAt = cTime;
conditions.isAOBActivated = isActivated;
}
}
//
// Check COB Activation ...
if (!conditions.isCOBActivated)
{
//
int aPeakRepetition = analyseCycleHelper.CountPrevPeakRepetition();
int aValeRepetition = analyseCycleHelper.CountPrevValeRepetition();
//
bool isActivated =
//
bid >= conditions.cOB.Lower() &&
bid <= conditions.cOB.Upper() &&
//
cBar.low >= conditions.cOB.Lower() &&
cBar.high <= conditions.cOB.Upper() &&
//
(conditions.cOB.IsBullish()
? decisionXConditions.valesBuffer[1] >= conditions.cOB.Lower() &&
decisionXConditions.valesBuffer[1] <= conditions.cOB.Upper()
: decisionXConditions.peaksBuffer[1] >= conditions.cOB.Lower() &&
decisionXConditions.peaksBuffer[1] <= conditions.cOB.Upper())
//
;
//
if (isActivated)
{
//
conditions.cOBActivatedAt = cTime;
conditions.isCOBActivated = isActivated;
}
}
//
result = conditions.isAOBActivated ||
conditions.isCOBActivated;
if (!result)
{
return result;
}
// TODO:
return false;
//
double upper = 0;
@@ -1607,3 +1242,237 @@ int AddX121SMCXOBSConditionsIfNotExists(
}
//
//
//
/**
* Retest Market ...
*
* @param test: XOBTest instance Reference, Represet Result Test ...
* @param tests: XOBTest instance Reference Collection, Represet Founded Tests till now ...
* @param htfState: XPOIState instance Reference ...
* @param mtfState: XPOIState instance Reference ...
* @param ttfState: XPOIState instance Reference ...
*
* @return ( bool )
*/
bool ReTestMarket(
XOBTest &test,
XOBTest &tests[],
XPOIState &htfState,
XPOIState &mtfState,
XPOIState &ttfState, //
//
XCPOIDrawer *drawer
//
)
{
//
bool result = false;
//
test.Clean();
//
int testsCount = ArraySize(tests);
bool hasTests = IsValidSize(testsCount);
XOBTest lastTest;
if (hasTests)
{
lastTest = tests[testsCount - 1];
}
//
// Detect Order Blocks ...
// HTF ...
//
// Bullish OBs ...
XCOrderBlock *bullOBs[];
bool hasYoungestBullOB = false;
XCOrderBlock *youngestBullOB = NULL;
int bullOBsCount = ExtractUnActivatedOBs(
htfState.bullishOrderBlocks,
bullOBs //
);
//
bool isBullOBsPassed = bullOBsCount >= 1;
if (isBullOBsPassed)
{
//
XBoxZone boxes[];
int boxesCount = ToBox(
bullOBs,
boxes //
);
int youngestBoxIDX = GetYoungest(boxes);
hasYoungestBullOB = IsValidIndex(youngestBoxIDX);
if (hasYoungestBullOB)
{
youngestBullOB = bullOBs[youngestBoxIDX];
}
}
//
// Bearish OBs ...
XCOrderBlock *bearOBs[];
bool hasYoungestBearOB = false;
XCOrderBlock *youngestBearOB = NULL;
int bearOBsCount = ExtractUnActivatedOBs(
htfState.bearishOrderBlocks,
bearOBs //
);
//
bool isBearOBsPassed = bearOBsCount >= 1;
if (isBearOBsPassed)
{
//
XBoxZone boxes[];
int boxesCount = ToBox(
bearOBs,
boxes //
);
int youngestBoxIDX = GetYoungest(boxes);
hasYoungestBearOB = IsValidIndex(youngestBoxIDX);
if (hasYoungestBearOB)
{
youngestBearOB = bearOBs[youngestBoxIDX];
}
}
//
result = isBullOBsPassed ||
isBearOBsPassed;
if (!result)
{
return result;
}
//
// DRAW ...
//
//
XCBaseObject *drawnObjects[];
//
if (hasYoungestBullOB)
{
//
XCBullishOrderBlockObject *iObj;
bool isCreated = drawer
.CreateBullishOrderBlock(
youngestBullOB,
iObj //
);
//
if (isCreated)
{
//
Add(
(XCBaseObject *)iObj,
drawnObjects //
);
}
}
//
if (hasYoungestBearOB)
{
//
XCBearishOrderBlockObject *iObj;
bool isCreated = drawer
.CreateBearishOrderBlock(
youngestBearOB,
iObj //
);
//
if (isCreated)
{
//
Add(
(XCBaseObject *)iObj,
drawnObjects //
);
}
}
//
// END DRAW ...
//
//
Print("OBs Passed ...");
//
return result;
}
/**
* Extract UnActivated Order Blocks ...
*
* @return ( int )
*/
int ExtractUnActivatedOBs(
XCOrderBlock *&source[],
XCOrderBlock *&obs[] //
)
{
//
int result = 0;
//
Clean(obs);
//
int count = ArraySize(source);
bool hasOB = IsValidSize(count);
if (!hasOB)
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
bool isBullish = source[i].IsBullish();
ENUM_X_DIRECTION forDir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
//
//
//
XOHCL activatedBar;
ENUM_X_DIRECTION activatedDir;
bool isActivated = source[i].IsActivated(
forDir,
activatedBar,
activatedDir //
);
if (!isActivated)
{
//
Add(
source[i],
obs //
);
}
}
//
result = ArraySize(obs);
//
return result;
}
//
+4 -752
View File
@@ -29,9 +29,6 @@
//
#include "../Signals/x-121.smc.x.signal.lib.mq5"
#include "../Signals/x-121.smc.xobs.signal.lib.mq5"
#include "../Signals/x-121.smc.xhkpv.signal.lib.mq5"
#include "../Signals/x-121.smc.xobpv.signal.lib.mq5"
#include "../Signals/x-121.smc.xiobpv.signal.lib.mq5"
//
// Definitions ...
@@ -47,9 +44,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// Props ...
bool useXSignal;
bool useXOBSSignal;
bool useXHKPVSignal;
bool useXOBPVSignal;
bool useXIOBPVSignal;
//
// Constructor(s) ...
@@ -68,15 +62,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// Deconstructur ...
void ~XCX121SMCStrategy()
{
//
Destroy();
//
Clean(mXConditionsCollection);
Clean(mXOBSConditionsCollection);
Clean(mXHKPVConditionsCollection);
Clean(mXOBPVConditionsCollection);
Clean(mXIOBPVConditionsCollection);
}
//
@@ -117,6 +103,10 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
*/
void Destroy() override
{
//
Clean(mXConditionsCollection);
Clean(mXOBSConditionsCollection);
//
ZeroMemory(mTriggerCycleHelper);
ZeroMemory(mDecisionCycleHelper);
@@ -212,9 +202,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
bool hasXSignal = false;
bool hasXOBSSignal = false;
bool hasXHKPVSignal = false;
bool hasXOBPVSignal = false;
bool hasXIOBPVSignal = false;
//
// X Signal ...
@@ -234,33 +221,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
hasSignal = hasXOBSSignal;
}
//
// XHKPV Signal ...
if (useXHKPVSignal && !hasSignal)
{
//
hasXHKPVSignal = DetectXHKPVSignal(conditions);
hasSignal = hasXHKPVSignal;
}
//
// XOBPV Signal ...
if (useXOBPVSignal && !hasSignal)
{
//
hasXOBPVSignal = DetectXOBPVSignal(conditions);
hasSignal = hasXOBPVSignal;
}
//
// XIOBPV Signal ...
if (useXIOBPVSignal && !hasSignal)
{
//
hasXIOBPVSignal = DetectXIOBPVSignal(conditions);
hasSignal = hasXIOBPVSignal;
}
//
result = hasSignal;
if (!result)
@@ -450,57 +410,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
);
}
//
// XHKPV Guard Detection ...
if (useXHKPVSignal)
{
//
bool hasGuard = DetectX121SMCXHKPVGuards(
guards,
positions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
}
//
// XOBPV Guard Detection ...
if (useXOBPVSignal)
{
//
bool hasGuard = DetectX121SMCXOBPVGuards(
guards,
positions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
}
//
// XIOBPV Guard Detection ...
if (useXIOBPVSignal)
{
//
bool hasGuard = DetectX121SMCXIOBPVGuards(
guards,
positions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
}
//
count = ArraySize(guards);
result = IsValidSize(count);
@@ -992,660 +901,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
return result;
}
//
// XHKPV Signal ...
bool DetectXHKPVSignal(
X121SMCStrategyConditions &conditions //
)
{
//
bool result = false;
//
bool isBullish = false;
bool isBearish = false;
//
int zIndex = 0;
int cIndex = zIndex + 1;
int pIndex = cIndex + 1;
int ppIndex = pIndex + 1;
//
string symbol = GetSymbol();
ENUM_TIMEFRAMES period = GetPeriod();
//
XOHCL zBar;
result = zBar.Init(
symbol,
period,
zIndex //
);
if (!result)
{
return result;
}
//
XOHCL cBar;
result = cBar.Init(
symbol,
period,
cIndex //
);
if (!result)
{
return result;
}
//
XOHCL pBar;
result = pBar.Init(
symbol,
period,
pIndex //
);
if (!result)
{
return result;
}
//
double cLL = cBar.FindLowest(7, MODE_LOW);
double cHH = cBar.FindHighest(7, MODE_HIGH);
//
datetime cTime = TimeCurrent();
//
ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_XHKPV;
string providerStr = ToString(provider);
//
// Detect Setup Conditions ...
datetime setupTime = mXHKPVConditions.setupTime;
bool isSetuped = mXHKPVConditions.IsSetuped();
ENUM_X_DIRECTION setupDir = mXHKPVConditions.dir;
if (!isSetuped)
{
//
// Detect Signal Setup ...
isSetuped = DetectX121SMCXHKPVSignalSetup(
symbol,
period,
mXHKPVConditions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
setupDir = mXHKPVConditions.dir;
setupTime = mXHKPVConditions.setupTime;
//
if (isSetuped)
{
//
int items = AddX121SMCXHKPVConditionsIfNotExists(
mXHKPVConditions,
mXHKPVConditionsCollection //
);
//
mXHKPVConditions.Clean();
}
}
//
int conditionsCount = ArraySize(mXHKPVConditionsCollection);
result = IsValidSize(conditionsCount);
if (!result)
{
return result;
}
//
// Looking For Conditions ...
int selectedIndex = 0;
X121SMCStrategyXHKPVSignalConditions mTmpConditions[];
Copy(
mXHKPVConditionsCollection,
mTmpConditions //
);
X121SMCStrategyXHKPVSignalConditions mConditions;
for (int i = 0; i < conditionsCount; i++)
{
//
// Check Triggers ...
bool canTrigger = mTmpConditions[i].CanTrigger();
datetime triggerTime = mTmpConditions[i].triggerTime;
if (!canTrigger)
{
//
// Detect Signal Trigger ...
canTrigger = DetectX121SMCXHKPVSignalTrigger(
mTmpConditions[i],
symbol,
period,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
result = canTrigger;
if (!result)
{
//
bool isISetuped = mTmpConditions[i].IsSetuped();
if (!isISetuped)
{
//
ArrayRemove(
mXHKPVConditionsCollection,
i,
1 //
);
}
continue;
}
//
triggerTime = mTmpConditions[i].triggerTime;
}
//
if (canTrigger)
{
//
selectedIndex = i;
mConditions = mTmpConditions[i];
break;
}
}
//
result = IsValid(mConditions.setupTime) &&
HasDirection(mConditions.dir);
if (!result)
{
return result;
}
//
// Remove Selected Index from Main Collection ...
ArrayRemove(
mXHKPVConditionsCollection,
selectedIndex,
1 //
);
//
// Check Signal Direction ...
isBullish = IsBullish(mConditions.dir);
isBearish = IsBearish(mConditions.dir);
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
//
// Issues Signal on Conditions ...
conditions.sl = mConditions.sl;
conditions.provider = providerStr;
conditions.signalDir = mConditions.dir;
conditions.target = mConditions.target;
//
return result;
}
//
// XOBPV Signal ...
bool DetectXOBPVSignal(
X121SMCStrategyConditions &conditions //
)
{
//
bool result = false;
//
bool isBullish = false;
bool isBearish = false;
//
int zIndex = 0;
int cIndex = zIndex + 1;
int pIndex = cIndex + 1;
int ppIndex = pIndex + 1;
//
string symbol = GetSymbol();
ENUM_TIMEFRAMES period = GetPeriod();
//
XOHCL zBar;
result = zBar.Init(
symbol,
period,
zIndex //
);
if (!result)
{
return result;
}
//
XOHCL cBar;
result = cBar.Init(
symbol,
period,
cIndex //
);
if (!result)
{
return result;
}
//
XOHCL pBar;
result = pBar.Init(
symbol,
period,
pIndex //
);
if (!result)
{
return result;
}
//
double cLL = cBar.FindLowest(7, MODE_LOW);
double cHH = cBar.FindHighest(7, MODE_HIGH);
//
datetime cTime = TimeCurrent();
//
ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_XOBPV;
string providerStr = ToString(provider);
//
// Detect Setup Conditions ...
datetime setupTime = mXOBPVConditions.setupTime;
bool isSetuped = mXOBPVConditions.IsSetuped();
ENUM_X_DIRECTION setupDir = mXOBPVConditions.dir;
if (!isSetuped)
{
//
// Detect Signal Setup ...
isSetuped = DetectX121SMCXOBPVSignalSetup(
symbol,
period,
mXOBPVConditions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
setupDir = mXOBPVConditions.dir;
setupTime = mXOBPVConditions.setupTime;
//
if (isSetuped)
{
//
int items = AddX121SMCXOBPVConditionsIfNotExists(
mXOBPVConditions,
mXOBPVConditionsCollection //
);
//
mXOBPVConditions.Clean();
}
}
//
int conditionsCount = ArraySize(mXOBPVConditionsCollection);
result = IsValidSize(conditionsCount);
if (!result)
{
return result;
}
//
// Looking For Conditions ...
int selectedIndex = 0;
X121SMCStrategyXOBPVSignalConditions mTmpConditions[];
Copy(
mXOBPVConditionsCollection,
mTmpConditions //
);
X121SMCStrategyXOBPVSignalConditions mConditions;
for (int i = 0; i < conditionsCount; i++)
{
//
// Check Triggers ...
bool canTrigger = mTmpConditions[i].CanTrigger();
datetime triggerTime = mTmpConditions[i].triggerTime;
if (!canTrigger)
{
//
// Detect Signal Trigger ...
canTrigger = DetectX121SMCXOBPVSignalTrigger(
mTmpConditions[i],
symbol,
period,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
result = canTrigger;
if (!result)
{
//
bool isISetuped = mTmpConditions[i].IsSetuped();
if (!isISetuped)
{
//
ArrayRemove(
mXOBPVConditionsCollection,
i,
1 //
);
}
continue;
}
//
triggerTime = mTmpConditions[i].triggerTime;
}
//
if (canTrigger)
{
//
selectedIndex = i;
mConditions = mTmpConditions[i];
break;
}
}
//
result = IsValid(mConditions.setupTime) &&
HasDirection(mConditions.dir);
if (!result)
{
return result;
}
//
// Remove Selected Index from Main Collection ...
ArrayRemove(
mXOBPVConditionsCollection,
selectedIndex,
1 //
);
//
// Check Signal Direction ...
isBullish = IsBullish(mConditions.dir);
isBearish = IsBearish(mConditions.dir);
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
//
// Issues Signal on Conditions ...
conditions.sl = mConditions.sl;
conditions.provider = providerStr;
conditions.signalDir = mConditions.dir;
conditions.target = mConditions.target;
//
return result;
}
//
// XIOBPV Signal ...
bool DetectXIOBPVSignal(
X121SMCStrategyConditions &conditions //
)
{
//
bool result = false;
//
bool isBullish = false;
bool isBearish = false;
//
int zIndex = 0;
int cIndex = zIndex + 1;
int pIndex = cIndex + 1;
int ppIndex = pIndex + 1;
//
string symbol = GetSymbol();
ENUM_TIMEFRAMES period = GetPeriod();
//
XOHCL zBar;
result = zBar.Init(
symbol,
period,
zIndex //
);
if (!result)
{
return result;
}
//
XOHCL cBar;
result = cBar.Init(
symbol,
period,
cIndex //
);
if (!result)
{
return result;
}
//
XOHCL pBar;
result = pBar.Init(
symbol,
period,
pIndex //
);
if (!result)
{
return result;
}
//
double cLL = cBar.FindLowest(7, MODE_LOW);
double cHH = cBar.FindHighest(7, MODE_HIGH);
//
datetime cTime = TimeCurrent();
//
ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_XIOBPV;
string providerStr = ToString(provider);
//
// Detect Setup Conditions ...
datetime setupTime = mXIOBPVConditions.setupTime;
bool isSetuped = mXIOBPVConditions.IsSetuped();
ENUM_X_DIRECTION setupDir = mXIOBPVConditions.dir;
if (!isSetuped)
{
//
// Detect Signal Setup ...
isSetuped = DetectX121SMCXIOBPVSignalSetup(
symbol,
period,
mXIOBPVConditions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
setupDir = mXIOBPVConditions.dir;
setupTime = mXIOBPVConditions.setupTime;
//
if (isSetuped)
{
//
int items = AddX121SMCXIOBPVConditionsIfNotExists(
mXIOBPVConditions,
mXIOBPVConditionsCollection //
);
//
mXIOBPVConditions.Clean();
}
}
//
int conditionsCount = ArraySize(mXIOBPVConditionsCollection);
result = IsValidSize(conditionsCount);
if (!result)
{
return result;
}
//
// Looking For Conditions ...
int selectedIndex = 0;
X121SMCStrategyXIOBPVSignalConditions mTmpConditions[];
Copy(
mXIOBPVConditionsCollection,
mTmpConditions //
);
X121SMCStrategyXIOBPVSignalConditions mConditions;
for (int i = 0; i < conditionsCount; i++)
{
//
// Check Triggers ...
bool canTrigger = mTmpConditions[i].CanTrigger();
datetime triggerTime = mTmpConditions[i].triggerTime;
if (!canTrigger)
{
//
// Detect Signal Trigger ...
canTrigger = DetectX121SMCXIOBPVSignalTrigger(
mTmpConditions[i],
symbol,
period,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
result = canTrigger;
if (!result)
{
//
bool isISetuped = mTmpConditions[i].IsSetuped();
if (!isISetuped)
{
//
ArrayRemove(
mXIOBPVConditionsCollection,
i,
1 //
);
}
continue;
}
//
triggerTime = mTmpConditions[i].triggerTime;
}
//
if (canTrigger)
{
//
selectedIndex = i;
mConditions = mTmpConditions[i];
break;
}
}
//
result = IsValid(mConditions.setupTime) &&
HasDirection(mConditions.dir);
if (!result)
{
return result;
}
//
// Remove Selected Index from Main Collection ...
ArrayRemove(
mXIOBPVConditionsCollection,
selectedIndex,
1 //
);
//
// Check Signal Direction ...
isBullish = IsBullish(mConditions.dir);
isBearish = IsBearish(mConditions.dir);
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
//
// Issues Signal on Conditions ...
conditions.sl = mConditions.sl;
conditions.provider = providerStr;
conditions.signalDir = mConditions.dir;
conditions.target = mConditions.target;
//
return result;
}
//
// Private ...
private:
@@ -1663,9 +918,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
useXSignal = false;
useXOBSSignal = true;
useXHKPVSignal = false;
useXOBPVSignal = false;
useXIOBPVSignal = false;
//
string symbol = GetSymbol();