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
+1 -4
View File
@@ -2782,10 +2782,7 @@ class XCPOIDrawer : public XCBase
}
//
if (!IsValid(to))
{
to = bar.time + PeriodSeconds(bar.period);
}
to = NormalizeTime(to);
//
string prefix = Prefix();
+530
View File
@@ -0,0 +1,530 @@
//////////////////////////////////////////////////////////////////////////////////
////// Detect Price Zones :
/////////////////////////////////////////////////////////////////////////////////
//
XPriceZones priceZone;
bool isPriceZoneValidForPeak;
bool isPriceZoneValidForVale;
//
priceZone.Clean();
isPriceZoneValidForPeak = false;
isPriceZoneValidForVale = false;
//
// Detect Price Zone ...
//
double pzPeak = decisionXConditions.peaksBuffer[1];
double pzVale = decisionXConditions.valesBuffer[1];
//
// Detecting Decision Price ones ...
XPriceZones decisionPriceZone;
bool hasDecisionPriceZone = CalculatePriceInsideZones(
decisionPriceZone,
decisionState,
cBar //
);
double decisionPriceZoneUpper = 0;
double decisionPriceZoneLower = 0;
bool isDecisionPriceZoneValidForPeak = false;
bool isDecisionPriceZoneValidForVale = false;
if (hasDecisionPriceZone)
{
//
bool hasBoundary = decisionPriceZone.GetBoundary(
X_DIRECTION_ALL,
decisionPriceZoneUpper,
decisionPriceZoneLower //
);
//
isDecisionPriceZoneValidForPeak =
hasBoundary &&
pzPeak <= decisionPriceZoneUpper &&
pzPeak >= decisionPriceZoneLower;
//
isDecisionPriceZoneValidForVale =
hasBoundary &&
pzVale <= decisionPriceZoneUpper &&
pzVale >= decisionPriceZoneLower;
}
//
// Detecting Analyse Price ones ...
XPriceZones analysePriceZone;
bool hasAnalysePriceZone = CalculatePriceInsideZones(
analysePriceZone,
analyseState,
cBar //
);
double analysePriceZoneUpper = 0;
double analysePriceZoneLower = 0;
bool isAnalysePriceZoneValidForPeak = false;
bool isAnalysePriceZoneValidForVale = false;
if (hasAnalysePriceZone)
{
//
bool hasBoundary = analysePriceZone.GetBoundary(
X_DIRECTION_ALL,
analysePriceZoneUpper,
analysePriceZoneLower //
);
//
isAnalysePriceZoneValidForPeak =
hasBoundary &&
pzPeak <= analysePriceZoneUpper &&
pzPeak >= analysePriceZoneLower;
//
isAnalysePriceZoneValidForVale =
hasBoundary &&
pzVale <= analysePriceZoneUpper &&
pzVale >= analysePriceZoneLower;
}
//
// Detecting Verification Price ones ...
XPriceZones verificationPriceZone;
bool hasVerificationPriceZone = CalculatePriceInsideZones(
verificationPriceZone,
verificationState,
cBar //
);
double verificationPriceZoneUpper = 0;
double verificationPriceZoneLower = 0;
bool isVerificationPriceZoneValidForPeak = false;
bool isVerificationPriceZoneValidForVale = false;
if (hasVerificationPriceZone)
{
//
bool hasBoundary = verificationPriceZone.GetBoundary(
X_DIRECTION_ALL,
verificationPriceZoneUpper,
verificationPriceZoneLower //
);
//
isVerificationPriceZoneValidForPeak =
hasBoundary &&
pzPeak <= verificationPriceZoneUpper &&
pzPeak >= verificationPriceZoneLower;
//
isVerificationPriceZoneValidForVale =
hasBoundary &&
pzVale <= verificationPriceZoneUpper &&
pzVale >= verificationPriceZoneLower;
}
//////////////////////////////////////////////////////////////////////////////////
////// Detect Pivot Zones :
/////////////////////////////////////////////////////////////////////////////////
//
double X121SMCXPivotPeak;
double X121SMCXPivotVale;
datetime X121SMCXPivotEnd;
datetime X121SMCXPivotStart;
ENUM_XPV_PIVOTS X121SMCXPivotType = XPV_NONE;
//
// 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(X121SMCXPivotStart);
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 &&
isSameCycleVales;
bool isPeakStart =
isSamePeaks &&
isSameCyclePeaks;
//
bool isStart = isPeakStart ||
isValeStart;
if (isStart)
{
//
X121SMCXPivotStart = cTime;
X121SMCXPivotType =
isPeakStart
? XPV_PEAK
: XPV_VALE;
//
X121SMCXPivotPeak = decisionXConditions.peaksBuffer[1];
X121SMCXPivotVale = decisionXConditions.valesBuffer[1];
}
//
hasPivot = IsValid(X121SMCXPivotStart);
//
// Create XPVPivot instance ...
if (hasPivot)
{
//
conditions.pivotZone.symbol = symbol;
conditions.pivotZone.period = period;
//
conditions.pivotZone.to = cTime;
conditions.pivotZone.repetition = 3;
//
conditions.pivotZone.upper = X121SMCXPivotPeak;
conditions.pivotZone.lower = X121SMCXPivotVale;
//
conditions.pivotZone.type = X121SMCXPivotType;
conditions.pivotZone.from = X121SMCXPivotStart;
}
}
}
//
if (hasPivot)
{
//
bool isBreaked = X121SMCXPivotType == XPV_PEAK
? decisionXConditions.isBreakedUpPrevPeak
: decisionXConditions.isBreakedDownPrevVale;
//
if (!isBreaked)
{
//
X121SMCXPivotPeak = decisionXConditions.peaksBuffer[1];
X121SMCXPivotVale = decisionXConditions.valesBuffer[1];
//
conditions.pivotZone.to = cTime;
conditions.pivotZone.repetition++;
conditions.pivotZone.upper = X121SMCXPivotPeak;
conditions.pivotZone.lower = X121SMCXPivotVale;
}
else
{
//
X121SMCXPivotEnd = 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(X121SMCXPivotEnd);
if (isPivotEnded)
{
//
X121SMCXPivotPeak = 0;
X121SMCXPivotVale = 0;
X121SMCXPivotEnd = NULL;
X121SMCXPivotStart = NULL;
X121SMCXPivotType = XPV_NONE;
//
conditions.pivotZone.Clean();
}
//////////////////////////////////////////////////////////////////////////////////
////// Detect Pivot Zones :
/////////////////////////////////////////////////////////////////////////////////
//
bool isCondition1Bullish =
//
hasPivot &&
//
isCBarBullishFormed &&
isCBarBullishPullbacked &&
//
hasAnalyseBullishTrend &&
hasDecisionBullishTrend &&
hasVerificationBullishTrend &&
//
decisionXConditions.isSarBullish &&
analyseXConditions.isSarBullish &&
verificationXConditions.isSarBullish &&
//
false
//
;
//
bool isCondition1Bearish =
//
hasPivot &&
//
isCBarBearishFormed &&
isCBarBearishPullbacked &&
//
hasAnalyseBearishTrend &&
hasDecisionBearishTrend &&
hasVerificationBearishTrend &&
//
decisionXConditions.isSarBearish &&
analyseXConditions.isSarBearish &&
verificationXConditions.isSarBearish &&
//
false
//
;
//
bool hasCondition1 = isCondition1Bullish ||
isCondition1Bearish;
if (hasCondition1)
{
//
ENUM_X_DIRECTION pzDir =
isCondition1Bullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
conditions.priceZone = analysePriceZone;
conditions.isPriceZoneValidForPeak = isAnalysePriceZoneValidForPeak;
conditions.isPriceZoneValidForVale = isAnalysePriceZoneValidForVale;
//
pzPeak = analysePriceZoneUpper;
pzVale = analysePriceZoneLower;
//
double point = GetEntry(
conditions.symbol,
pzDir //
);
//
// Manipulate Conditions Point ...
//
// point =
// isCondition1Bullish ? pzPeak
// : pzVale;
conditions.point = point;
//
// Manipulate Conditions Pivot ...
//
conditions.pivot =
isCondition1Bullish
? pzVale
: pzPeak;
}
+38
View File
@@ -335,3 +335,41 @@ int DrawX121SMCStrategyConditions(
//
return result;
}
////////////////////////////////////////////////
// //
// isCBarBearishFormed &&
// (isPivotToDownRejected ||
// isPivotToDownBreaked) &&
// conditions.pivotZone.IsVale() &&
// //
// // SAR ...
// isSarBearishFormed &&
// // //
// // // STR ...
// // !(decisionXConditions.isStrBullish) &&
// // //
// // // VWAP ...
// // !(decisionXConditions.isVWapBullishState ||
// // decisionXConditions.isVWapBullishOrdered) &&
// //
// //
// isCBarBullishFormed &&
// (isPivotToUpRejected ||
// isPivotToUpBreaked) &&
// conditions.pivotZone.IsPeak() &&
// //
// // SAR ...
// isSarBullishFormed &&
// // //
// // // STR ...
// // !(decisionXConditions.isStrBearish) &&
// // //
// // // VWAP ...
// // !(decisionXConditions.isVWapBearishState ||
// // decisionXConditions.isVWapBearishOrdered) &&
// //
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -65,7 +65,7 @@ input string eaCloseAllTradesAt = ""; // Enable Close All Trades on Signals on T
//
// Risk Management ...
input group "Risk Management";
input double eaR2R = 3; // Signallers Risk to Reward Ratio
input double eaR2R = 2; // Signallers Risk to Reward Ratio
input double eaVolume = 0.05; // Static Volume
input double eaRiskPercentPerBalance = 0; // Risk Percent Per Balance in Each Trade
input bool eaDynamicRiskManagement = false; // Dynamic Risk Management
@@ -80,9 +80,9 @@ input int eaPauseSignallingAfterReachesMaxAllowedSLInSecconds = 7200; // Pause S
// Protection ...
input group "Protection";
input bool eaAllowHedging = true; // Allow Hedge Positions
input int eaMinOpenTradesFroHedging = 5; // Minimum Open Positions for Hedging
input int eaMinOpenTradesFroHedging = 4; // Minimum Open Positions for Hedging
input double eaHedgingMinVolumeStep = 0.01; // Minimum Volume Step for Hedging
input double eaHedgeingMinRequiredProfitPerVolumeStep = 1.5; // Minimum Required Profit Per Volume Step for Hedging
input double eaHedgeingMinRequiredProfitPerVolumeStep = 2.0; // Minimum Required Profit Per Volume Step for Hedging
//
// Alert ...
-64
View File
@@ -199,10 +199,6 @@ struct X121Conditions
double donCloseUpperBuffer[];
double donCloseLowerBuffer[];
//
bool bullishTrendBuffer[];
bool bearishTrendBuffer[];
//
double rsiSlope;
double strSlope;
@@ -497,14 +493,6 @@ struct X121Conditions
bool isStrLowerCrossedOverDonLowLower;
bool isStrLowerCrossedUnderDonLowLower;
//
bool isTrendBullish;
bool isTrendBearish;
//
bool isTrendSwirchedToBullish;
bool isTrendSwirchedToBearish;
//
bool isAtrUpperOverPeak;
bool isAtrUpperEqualsToPeak;
@@ -592,10 +580,6 @@ struct X121Conditions
Clean(donCloseUpperBuffer);
Clean(donCloseLowerBuffer);
//
Clean(bullishTrendBuffer);
Clean(bearishTrendBuffer);
//
ArraySetAsSeries(rsiBuffer, true);
ArraySetAsSeries(atrBuffer, true);
@@ -647,10 +631,6 @@ struct X121Conditions
ArraySetAsSeries(donCloseUpperBuffer, true);
ArraySetAsSeries(donCloseLowerBuffer, true);
//
ArraySetAsSeries(bullishTrendBuffer, true);
ArraySetAsSeries(bearishTrendBuffer, true);
//
cheMin = 0;
cheMax = 0;
@@ -1014,14 +994,6 @@ struct X121Conditions
//
isStrLowerCrossedOverDonLowLower = false;
isStrLowerCrossedUnderDonLowLower = false;
//
isTrendBullish = false;
isTrendBearish = false;
//
isTrendSwirchedToBullish = false;
isTrendSwirchedToBearish = false;
}
/**
@@ -1231,10 +1203,6 @@ struct X121Conditions
"-----------------------" + separator +
"Coplex ..." + separator +
"-----------------------" + separator +
ToString("isTrendBullish", isTrendBullish, ignoreFalseConditions, separator) +
ToString("isTrendBearish", isTrendBearish, ignoreFalseConditions, separator) +
ToString("isTrendSwirchedToBullish", isTrendSwirchedToBullish, ignoreFalseConditions, separator) +
ToString("isTrendSwirchedToBearish", isTrendSwirchedToBearish, ignoreFalseConditions, separator) +
ToString("isSarIncreased", isSarIncreased, ignoreFalseConditions, separator) +
ToString("isSarDecreased", isSarDecreased, ignoreFalseConditions, separator) +
ToString("isSarEqualsToPeak", isSarEqualsToPeak, ignoreFalseConditions, separator) +
@@ -1944,18 +1912,6 @@ class XCX121Helper : public XCBase
conditions.hLLBuffer //
);
//
Copy(
xpvConditions.bullishTrendBuffer,
conditions.bullishTrendBuffer //
);
//
Copy(
xpvConditions.bearishTrendBuffer,
conditions.bearishTrendBuffer //
);
//
// Conditions ...
@@ -2368,20 +2324,6 @@ class XCX121Helper : public XCBase
//
// Complex Conditions ...
//
bool isTrendBullish = conditions.bullishTrendBuffer[0];
bool isTrendBullishPrev = conditions.bullishTrendBuffer[1];
//
bool isTrendBearish = conditions.bearishTrendBuffer[0];
bool isTrendBearishPrev = conditions.bearishTrendBuffer[1];
//
bool isTrendSwirchedToBullish = isTrendBullish &&
!isTrendBullishPrev;
bool isTrendSwirchedToBearish = isTrendBearish &&
!isTrendBearishPrev;
//
double vwapFast = conditions.vwapFastBuffer[cIDX];
double vwapMid = conditions.vwapMidBuffer[cIDX];
@@ -2801,12 +2743,6 @@ class XCX121Helper : public XCBase
conditions.vwapMin = vwapMin;
conditions.vwapMax = vwapMax;
//
conditions.isTrendBullish = isTrendBullish;
conditions.isTrendBearish = isTrendBearish;
conditions.isTrendSwirchedToBullish = isTrendSwirchedToBullish;
conditions.isTrendSwirchedToBearish = isTrendSwirchedToBearish;
//
conditions.isSarIncreased = isSarIncreased;
conditions.isSarDecreased = isSarDecreased;
+2 -388
View File
@@ -270,10 +270,6 @@ struct X121XPVConditions
double hHHBuffer[];
double hLLBuffer[];
//
bool bullishTrendBuffer[];
bool bearishTrendBuffer[];
//
// Conditions ...
@@ -345,8 +341,8 @@ struct X121XPVConditions
Clean(hLLBuffer);
//
Clean(bullishTrendBuffer);
Clean(bearishTrendBuffer);
// Clean(bullishTrendBuffer);
// Clean(bearishTrendBuffer);
//
ArraySetAsSeries(peaksBuffer, true);
@@ -363,10 +359,6 @@ struct X121XPVConditions
ArraySetAsSeries(hHHBuffer, true);
ArraySetAsSeries(hLLBuffer, true);
//
ArraySetAsSeries(bullishTrendBuffer, true);
ArraySetAsSeries(bearishTrendBuffer, true);
//
// Conditions ...
@@ -1612,107 +1604,6 @@ class XCX121XPVHelper : public XCBaseHelper
);
}
//
// Trends ...
// //
// bool GetBullishTrend(
// int barIndex // Bar Index
// )
// {
// //
// if (barIndex < 0)
// {
// barIndex = 0;
// }
// //
// Calculate();
// //
// int count = ArraySize(bullishTrendBuffer);
// if (barIndex >= count)
// {
// barIndex = count - 1;
// }
// //
// return bullishTrendBuffer[barIndex];
// }
// //
// int CopyBullishTrend(
// int start, // Start
// int count, // Number of Items for read
// bool &buffer[], // Dest Buffer
// bool forceClean = true // Force To Clean buffer
// )
// {
// //
// // Update Calculations ...
// Calculate();
// //
// // Copy Items ...
// return Copy(
// start,
// count,
// bullishTrendBuffer,
// buffer,
// forceClean
// //
// );
// }
// //
// bool GetBearishTrend(
// int barIndex // Bar Index
// )
// {
// //
// if (barIndex < 0)
// {
// barIndex = 0;
// }
// //
// Calculate();
// //
// int count = ArraySize(bearishTrendBuffer);
// if (barIndex >= count)
// {
// barIndex = count - 1;
// }
// //
// return bearishTrendBuffer[barIndex];
// }
// //
// int CopyBearishTrend(
// int start, // Start
// int count, // Number of Items for read
// bool &buffer[], // Dest Buffer
// bool forceClean = true // Force To Clean buffer
// )
// {
// //
// // Update Calculations ...
// Calculate();
// //
// // Copy Items ...
// return Copy(
// start,
// count,
// bearishTrendBuffer,
// buffer,
// forceClean
// //
// );
// }
//
// Tools Function ...
@@ -1936,191 +1827,6 @@ class XCX121XPVHelper : public XCBaseHelper
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 = GetPeak(hpIndex);
}
//
if (lastLV == 0)
{
//
lastLV = GetVale(lvIndex);
}
//
int highestPeakIndex = -1;
double highesrPeak =
GetHigherPeak(
highestPeakIndex,
lastHP,
hpIndex //
);
if (IsValidIndex(highestPeakIndex))
{
//
Add(
highestPeakIndex,
hpIndexes //
);
//
Add(
highesrPeak,
hpValues //
);
}
//
int lowestValeIndex = -1;
double lowestVale =
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;
}
//
bool GetConditions(
X121XPVConditions &conditions, //
@@ -2281,48 +1987,6 @@ class XCX121XPVHelper : public XCBaseHelper
conditions.hLLBuffer //
);
// //
// CopyBullishTrend(
// zIndex,
// loopback,
// conditions.bullishTrendBuffer //
// );
// //
// CopyBearishTrend(
// zIndex,
// loopback,
// conditions.bearishTrendBuffer //
// );
//
for (int i = barIndex + 1; i < barIndex + 3; i++)
{
//
ENUM_X_DIRECTION iDirection;
bool iHasDirection = DetectMarketStructure(iDirection);
//
bool iHasBullishTrend = iHasDirection &&
IsBullish(iDirection);
//
bool iHasBearishTrend = iHasDirection &&
IsBearish(iDirection);
//
Add(
iHasBullishTrend,
conditions.bullishTrendBuffer //
);
//
Add(
iHasBearishTrend,
conditions.bearishTrendBuffer //
);
}
//
// Conditions ...
@@ -2400,11 +2064,6 @@ class XCX121XPVHelper : public XCBaseHelper
conditions.isRejectedPrevVale = isRejectedPrevVale;
conditions.isBreakedDownPrevVale = isBreakedDownPrevVale;
// //
// if (isNewVale || isNewPeak) {
// CalculateTrend();
// }
//
return result;
}
@@ -2435,29 +2094,6 @@ class XCX121XPVHelper : public XCBaseHelper
double hHHBuffer[];
double hLLBuffer[];
//
// bool bullishTrendBuffer[];
// bool bearishTrendBuffer[];
//
// void AddTrend(
// bool isBullish,
// bool isBearish //
// )
// {
// //
// Add(
// isBullish,
// bullishTrendBuffer //
// );
// //
// Add(
// isBearish,
// bearishTrendBuffer //
// );
// }
//
void Calculate()
{
@@ -2632,28 +2268,6 @@ class XCX121XPVHelper : public XCBaseHelper
//
);
}
//
// void CalculateTrend()
// {
// //
// ENUM_X_DIRECTION iDirection;
// bool iHasDirection = DetectMarketStructure(iDirection);
// //
// bool iHasBullishTrend = iHasDirection &&
// IsBullish(iDirection);
// //
// bool iHasBearishTrend = iHasDirection &&
// IsBearish(iDirection);
// //
// AddTrend(
// iHasBullishTrend,
// iHasBearishTrend //
// );
// }
};
//
@@ -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 ...