This commit is contained in:
2025-01-21 05:46:01 +03:30
parent 6363320cc2
commit 560a54af30
16 changed files with 7623 additions and 859 deletions
@@ -359,6 +359,199 @@ class XC121SMCCycleHelper : public XCBase
return result;
}
/**
* Detect Market Structure Method 2 ...
*
* @param model: XMarketStructure instance Reference ...
*
* @return ( bool )
*/
bool DetectMarketStructure(
ENUM_X_DIRECTION &dir,
int pivotsCount = 3 //
)
{
//
bool result = false;
//
int barIndex = 0;
//
if (pivotsCount < 3)
{
pivotsCount = 3;
}
//
dir = X_DIRECTION_NONE;
string symbol = GetSymbol();
ENUM_TIMEFRAMES period = GetPeriod();
//
int hpIndex = -1;
int hpIndexes[];
double hpValues[];
//
int lvIndex = -1;
int lvIndexes[];
double lvValues[];
//
for (int i = 0; i < pivotsCount; i++)
{
//
hpIndex = barIndex;
lvIndex = barIndex;
//
double lastHP = 0;
double lastLV = 0;
//
int hpCount = ArraySize(hpIndexes);
int lvCount = ArraySize(lvIndexes);
//
if (IsValidSize(hpCount))
{
//
lastHP = hpValues[hpCount - 1];
hpIndex = hpIndexes[hpCount - 1];
}
//
if (IsValidSize(lvCount))
{
//
lastLV = lvValues[lvCount - 1];
lvIndex = lvIndexes[lvCount - 1];
}
//
if (lastHP == 0)
{
//
lastHP = mX121Helper
.xpvHelper
.GetPeak(hpIndex);
}
//
if (lastLV == 0)
{
//
lastLV = mX121Helper
.xpvHelper
.GetVale(lvIndex);
}
//
int highestPeakIndex = -1;
double highesrPeak =
mX121Helper
.xpvHelper
.GetHigherPeak(
highestPeakIndex,
lastHP,
hpIndex //
);
if (IsValidIndex(highestPeakIndex))
{
//
Add(
highestPeakIndex,
hpIndexes //
);
//
Add(
highesrPeak,
hpValues //
);
}
//
int lowestValeIndex = -1;
double lowestVale =
mX121Helper
.xpvHelper
.GetLowerVale(
lowestValeIndex,
lastLV,
lvIndex //
);
if (IsValidIndex(lowestValeIndex))
{
//
Add(
lowestValeIndex,
lvIndexes //
);
//
Add(
lowestVale,
lvValues //
);
}
//
bool canBreak = ArraySize(hpIndexes) >= pivotsCount ||
ArraySize(lvIndexes) >= pivotsCount;
if (canBreak)
{
break;
}
}
//
ArrayReverse(hpValues);
ArrayReverse(hpIndexes);
int countHPs = ArraySize(hpIndexes);
//
ArrayReverse(lvValues);
ArrayReverse(lvIndexes);
int countLVs = ArraySize(lvIndexes);
//
bool isValidHPs = countHPs >= pivotsCount;
bool isValidLVs = countLVs >= pivotsCount;
//
result = isValidHPs ||
isValidLVs;
if (!result)
{
return result;
}
//
if (isValidHPs && isValidLVs)
{
//
hpIndex = hpIndexes[countHPs - 1];
lvIndex = lvIndexes[countLVs - 1];
}
//
dir =
!isValidHPs && isValidLVs
? X_DIRECTION_BULLISH
: !isValidLVs && isValidHPs
? X_DIRECTION_BEARISH
: hpIndex < lvIndex
? X_DIRECTION_BEARISH
: lvIndex < hpIndex
? X_DIRECTION_BULLISH
: X_DIRECTION_ALL;
//
return result;
}
/**
* Retrieve Cycle Conditions ...
*
+36 -6
View File
@@ -309,18 +309,48 @@ bool DetectX121SMCGuards(
//
// Trigger ...
bool hasTriggerBullishTrend = triggerXConditions.bullishTrendBuffer[1];
bool hasTriggerBearishTrend = triggerXConditions.bearishTrendBuffer[1];
ENUM_X_DIRECTION triggerTrendDir;
bool hasTriggerTrend =
triggerCycleHelper
.DetectMarketStructure(
triggerTrendDir //
);
bool hasTriggerBullishTrend =
hasTriggerTrend &&
IsBullish(triggerTrendDir);
bool hasTriggerBearishTrend =
hasTriggerTrend &&
IsBearish(triggerTrendDir);
//
// Decision ...
bool hasDecisionBullishTrend = decisionXConditions.bullishTrendBuffer[1];
bool hasDecisionBearishTrend = decisionXConditions.bearishTrendBuffer[1];
ENUM_X_DIRECTION decisionTrendDir;
bool hasDecisionTrend =
decisionCycleHelper
.DetectMarketStructure(
decisionTrendDir //
);
bool hasDecisionBullishTrend =
hasDecisionTrend &&
IsBullish(decisionTrendDir);
bool hasDecisionBearishTrend =
hasDecisionTrend &&
IsBearish(decisionTrendDir);
//
// Analyse ...
bool hasAnalyseBullishTrend = analyseXConditions.bullishTrendBuffer[1];
bool hasAnalyseBearishTrend = analyseXConditions.bearishTrendBuffer[1];
ENUM_X_DIRECTION analyseTrendDir;
bool hasAnalyseTrend =
analyseCycleHelper
.DetectMarketStructure(
analyseTrendDir //
);
bool hasAnalyseBullishTrend =
hasAnalyseTrend &&
IsBullish(analyseTrendDir);
bool hasAnalyseBearishTrend =
hasAnalyseTrend &&
IsBearish(analyseTrendDir);
//
// Consolidation Zone ...
+6 -6
View File
@@ -35,7 +35,7 @@
const string X121SMCStrategyToken = "X121SMC";
//
const string X121SMCXTestToken = "X121XTest";
const string X121SMCXToken = "X121X";
const string X121SMCXPZToken = "X121XPZ";
const string X121SMCXRSPVIToken = "X121XRSPVI";
const string X121SMCXSTRPVToken = "X121XSTRPV";
@@ -46,7 +46,7 @@ enum ENUM_X_121_SMC_PROVIDERS
{
//
X_121_SMC_PROVIDER_NONE,
X_121_SMC_PROVIDER_XTEST,
X_121_SMC_PROVIDER_X,
X_121_SMC_PROVIDER_XPZ,
X_121_SMC_PROVIDER_XRSPVI,
X_121_SMC_PROVIDER_XSTRPV,
@@ -704,8 +704,8 @@ string ToString(ENUM_X_121_SMC_PROVIDERS value)
switch (value)
{
//
case X_121_SMC_PROVIDER_XTEST:
result = X121SMCXTestToken;
case X_121_SMC_PROVIDER_X:
result = X121SMCXToken;
break;
//
@@ -747,9 +747,9 @@ ENUM_X_121_SMC_PROVIDERS ParseProvider(string value)
}
//
if (Contains(X121SMCXTestToken, value))
if (Contains(X121SMCXToken, value))
{
result = X_121_SMC_PROVIDER_XTEST;
result = X_121_SMC_PROVIDER_X;
}
else if (Contains(X121SMCXPZToken, value))
{
File diff suppressed because it is too large Load Diff
+54 -335
View File
@@ -58,9 +58,6 @@ struct X121SMCStrategyXPZSignalConditions
bool isPriceZoneValidForPeak;
bool isPriceZoneValidForVale;
//
XPVPivot pivotZone;
//
// Constructor ...
X121SMCStrategyXPZSignalConditions()
@@ -181,7 +178,6 @@ struct X121SMCStrategyXPZSignalConditions
//
priceZone.Clean();
pivotZone.Clean();
isPriceZoneValidForPeak = false;
isPriceZoneValidForVale = false;
}
@@ -194,13 +190,6 @@ struct X121SMCStrategyXPZSignalConditions
X121SMCStrategyXPZSignalConditions mXPZConditions;
X121SMCStrategyXPZSignalConditions mXPZConditionsCollection[];
//
double X121SMCXPZPivotPeak;
double X121SMCXPZPivotVale;
datetime X121SMCXPZPivotEnd;
datetime X121SMCXPZPivotStart;
ENUM_XPV_PIVOTS X121SMCXPZPivotType = XPV_NONE;
//
// Extension Functions ...
@@ -425,25 +414,63 @@ bool DetectX121SMCXPZSiganlSetup(
//
// Consolidation ...
//
bool hasConsolidationBullishTrend = consolidationXConditions.isTrendBullish;
bool hasConsolidationBearishTrend = consolidationXConditions.isTrendBearish;
ENUM_X_DIRECTION consolidationTrendDir;
bool hasConsolidationTrend =
consolidationCycleHelper
.DetectMarketStructure(
consolidationTrendDir //
);
bool hasConsolidationBullishTrend =
hasConsolidationTrend &&
IsBullish(consolidationTrendDir);
bool hasConsolidationBearishTrend =
hasConsolidationTrend &&
IsBearish(consolidationTrendDir);
//
// Verification ...
bool hasVerificationBullishTrend = verificationXConditions.isTrendBullish;
bool hasVerificationBearishTrend = verificationXConditions.isTrendBearish;
ENUM_X_DIRECTION verificationTrendDir;
bool hasVerificationTrend =
verificationCycleHelper
.DetectMarketStructure(
verificationTrendDir //
);
bool hasVerificationBullishTrend =
hasVerificationTrend &&
IsBullish(verificationTrendDir);
bool hasVerificationBearishTrend =
hasVerificationTrend &&
IsBearish(verificationTrendDir);
//
// Analyse ...
bool hasAnalyseBullishTrend = analyseXConditions.isTrendBullish;
bool hasAnalyseBearishTrend = analyseXConditions.isTrendBearish;
ENUM_X_DIRECTION analyseTrendDir;
bool hasAnalyseTrend =
analyseCycleHelper
.DetectMarketStructure(
analyseTrendDir //
);
bool hasAnalyseBullishTrend =
hasAnalyseTrend &&
IsBullish(analyseTrendDir);
bool hasAnalyseBearishTrend =
hasAnalyseTrend &&
IsBearish(analyseTrendDir);
//
// Decision ...
bool hasDecisionBullishTrend = decisionXConditions.isTrendBullish;
bool hasDecisionBearishTrend = decisionXConditions.isTrendBearish;
ENUM_X_DIRECTION decisionTrendDir;
bool hasDecisionTrend =
decisionCycleHelper
.DetectMarketStructure(
decisionTrendDir //
);
bool hasDecisionBullishTrend =
hasDecisionTrend &&
IsBullish(decisionTrendDir);
bool hasDecisionBearishTrend =
hasDecisionTrend &&
IsBearish(decisionTrendDir);
//
// Detect Bar State ...
@@ -541,314 +568,6 @@ bool DetectX121SMCXPZSiganlSetup(
//
;
//
// Detect PV Pivot ...
//
bool isPivotPeakZoneRejected = false;
bool isPivotPeakZoneBreakedUp = false;
bool isPivotPeakZoneBreakedDown = false;
bool isPivotValeZoneRejected = false;
bool isPivotValeZoneBreakedUp = false;
bool isPivotValeZoneBreakedDown = false;
bool hasPivot = conditions.pivotZone.IsValid();
if (!hasPivot)
{
//
hasPivot = IsValid(X121SMCXPZPivotStart);
if (!hasPivot)
{
//
bool isNewVale = decisionXConditions.isNewVale;
bool isNewValeOverLast = decisionXConditions.isNewValeOverLast;
bool isNewValeUnderLast = decisionXConditions.isNewValeUnderLast;
bool isSameVales = decisionXConditions.valesBuffer[1] ==
decisionXConditions.valesBuffer[2] &&
decisionXConditions.valesBuffer[2] ==
decisionXConditions.valesBuffer[3];
bool isSameCycleVales = decisionXConditions.valesBuffer[1] ==
analyseXConditions.valesBuffer[1] &&
analyseXConditions.valesBuffer[1] ==
verificationXConditions.valesBuffer[1];
//
bool isNewPeak = decisionXConditions.isNewPeak;
bool isNewPeakOverLast = decisionXConditions.isNewPeakOverLast;
bool isNewPeakUnderLast = decisionXConditions.isNewPeakUnderLast;
bool isSamePeaks = decisionXConditions.peaksBuffer[1] ==
decisionXConditions.peaksBuffer[2] &&
decisionXConditions.peaksBuffer[2] ==
decisionXConditions.peaksBuffer[3];
bool isSameCyclePeaks = decisionXConditions.peaksBuffer[1] ==
analyseXConditions.peaksBuffer[1] &&
analyseXConditions.peaksBuffer[1] ==
verificationXConditions.peaksBuffer[1];
//
bool isValeStart =
// isSameVales;
isSameVales &&
isSameCycleVales;
bool isPeakStart =
// isSamePeaks;
isSamePeaks &&
isSameCyclePeaks;
//
bool isStart = isPeakStart ||
isValeStart;
if (isStart)
{
//
X121SMCXPZPivotStart = cTime;
X121SMCXPZPivotType =
isPeakStart
? XPV_PEAK
: XPV_VALE;
//
X121SMCXPZPivotPeak = decisionXConditions.peaksBuffer[1];
X121SMCXPZPivotVale = decisionXConditions.valesBuffer[1];
}
//
hasPivot = IsValid(X121SMCXPZPivotStart);
//
// Create XPVPivot instance ...
if (hasPivot)
{
//
conditions.pivotZone.symbol = symbol;
conditions.pivotZone.period = period;
//
conditions.pivotZone.to = cTime;
conditions.pivotZone.repetition = 3;
//
conditions.pivotZone.upper = X121SMCXPZPivotPeak;
conditions.pivotZone.lower = X121SMCXPZPivotVale;
//
conditions.pivotZone.type = X121SMCXPZPivotType;
conditions.pivotZone.from = X121SMCXPZPivotStart;
}
}
}
//
if (hasPivot)
{
//
bool isBreaked = X121SMCXPZPivotType == XPV_PEAK
? decisionXConditions.isBreakedUpPrevPeak
: decisionXConditions.isBreakedDownPrevVale;
//
if (!isBreaked)
{
//
X121SMCXPZPivotPeak = decisionXConditions.peaksBuffer[1];
X121SMCXPZPivotVale = decisionXConditions.valesBuffer[1];
//
conditions.pivotZone.to = cTime;
conditions.pivotZone.repetition++;
conditions.pivotZone.upper = X121SMCXPZPivotPeak;
conditions.pivotZone.lower = X121SMCXPZPivotVale;
}
else
{
//
X121SMCXPZPivotEnd = cTime;
conditions.pivotZone.to = cTime;
}
//
// Fill Pivot State ...
//
XPOIState analysePivotState;
DetectPivotPOIs(
conditions.pivotZone,
analyseState,
analysePivotState //
);
//
XPOIState decisionPivotState;
DetectPivotPOIs(
conditions.pivotZone,
decisionState,
decisionPivotState //
);
//
// Combine two State ...
XPOIState combinedPivotState;
XPOIState iStates[];
AddRef(
analysePivotState,
iStates //
);
AddRef(
decisionPivotState,
iStates //
);
CombineStates(
combinedPivotState,
iStates //
);
combinedPivotState = decisionPivotState;
//
ArrayFree(iStates);
//
combinedPivotState.time = decisionPivotState.time;
combinedPivotState.symbol = decisionPivotState.symbol;
combinedPivotState.period = decisionPivotState.period;
//
// Hold Only Areas Which on Upper or Lower bondary of Pivot Zone ...
FilterPivotState(
conditions.pivotZone,
combinedPivotState //
);
//
conditions.pivotZone.state = combinedPivotState;
//
double peakUpper = 0;
double peakLower = 0;
double valeUpper = 0;
double valeLower = 0;
//
datetime peakTo = NULL;
datetime valeTo = NULL;
datetime peakFrom = NULL;
datetime valeFrom = NULL;
//
bool hasBoxData = DetectPivotStateBoxData(
conditions.pivotZone,
peakUpper,
peakLower,
peakFrom,
peakTo,
valeUpper,
valeLower,
valeFrom,
valeTo //
);
//
// Calculate Pivot Tick Zones ...
//
int ticksLevels = decisionCycleHelper
.mPOIDetector
.TicksRangeZoneLevel();
int ticksRange = decisionCycleHelper
.mPOIDetector
.TicksRangeZoneRange();
//
CalculatePivotTickZone(
conditions.pivotZone,
ticksLevels,
ticksRange //
);
//
isPivotPeakZoneRejected =
hasBoxData &&
(
//
IsBarReject(
peakLower,
X_DIRECTION_BEARISH,
cBar //
)
//
||
//
IsBarReject(
peakUpper,
X_DIRECTION_BEARISH,
cBar //
)
//
);
isPivotPeakZoneBreakedUp =
hasBoxData &&
IsBarBreak(
peakUpper,
X_DIRECTION_BULLISH,
cBar //
);
isPivotPeakZoneBreakedDown =
hasBoxData &&
IsBarBreak(
peakLower,
X_DIRECTION_BEARISH,
cBar //
);
//
isPivotValeZoneRejected =
hasBoxData &&
(
//
IsBarReject(
valeLower,
X_DIRECTION_BULLISH,
cBar //
)
//
||
//
IsBarReject(
valeUpper,
X_DIRECTION_BULLISH,
cBar //
)
//
);
isPivotValeZoneBreakedUp =
hasBoxData &&
IsBarBreak(
valeUpper,
X_DIRECTION_BULLISH,
cBar //
);
isPivotValeZoneBreakedDown =
hasBoxData &&
IsBarBreak(
valeLower,
X_DIRECTION_BEARISH,
cBar //
);
}
//
bool isPivotEnded = IsValid(X121SMCXPZPivotEnd);
if (isPivotEnded)
{
//
X121SMCXPZPivotPeak = 0;
X121SMCXPZPivotVale = 0;
X121SMCXPZPivotEnd = NULL;
X121SMCXPZPivotStart = NULL;
X121SMCXPZPivotType = XPV_NONE;
//
conditions.pivotZone.Clean();
}
//
// Detect Price Zone ...
@@ -989,8 +708,6 @@ bool DetectX121SMCXPZSiganlSetup(
//
bool isPriceZoneBullish =
//
hasPivot &&
//
hasVerificationBullishTrend &&
hasAnalyseBullishTrend &&
@@ -1003,14 +720,14 @@ bool DetectX121SMCXPZSiganlSetup(
isCBarBullishFormed &&
isInDecisionDiscount &&
decisionXConditions.isAtrLowerUnderVale &&
decisionXConditions.isAtrLowerSlopeBullish
decisionXConditions.isAtrLowerSlopeBullish &&
//
true
//
;
//
bool isPriceZoneBearish =
//
hasPivot &&
//
hasVerificationBearishTrend &&
hasAnalyseBearishTrend &&
@@ -1023,7 +740,9 @@ bool DetectX121SMCXPZSiganlSetup(
isInDecisionPremium &&
isCBarBearishFormed &&
decisionXConditions.isAtrUpperOverPeak &&
decisionXConditions.isAtrUpperSlopeBearish
decisionXConditions.isAtrUpperSlopeBearish &&
//
true
//
;
@@ -445,25 +445,63 @@ bool DetectX121SMCXRSPVISiganlSetup(
//
// Consolidation ...
//
bool hasConsolidationBullishTrend = consolidationXConditions.isTrendBullish;
bool hasConsolidationBearishTrend = consolidationXConditions.isTrendBearish;
ENUM_X_DIRECTION consolidationTrendDir;
bool hasConsolidationTrend =
consolidationCycleHelper
.DetectMarketStructure(
consolidationTrendDir //
);
bool hasConsolidationBullishTrend =
hasConsolidationTrend &&
IsBullish(consolidationTrendDir);
bool hasConsolidationBearishTrend =
hasConsolidationTrend &&
IsBearish(consolidationTrendDir);
//
// Verification ...
bool hasVerificationBullishTrend = verificationXConditions.isTrendBullish;
bool hasVerificationBearishTrend = verificationXConditions.isTrendBearish;
ENUM_X_DIRECTION verificationTrendDir;
bool hasVerificationTrend =
verificationCycleHelper
.DetectMarketStructure(
verificationTrendDir //
);
bool hasVerificationBullishTrend =
hasVerificationTrend &&
IsBullish(verificationTrendDir);
bool hasVerificationBearishTrend =
hasVerificationTrend &&
IsBearish(verificationTrendDir);
//
// Analyse ...
bool hasAnalyseBullishTrend = analyseXConditions.isTrendBullish;
bool hasAnalyseBearishTrend = analyseXConditions.isTrendBearish;
ENUM_X_DIRECTION analyseTrendDir;
bool hasAnalyseTrend =
analyseCycleHelper
.DetectMarketStructure(
analyseTrendDir //
);
bool hasAnalyseBullishTrend =
hasAnalyseTrend &&
IsBullish(analyseTrendDir);
bool hasAnalyseBearishTrend =
hasAnalyseTrend &&
IsBearish(analyseTrendDir);
//
// Decision ...
bool hasDecisionBullishTrend = decisionXConditions.isTrendBullish;
bool hasDecisionBearishTrend = decisionXConditions.isTrendBearish;
ENUM_X_DIRECTION decisionTrendDir;
bool hasDecisionTrend =
decisionCycleHelper
.DetectMarketStructure(
decisionTrendDir //
);
bool hasDecisionBullishTrend =
hasDecisionTrend &&
IsBullish(decisionTrendDir);
bool hasDecisionBearishTrend =
hasDecisionTrend &&
IsBearish(decisionTrendDir);
//
// Detect Bar State ...
@@ -423,25 +423,63 @@ bool DetectX121SMCXSTRPVSiganlSetup(
//
// Consolidation ...
//
bool hasConsolidationBullishTrend = consolidationXConditions.isTrendBullish;
bool hasConsolidationBearishTrend = consolidationXConditions.isTrendBearish;
ENUM_X_DIRECTION consolidationTrendDir;
bool hasConsolidationTrend =
consolidationCycleHelper
.DetectMarketStructure(
consolidationTrendDir //
);
bool hasConsolidationBullishTrend =
hasConsolidationTrend &&
IsBullish(consolidationTrendDir);
bool hasConsolidationBearishTrend =
hasConsolidationTrend &&
IsBearish(consolidationTrendDir);
//
// Verification ...
bool hasVerificationBullishTrend = verificationXConditions.isTrendBullish;
bool hasVerificationBearishTrend = verificationXConditions.isTrendBearish;
ENUM_X_DIRECTION verificationTrendDir;
bool hasVerificationTrend =
verificationCycleHelper
.DetectMarketStructure(
verificationTrendDir //
);
bool hasVerificationBullishTrend =
hasVerificationTrend &&
IsBullish(verificationTrendDir);
bool hasVerificationBearishTrend =
hasVerificationTrend &&
IsBearish(verificationTrendDir);
//
// Analyse ...
bool hasAnalyseBullishTrend = analyseXConditions.isTrendBullish;
bool hasAnalyseBearishTrend = analyseXConditions.isTrendBearish;
ENUM_X_DIRECTION analyseTrendDir;
bool hasAnalyseTrend =
analyseCycleHelper
.DetectMarketStructure(
analyseTrendDir //
);
bool hasAnalyseBullishTrend =
hasAnalyseTrend &&
IsBullish(analyseTrendDir);
bool hasAnalyseBearishTrend =
hasAnalyseTrend &&
IsBearish(analyseTrendDir);
//
// Decision ...
bool hasDecisionBullishTrend = decisionXConditions.isTrendBullish;
bool hasDecisionBearishTrend = decisionXConditions.isTrendBearish;
ENUM_X_DIRECTION decisionTrendDir;
bool hasDecisionTrend =
decisionCycleHelper
.DetectMarketStructure(
decisionTrendDir //
);
bool hasDecisionBullishTrend =
hasDecisionTrend &&
IsBullish(decisionTrendDir);
bool hasDecisionBearishTrend =
hasDecisionTrend &&
IsBearish(decisionTrendDir);
//
// Detect Bar State ...
+281 -33
View File
@@ -27,6 +27,7 @@
#include "../Classes/x-121.smc.market.cycle.helper.class.mq5"
//
#include "../Signals/x-121.smc.x.signal.lib.mq5"
#include "../Signals/x-121.smc.xpz.signal.lib.mq5"
#include "../Signals/x-121.smc.xrspvi.signal.lib.mq5"
#include "../Signals/x-121.smc.xstrpv.signal.lib.mq5"
@@ -43,6 +44,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
public:
//
// Props ...
bool useXSignal;
bool useXPZSignal;
bool useXRSPVISignal;
bool useXSTRPVSignal;
@@ -195,10 +197,20 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
bool hasSignal = false;
//
bool hasXSignal = false;
bool hasXPZSignal = false;
bool hasXRSPVISignal = false;
bool hasXSTRPVSignal = false;
//
// X Signal ...
if (useXSignal && !hasSignal)
{
//
hasXSignal = DetectXSignal(conditions);
hasSignal = hasXSignal;
}
//
// XPZ Signal ...
if (useXPZSignal && !hasSignal)
@@ -382,11 +394,11 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
}
//
// XSTRPV Guard Detection ...
if (useXSTRPVSignal)
// X Guard Detection ...
if (useXSignal)
{
//
bool hasGuard = DetectX121SMCXSTRPVGuards(
bool hasGuard = DetectX121SMCXGuards(
guards,
positions,
mTriggerCycleHelper,
@@ -415,6 +427,23 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
);
}
//
// XSTRPV Guard Detection ...
if (useXSTRPVSignal)
{
//
bool hasGuard = DetectX121SMCXSTRPVGuards(
guards,
positions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
}
//
// XRSPVI Guard Detection ...
if (useXRSPVISignal)
@@ -471,8 +500,8 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// Signalling Functions ...
//
// XSTRPV Signal ...
bool DetectXSTRPVSignal(
// X Signal ...
bool DetectXSignal(
X121SMCStrategyConditions &conditions //
)
{
@@ -537,22 +566,22 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
datetime cTime = TimeCurrent();
//
ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_XSTRPV;
ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_X;
string providerStr = ToString(provider);
//
// Detect Setup Conditions ...
datetime setupTime = mXSTRPVConditions.setupTime;
bool isSetuped = mXSTRPVConditions.IsSetuped();
ENUM_X_DIRECTION setupDir = mXSTRPVConditions.dir;
datetime setupTime = mXConditions.setupTime;
bool isSetuped = mXConditions.IsSetuped();
ENUM_X_DIRECTION setupDir = mXConditions.dir;
if (!isSetuped)
{
//
// Detect Signal Setup ...
isSetuped = DetectX121SMCXSTRPVSiganlSetup(
isSetuped = DetectX121SMCXSiganlSetup(
symbol,
period,
mXSTRPVConditions,
mXConditions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
@@ -562,25 +591,25 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
);
//
setupDir = mXSTRPVConditions.dir;
setupTime = mXSTRPVConditions.setupTime;
setupDir = mXConditions.dir;
setupTime = mXConditions.setupTime;
//
if (isSetuped)
{
//
int items = AddX121SMCXSTRPVConditionsIfNotExists(
mXSTRPVConditions,
mXSTRPVConditionsCollection //
int items = AddX121SMCXConditionsIfNotExists(
mXConditions,
mXConditionsCollection //
);
//
mXSTRPVConditions.Clean();
mXConditions.Clean();
}
}
//
int conditionsCount = ArraySize(mXSTRPVConditionsCollection);
int conditionsCount = ArraySize(mXConditionsCollection);
result = IsValidSize(conditionsCount);
if (!result)
{
@@ -590,12 +619,12 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
// Looking For Conditions ...
int selectedIndex = 0;
X121SMCStrategyXSTRPVSignalConditions mTmpConditions[];
X121SMCStrategyXSignalConditions mTmpConditions[];
Copy(
mXSTRPVConditionsCollection,
mXConditionsCollection,
mTmpConditions //
);
X121SMCStrategyXSTRPVSignalConditions mConditions;
X121SMCStrategyXSignalConditions mConditions;
for (int i = 0; i < conditionsCount; i++)
{
//
@@ -606,7 +635,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
{
//
// Detect Signal Trigger ...
canTrigger = DetectX121SMCXSTRPVSiganlTrigger(
canTrigger = DetectX121SMCXSiganlTrigger(
mTmpConditions[i],
symbol,
period,
@@ -628,7 +657,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
{
//
ArrayRemove(
mXSTRPVConditionsCollection,
mXConditionsCollection,
i,
1 //
);
@@ -661,7 +690,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
// Remove Selected Index from Main Collection ...
ArrayRemove(
mXSTRPVConditionsCollection,
mXConditionsCollection,
selectedIndex,
1 //
);
@@ -906,6 +935,224 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
return result;
}
//
// XSTRPV Signal ...
bool DetectXSTRPVSignal(
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_XSTRPV;
string providerStr = ToString(provider);
//
// Detect Setup Conditions ...
datetime setupTime = mXSTRPVConditions.setupTime;
bool isSetuped = mXSTRPVConditions.IsSetuped();
ENUM_X_DIRECTION setupDir = mXSTRPVConditions.dir;
if (!isSetuped)
{
//
// Detect Signal Setup ...
isSetuped = DetectX121SMCXSTRPVSiganlSetup(
symbol,
period,
mXSTRPVConditions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
setupDir = mXSTRPVConditions.dir;
setupTime = mXSTRPVConditions.setupTime;
//
if (isSetuped)
{
//
int items = AddX121SMCXSTRPVConditionsIfNotExists(
mXSTRPVConditions,
mXSTRPVConditionsCollection //
);
//
mXSTRPVConditions.Clean();
}
}
//
int conditionsCount = ArraySize(mXSTRPVConditionsCollection);
result = IsValidSize(conditionsCount);
if (!result)
{
return result;
}
//
// Looking For Conditions ...
int selectedIndex = 0;
X121SMCStrategyXSTRPVSignalConditions mTmpConditions[];
Copy(
mXSTRPVConditionsCollection,
mTmpConditions //
);
X121SMCStrategyXSTRPVSignalConditions 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 = DetectX121SMCXSTRPVSiganlTrigger(
mTmpConditions[i],
symbol,
period,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
result = canTrigger;
if (!result)
{
//
bool isISetuped = mTmpConditions[i].IsSetuped();
if (!isISetuped)
{
//
ArrayRemove(
mXSTRPVConditionsCollection,
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(
mXSTRPVConditionsCollection,
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;
}
//
// XRSPVI Signal ...
bool DetectXRSPVISignal(
@@ -1139,9 +1386,10 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
void InitialHelpers()
{
//
useXPZSignal = true;
useXRSPVISignal = true;
useXSTRPVSignal = true;
useXSignal = true;
useXPZSignal = false;
useXRSPVISignal = false;
useXSTRPVSignal = false;
//
string symbol = GetSymbol();
@@ -1209,12 +1457,12 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
// XATR ...
x121Inputs.xatrInputs.showATRUpper = showAll || true;
x121Inputs.xatrInputs.showATRLower = showAll || true;
x121Inputs.xatrInputs.showATRUpper = showAll || false;
x121Inputs.xatrInputs.showATRLower = showAll || false;
//
// XSTR ...
x121Inputs.xstrInputs.showStr = showAll || true;
x121Inputs.xstrInputs.showStr = showAll || false;
x121Inputs.xstrInputs.showStrUpper = showAll || false;
x121Inputs.xstrInputs.showStrLower = showAll || false;
@@ -1234,9 +1482,9 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
// XVWAP ...
x121Inputs.xvwapInputs.showVWapFast = showAll || true;
x121Inputs.xvwapInputs.showVWapMedium = showAll || true;
x121Inputs.xvwapInputs.showVWapSlow = showAll || true;
x121Inputs.xvwapInputs.showVWapFast = showAll || false;
x121Inputs.xvwapInputs.showVWapMedium = showAll || false;
x121Inputs.xvwapInputs.showVWapSlow = showAll || false;
//
// Initialize Cycle Helpers ...