This commit is contained in:
2025-01-15 11:53:34 +03:30
parent 56cd60e31d
commit 341992374c
6 changed files with 737 additions and 145 deletions
+500 -83
View File
@@ -52,6 +52,11 @@ struct X121SMCStrategyXSTRPVSignalConditions
double pivot;
double point;
//
XPriceZones priceZone;
bool isPriceZoneValidForPeak;
bool isPriceZoneValidForVale;
//
// Constructor ...
X121SMCStrategyXSTRPVSignalConditions()
@@ -169,6 +174,11 @@ struct X121SMCStrategyXSTRPVSignalConditions
//
pivot = 0;
point = 0;
//
priceZone.Clean();
isPriceZoneValidForPeak = false;
isPriceZoneValidForVale = false;
}
//
@@ -402,18 +412,68 @@ bool DetectX121SMCXSTRPVSiganlSetup(
// Detect Trend ...
//
ENUM_X_DIRECTION marketDir;
bool hasMarketDir = decisionCycleHelper.DetectMarketStructure(marketDir);
// Consolidation ...
ENUM_X_DIRECTION consolidationMarketDir;
bool hasConsolidationMarketDir = consolidationCycleHelper
.DetectMarketStructure(consolidationMarketDir);
//
bool hasBullishTrend =
hasMarketDir &&
IsBullish(marketDir);
bool hasConsolidationBullishTrend =
hasConsolidationMarketDir &&
IsBullish(consolidationMarketDir);
//
bool hasBearishTrend =
hasMarketDir &&
IsBearish(marketDir);
bool hasConsolidationBearishTrend =
hasConsolidationMarketDir &&
IsBearish(consolidationMarketDir);
//
// Verification ...
ENUM_X_DIRECTION verificationMarketDir;
bool hasVerificationMarketDir = verificationCycleHelper
.DetectMarketStructure(verificationMarketDir);
//
bool hasVerificationBullishTrend =
hasVerificationMarketDir &&
IsBullish(verificationMarketDir);
//
bool hasVerificationBearishTrend =
hasVerificationMarketDir &&
IsBearish(verificationMarketDir);
//
// Analyse ...
ENUM_X_DIRECTION analyseMarketDir;
bool hasAnalyseMarketDir = analyseCycleHelper
.DetectMarketStructure(analyseMarketDir);
//
bool hasAnalyseBullishTrend =
hasAnalyseMarketDir &&
IsBullish(analyseMarketDir);
//
bool hasAnalyseBearishTrend =
hasAnalyseMarketDir &&
IsBearish(analyseMarketDir);
//
// Decision ...
ENUM_X_DIRECTION decisionMarketDir;
bool hasDecisionMarketDir = decisionCycleHelper
.DetectMarketStructure(decisionMarketDir);
//
bool hasDecisionBullishTrend =
hasDecisionMarketDir &&
IsBullish(decisionMarketDir);
//
bool hasDecisionBearishTrend =
hasDecisionMarketDir &&
IsBearish(decisionMarketDir);
//
// Detect Bar State ...
@@ -515,40 +575,75 @@ bool DetectX121SMCXSTRPVSiganlSetup(
// Detect Price Zone ...
//
double pzPeak = decisionConditions.x121Conditions.peaksBuffer[1];
double pzVale = decisionConditions.x121Conditions.valesBuffer[1];
double pzPeak = decisionXConditions.peaksBuffer[1];
double pzVale = decisionXConditions.valesBuffer[1];
//
XPriceZones priceZones;
bool hasPriceZones = CalculatePriceInsideZones(
priceZones,
// Detecting Analyse Price ones ...
XPriceZones analysePriceZone;
bool hasAnalysePriceZone = CalculatePriceInsideZones(
analysePriceZone,
analyseState,
cBar //
);
double priceZonesUpper = 0;
double priceZonesLower = 0;
bool isPriceZoneValidForPeak = false;
bool isPriceZoneValidForVale = false;
if (hasPriceZones)
double analysePriceZoneUpper = 0;
double analysePriceZoneLower = 0;
bool isAnalysePriceZoneValidForPeak = false;
bool isAnalysePriceZoneValidForVale = false;
if (hasAnalysePriceZone)
{
//
bool hasBoundary = priceZones.GetBoundary(
bool hasBoundary = analysePriceZone.GetBoundary(
X_DIRECTION_ALL,
priceZonesUpper,
priceZonesLower //
analysePriceZoneUpper,
analysePriceZoneLower //
);
//
isPriceZoneValidForPeak =
isAnalysePriceZoneValidForPeak =
hasBoundary &&
pzPeak <= priceZonesUpper &&
pzPeak >= priceZonesLower;
pzPeak <= analysePriceZoneUpper &&
pzPeak >= analysePriceZoneLower;
//
isPriceZoneValidForVale =
isAnalysePriceZoneValidForVale =
hasBoundary &&
pzVale <= priceZonesUpper &&
pzVale >= priceZonesLower;
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;
}
//
@@ -559,75 +654,363 @@ bool DetectX121SMCXSTRPVSiganlSetup(
// Summarize Conditions ...
//
isBullish =
// Decision Conditions ...
//
bool isDecisionBullish =
//
// Other Time Frames ...
//
// Consolidation ...
(consolidationXConditions.isCheBullish &&
consolidationXConditions.isStrBullish &&
consolidationXConditions.isSarBullish &&
consolidationXConditions.isClosedOverVWapMax) &&
//
// Analyse ...
(analyseXConditions.isCheBullish &&
analyseXConditions.isStrBullish &&
analyseXConditions.isSarBullish &&
analyseXConditions.isClosedOverVWapMax) &&
hasAnalysePriceZone &&
analysePriceZone.IsBullish() &&
isAnalysePriceZoneValidForVale &&
//
// Decision ...
hasBullishTrend &&
hasVerificationBullishTrend &&
hasAnalyseBullishTrend &&
hasDecisionBullishTrend &&
decisionXConditions.isBreakedDownPrevAtrUpper &&
(
//
((decisionXConditions.isStrSwitchedToBullish &&
((decisionXConditions.isSarBullish &&
decisionXConditions.isCheBullish &&
decisionXConditions.isSarBullish) ||
(decisionXConditions.isCheSwitchedToBullish &&
decisionXConditions.isBreakedUpPrevStr &&
decisionXConditions.isStrSwitchedToBullish) ||
(decisionXConditions.isStrBullish &&
decisionXConditions.isSarBullish &&
decisionXConditions.isStrBullish) ||
(decisionXConditions.isSarSwitchedToBullish &&
decisionXConditions.isBreakedUpPrevCheMax &&
decisionXConditions.isCheSwitchedToBullish) ||
(decisionXConditions.isStrBullish &&
decisionXConditions.isCheBullish &&
decisionXConditions.isStrBullish))
decisionXConditions.isBreakedUpPrevSar &&
decisionXConditions.isSarSwitchedToBullish))
//
)
//
;
//
isBearish =
bool isDecisionBearish =
//
// Other Time Frames ...
//
// Consolidation ...
(consolidationXConditions.isCheBearish &&
consolidationXConditions.isStrBearish &&
consolidationXConditions.isSarBearish &&
consolidationXConditions.isClosedUnderVWapMax) &&
//
// Analyse ...
(analyseXConditions.isCheBearish &&
analyseXConditions.isStrBearish &&
analyseXConditions.isSarBearish &&
analyseXConditions.isClosedUnderVWapMax) &&
hasAnalysePriceZone &&
analysePriceZone.IsBearish() &&
isAnalysePriceZoneValidForPeak &&
//
// Decision ...
hasBearishTrend &&
hasVerificationBearishTrend &&
hasAnalyseBearishTrend &&
hasDecisionBearishTrend &&
decisionXConditions.isBreakedDownPrevAtrLower &&
(
//
((decisionXConditions.isStrSwitchedToBearish &&
((decisionXConditions.isSarBearish &&
decisionXConditions.isCheBearish &&
decisionXConditions.isSarBearish) ||
(decisionXConditions.isCheSwitchedToBearish &&
decisionXConditions.isBreakedDownPrevStr &&
decisionXConditions.isStrSwitchedToBearish) ||
(decisionXConditions.isStrBearish &&
decisionXConditions.isSarBearish &&
decisionXConditions.isStrBearish) ||
(decisionXConditions.isSarSwitchedToBearish &&
decisionXConditions.isCheSwitchedToBearish &&
decisionXConditions.isBreakedDownPrevCheMin) ||
(decisionXConditions.isStrBearish &&
decisionXConditions.isCheBearish &&
decisionXConditions.isStrBearish))
decisionXConditions.isBreakedDownPrevSar &&
decisionXConditions.isSarSwitchedToBearish))
//
)
//
;
//
bool hasDecisionCondition = isDecisionBullish ||
isDecisionBearish;
if (hasDecisionCondition)
{
//
conditions.priceZone = analysePriceZone;
conditions.isPriceZoneValidForPeak = isAnalysePriceZoneValidForPeak;
conditions.isPriceZoneValidForVale = isAnalysePriceZoneValidForVale;
//
pzPeak = analysePriceZoneUpper;
pzVale = analysePriceZoneLower;
//
double point = GetEntry(
conditions.symbol,
conditions.dir //
);
//
// Manipulate Conditions Point ...
//
point =
isDecisionBullish ? pzPeak
: pzVale;
conditions.point = point;
//
// Manipulate Conditions Pivot ...
//
conditions.pivot =
isDecisionBullish
? pzVale
: pzPeak;
}
//
// Analyse Conditions ...
//
bool isAnalyseBullish =
//
!hasDecisionCondition &&
//
hasVerificationPriceZone &&
verificationPriceZone.IsBullish() &&
isVerificationPriceZoneValidForVale &&
//
hasConsolidationBullishTrend &&
hasVerificationBullishTrend &&
hasAnalyseBullishTrend &&
analyseXConditions.isBreakedDownPrevAtrUpper &&
//
(
//
((analyseXConditions.isSarBullish &&
analyseXConditions.isCheBullish &&
analyseXConditions.isBreakedUpPrevStr &&
analyseXConditions.isStrSwitchedToBullish) ||
(analyseXConditions.isStrBullish &&
analyseXConditions.isSarBullish &&
analyseXConditions.isBreakedUpPrevCheMax &&
analyseXConditions.isCheSwitchedToBullish) ||
(analyseXConditions.isStrBullish &&
analyseXConditions.isCheBullish &&
analyseXConditions.isBreakedUpPrevSar &&
analyseXConditions.isSarSwitchedToBullish))
//
)
//
;
//
bool isAnalyseBearish =
//
!hasDecisionCondition &&
//
hasVerificationPriceZone &&
verificationPriceZone.IsBearish() &&
isVerificationPriceZoneValidForPeak &&
//
hasConsolidationBearishTrend &&
hasVerificationBearishTrend &&
hasAnalyseBearishTrend &&
analyseXConditions.isBreakedDownPrevAtrLower &&
//
(
//
((analyseXConditions.isSarBearish &&
analyseXConditions.isCheBearish &&
analyseXConditions.isBreakedDownPrevStr &&
analyseXConditions.isStrSwitchedToBearish) ||
(analyseXConditions.isStrBearish &&
analyseXConditions.isSarBearish &&
analyseXConditions.isCheSwitchedToBearish &&
analyseXConditions.isBreakedDownPrevCheMin) ||
(analyseXConditions.isStrBearish &&
analyseXConditions.isCheBearish &&
analyseXConditions.isBreakedDownPrevSar &&
analyseXConditions.isSarSwitchedToBearish))
//
)
//
;
//
bool hasAnalyseCondition = isAnalyseBullish ||
isAnalyseBearish;
if (hasAnalyseCondition)
{
//
conditions.priceZone = analysePriceZone;
conditions.isPriceZoneValidForPeak = isVerificationPriceZoneValidForPeak;
conditions.isPriceZoneValidForVale = isVerificationPriceZoneValidForVale;
//
pzPeak = analysePriceZoneUpper;
pzVale = analysePriceZoneLower;
//
double point = GetEntry(
conditions.symbol,
conditions.dir //
);
//
// Manipulate Conditions Point ...
//
point =
isAnalyseBullish ? pzPeak
: pzVale;
conditions.point = point;
//
// Manipulate Conditions Pivot ...
//
conditions.pivot =
isAnalyseBullish
? pzVale
: pzPeak;
}
//
//
//
//
double decisionPVMiddle = decisionXConditions.valesBuffer[1] +
(decisionXConditions.peaksBuffer[1] - decisionXConditions.valesBuffer[1]) / 2;
bool isInDecisionPremium =
//
ask > decisionPVMiddle &&
bid > decisionPVMiddle &&
//
ask < decisionXConditions.peaksBuffer[1] &&
bid < decisionXConditions.peaksBuffer[1]
//
;
bool isInDecisionDiscount =
//
ask < decisionPVMiddle &&
bid < decisionPVMiddle &&
//
ask < decisionXConditions.valesBuffer[1] &&
bid < decisionXConditions.valesBuffer[1]
//
;
//
bool isPriceZoneBullish =
//
!hasDecisionCondition &&
!hasAnalyseCondition &&
//
hasVerificationBullishTrend &&
hasAnalyseBullishTrend &&
hasDecisionBullishTrend &&
//
hasAnalysePriceZone &&
analysePriceZone.IsBullish() &&
isAnalysePriceZoneValidForVale &&
//
isCBarBullishFormed &&
isInDecisionDiscount &&
decisionXConditions.isAtrLowerUnderVale &&
decisionXConditions.isAtrLowerSlopeBullish &&
true
//
;
//
bool isPriceZoneBearish =
//
!hasDecisionCondition &&
!hasAnalyseCondition &&
//
hasVerificationBearishTrend &&
hasAnalyseBearishTrend &&
hasDecisionBearishTrend &&
//
hasAnalysePriceZone &&
analysePriceZone.IsBearish() &&
isAnalysePriceZoneValidForPeak &&
//
isInDecisionPremium &&
isCBarBearishFormed &&
decisionXConditions.isAtrUpperOverPeak &&
decisionXConditions.isAtrUpperSlopeBearish &&
true
//
;
//
bool hasPriceZoneCondition = isPriceZoneBullish ||
isPriceZoneBearish;
if (hasPriceZoneCondition)
{
//
ENUM_X_DIRECTION pzDir =
isPriceZoneBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
// XCBaseObject *drawnObjects[];
// int drawnObjectsCount = triggerCycleHelper
// .mPOIDetector
// .mDrawer
// .DrawPriceZone(
// analysePriceZone,
// drawnObjects,
// pzDir //
// );
// if (IsValidSize(drawnObjectsCount))
// {
// Print("DIR: " + EnumToString(pzDir));
// }
//
conditions.priceZone = analysePriceZone;
conditions.isPriceZoneValidForPeak = isAnalysePriceZoneValidForPeak;
conditions.isPriceZoneValidForVale = isAnalysePriceZoneValidForVale;
//
pzPeak = analysePriceZoneUpper;
pzVale = analysePriceZoneLower;
//
double point = GetEntry(
conditions.symbol,
conditions.dir //
);
//
// Manipulate Conditions Point ...
//
// point =
// isPriceZoneBullish ? pzPeak
// : pzVale;
conditions.point = point;
//
// Manipulate Conditions Pivot ...
//
conditions.pivot =
isPriceZoneBullish
? pzVale
: pzPeak;
}
//
//
//
//
isBullish =
isAnalyseBullish ||
isDecisionBullish ||
isPriceZoneBullish;
//
isBearish =
isAnalyseBearish ||
isDecisionBearish ||
isPriceZoneBearish;
//
result = isBullish ||
isBearish;
@@ -637,23 +1020,12 @@ bool DetectX121SMCXSTRPVSiganlSetup(
}
//
conditions.pivot =
isBullish
? pzVale
: pzPeak;
conditions.setupTime = cTime;
conditions.dir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
double point = GetEntry(
conditions.symbol,
conditions.dir //
);
conditions.point = point;
//
return result;
}
@@ -970,7 +1342,7 @@ bool DetectX121SMCXSTRPVSiganlTrigger(
//
double point = conditions.point;
bool isPointBreak = IsBarBreak(
bool isPointBreaked = IsBarBreak(
point,
setupDir,
cBar //
@@ -983,7 +1355,7 @@ bool DetectX121SMCXSTRPVSiganlTrigger(
isBullish =
//
isBullish &&
isPointBreak &&
isPointBreaked &&
isSlopesBullish &&
cBar.IsBullish()
//
@@ -993,7 +1365,7 @@ bool DetectX121SMCXSTRPVSiganlTrigger(
isBearish =
//
isBearish &&
isPointBreak &&
isPointBreaked &&
isSlopesBearish &&
cBar.IsBearish()
//
@@ -1392,3 +1764,48 @@ int AddX121SMCXSTRPVConditionsIfNotExists(
}
//
int DrawX121SMCXSTRPVConditions(
X121SMCStrategyXSTRPVSignalConditions &conditions,
XCBaseObject *&drawnObjects[],
XCPOIDrawer *drawer //
)
{
//
int result = 0;
//
Clean(drawnObjects);
//
if (drawer == NULL)
{
return result;
}
//
bool isSetuped = conditions.IsSetuped();
if (!isSetuped)
{
return result;
}
//
bool hasPriceZone = conditions.priceZone.IsValid();
if (!hasPriceZone)
{
return result;
}
//
int zonesObjCount = drawer.DrawPriceZone(
conditions.priceZone,
drawnObjects,
conditions.dir //
);
result = zonesObjCount;
//
return result;
}
//