This commit is contained in:
2025-01-18 12:16:28 +03:30
parent 9cdd5b4c7d
commit e74f64c51e
10 changed files with 2111 additions and 1003 deletions
@@ -426,656 +426,6 @@ class XC121SMCCycleHelper : public XCBase
return result;
}
/**
* Detect Market Structure ...
*
* @param model: XMarketStructure instance Reference ...
*
* @return ( bool )
*/
bool DetectMarketStructure(
XMarketStructure &model //
)
{
//
bool result = false;
//
model.Clean();
//
int barIndex = 0;
//
string symbol = GetSymbol();
ENUM_TIMEFRAMES period = GetPeriod();
//
model.symbol = symbol;
model.period = period;
//
int highestPeakIndex = -1;
double highestPeakVale = 0;
double highestPeak =
mX121Helper
.xpvHelper
.GetHighestPeak(
barIndex,
highestPeakIndex,
highestPeakVale //
);
//
int lowestValeIndex = -1;
double lowestValePeak = 0;
double lowestVale =
mX121Helper
.xpvHelper
.GetLowestVale(
barIndex,
lowestValeIndex,
lowestValePeak //
);
//
result = IsValidIndex(highestPeakIndex) &&
IsValidIndex(lowestValeIndex);
if (!result)
{
return result;
}
//
model.bias =
highestPeakIndex < lowestValeIndex
? X_DIRECTION_BEARISH
: highestPeakIndex > lowestValeIndex
? X_DIRECTION_BULLISH
: X_DIRECTION_NONE;
//
result = HasDirection(model.bias);
if (!result)
{
return result;
}
//
bool isBullish = IsBullish(model.bias);
//
// Looking for Change Of Character Proved ...
//
// Bullish Bias:
// - Price Must Break Up Lowst Vale's Peak;
// - Create a Vale Above Lowest Vale's Peak;
//
// Bearish Bias:
// - Price Must Breake Down HighestPeak's Vale;
// - Create a Peak Under Highest Peak's Vale;
//
// Checking Peak Breake Up ...
int lowestValePeakBreakeUpIndex = -1;
for (int i = lowestValeIndex; i >= barIndex; i--)
{
//
XOHCL iBar;
result = GetBar(iBar, i);
if (!result)
{
continue;
}
//
bool isBreake = IsBarBreak(
lowestValePeak,
X_DIRECTION_BULLISH,
iBar //
);
if (isBreake)
{
//
lowestValePeakBreakeUpIndex = i;
break;
}
}
bool isValidBreakeUpLowestValePeak = IsValidIndex(lowestValePeakBreakeUpIndex) &&
lowestValePeakBreakeUpIndex <= lowestValeIndex;
//
// Checking Vale Breake Down ...
int highestPeakValeBreakeDownIndex = -1;
for (int i = highestPeakIndex; i >= barIndex; i--)
{
//
XOHCL iBar;
result = GetBar(iBar, i);
if (!result)
{
continue;
}
//
bool isBreake = IsBarBreak(
highestPeakVale,
X_DIRECTION_BEARISH,
iBar //
);
if (isBreake)
{
//
highestPeakValeBreakeDownIndex = i;
break;
}
}
bool isValidBreakeDownHighestPeakVale = IsValidIndex(highestPeakValeBreakeDownIndex) &&
highestPeakValeBreakeDownIndex <= highestPeakIndex;
//
result = isBullish
? isValidBreakeUpLowestValePeak
: isValidBreakeDownHighestPeakVale;
if (!result)
{
return result;
}
//
// Checking Create a Vale above Peak ...
int valeAboveLowestValePeakIndex = -1;
double valeAboveLowestValePeakPeak = 0;
for (int i = lowestValePeakBreakeUpIndex; i >= barIndex; i--)
{
//
double iVale = mX121Helper.xpvHelper.GetVale(i);
//
bool isValid =
iVale > 0 &&
iVale > lowestValePeak;
if (isValid)
{
//
valeAboveLowestValePeakIndex = i;
valeAboveLowestValePeakPeak = mX121Helper.xpvHelper.GetPeak(i);
break;
}
}
bool isValidValeAboveLowestValePeak = IsValidIndex(valeAboveLowestValePeakIndex) &&
valeAboveLowestValePeakIndex < lowestValePeakBreakeUpIndex;
//
// Checking Create a Peak below Vale ...
int peakBelowHighestPeakValeIndex = -1;
double peakBelowHighestPeakValeVale = 0;
for (int i = highestPeakValeBreakeDownIndex; i >= barIndex; i--)
{
//
double iPeak = mX121Helper.xpvHelper.GetPeak(i);
//
bool isValid =
iPeak > 0 &&
iPeak < highestPeakVale;
if (isValid)
{
//
peakBelowHighestPeakValeIndex = i;
peakBelowHighestPeakValeVale = mX121Helper.xpvHelper.GetVale(i);
break;
}
}
bool isValidPeakBelowHighestPeakVale = IsValidIndex(peakBelowHighestPeakValeIndex) &&
peakBelowHighestPeakValeIndex < highestPeakValeBreakeDownIndex;
//
result = isBullish ? isValidValeAboveLowestValePeak
: isValidPeakBelowHighestPeakVale;
if (!result)
{
return result;
}
//
// Now we Have to Detect Valid Peaks and Valid Vales Here ...
// based on Detected Range ...
//
XPVPivotPoint iPeakPoint;
XPVPivotPoint iValePoint;
XPriceZones peakPriceZone;
XPriceZones valePriceZone;
//
XPOIState state;
mPOIDetector.GetState(
state //
);
//
int minRepetition = 5;
//
int from =
isBullish
? valeAboveLowestValePeakIndex
: peakBelowHighestPeakValeIndex;
for (int i = from; i >= barIndex; i--)
{
//
XOHCL iBar;
bool isInited = GetBar(iBar, i);
//
double iPeak = mX121Helper.xpvHelper.GetPeak(i);
double iVale = mX121Helper.xpvHelper.GetVale(i);
//
bool hasPeakPriceInsideZone = CalculatePriceInsideZones(
peakPriceZone,
state,
iPeak //
);
bool hasValePriceInsideZone = CalculatePriceInsideZones(
valePriceZone,
state,
iVale //
);
//
if (hasPeakPriceInsideZone)
{
//
// Peak ...
if (!iPeakPoint.IsValid())
{
//
// Initialization ...
iPeakPoint.value = iPeak;
iPeakPoint.repetition = 1;
iPeakPoint.type = XPV_PEAK;
iPeakPoint.time = iBar.time;
}
else
{
//
if (iPeakPoint.value == iPeak)
{
iPeakPoint.repetition++;
}
else
{
//
if (iPeakPoint.repetition > minRepetition)
{
//
AddRef(
iPeakPoint,
model.peaks //
);
//
AddRef(
peakPriceZone,
model.peakPriceZones //
);
}
//
iPeakPoint.Clean();
peakPriceZone.Clean();
iPeakPoint.value = iPeak;
iPeakPoint.repetition = 1;
iPeakPoint.type = XPV_PEAK;
iPeakPoint.time = iBar.time;
}
}
}
//
if (hasValePriceInsideZone)
{
//
// Vale ...
if (!iValePoint.IsValid())
{
//
// Initialization ...
iValePoint.value = iVale;
iValePoint.repetition = 1;
iValePoint.type = XPV_VALE;
iValePoint.time = iBar.time;
}
else
{
//
if (iValePoint.value == iVale)
{
iValePoint.repetition++;
}
else
{
//
if (iValePoint.repetition > minRepetition)
{
//
AddRef(
iValePoint,
model.vales //
);
//
AddRef(
valePriceZone,
model.valePriceZones //
);
}
//
iValePoint.Clean();
valePriceZone.Clean();
iValePoint.value = iVale;
iValePoint.repetition = 1;
iValePoint.type = XPV_VALE;
iValePoint.time = iBar.time;
}
}
}
}
//
// in Bullish Bias we Looking for Vales Oder ...
// in Bearish Bias we Looking for Peaks Oder ...
//
// Bullish Bias Drawn ...
if (isBullish)
{
//
result = GetBar(
model.lowestValeBar,
lowestValeIndex //
);
if (!result)
{
return result;
}
//
if (isValidBreakeUpLowestValePeak)
{
//
result = GetBar(
model.lowestValePeakBreakeUpBar,
lowestValePeakBreakeUpIndex //
);
if (!result)
{
return result;
}
}
//
if (isValidValeAboveLowestValePeak)
{
//
result = GetBar(
model.valeAboveLowestValePeakBar,
valeAboveLowestValePeakIndex //
);
if (!result)
{
return result;
}
}
}
//
// Bearish Bias Drawn ...
if (!isBullish)
{
//
result = GetBar(
model.highestPeakBar,
highestPeakIndex //
);
if (!result)
{
return result;
}
//
if (isValidBreakeDownHighestPeakVale)
{
//
result = GetBar(
model.highestPeakValeBreakeDownBar,
highestPeakValeBreakeDownIndex //
);
if (!result)
{
return result;
}
}
//
if (isValidPeakBelowHighestPeakVale)
{
//
result = GetBar(
model.peakBelowHighestPeakValeBar,
peakBelowHighestPeakValeIndex //
);
if (!result)
{
return result;
}
}
}
//
result = model.IsValid();
//
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;
}
//
// Tools ...
@@ -1166,91 +516,5 @@ class XC121SMCCycleHelper : public XCBase
ChartSetInteger(chartId, CHART_COLOR_VOLUME, mVolumesColor);
}
/**
* Fill Pivot Tick Zone ...
*
* @param pivot: XPVPivot instance Reference ...
*/
void CalculatePivotTickZone(
XPVPivot &pivot //
)
{
//
string symbol = GetSymbol();
ENUM_TIMEFRAMES period = GetPeriod();
//
bool isInited = false;
//
datetime from = pivot.from;
XOHCL iFromBar;
int iFromBarIndex = iBarShift(
symbol,
period,
from //
);
isInited = iFromBar.Init(
symbol,
period,
iFromBarIndex //
);
if (!isInited)
{
return;
}
//
datetime to = pivot.to;
XOHCL iToBar;
int iToBarIndex = iBarShift(
symbol,
period,
to //
);
isInited = iToBar.Init(
symbol,
period,
iToBarIndex //
);
if (!isInited)
{
return;
}
//
if (iFromBarIndex <= iToBarIndex)
{
return;
}
//
XCTicksZone *iZone;
iZone = new XCTicksZone();
//
int ticksLevels = mPOIDetector.TicksRangeZoneLevel();
int ticksRange = mPOIDetector.TicksRangeZoneRange();
isInited = ticksLevels > 0 &&
ticksRange > 0;
if (!isInited)
{
return;
}
//
isInited = iZone.Init(
iFromBar,
iToBar //
);
if (!isInited)
{
return;
}
//
pivot.state.ticksZone = iZone;
}
//
};
+45 -6
View File
@@ -984,7 +984,7 @@ class XC121SMCExpert : public XCBaseExpert
//
signal.Clean();
conditions.Clean();
conditions.Clean();
}
//
@@ -2001,11 +2001,17 @@ class XC121SMCExpert : public XCBaseExpert
//
string comment = "Guard Close All ...";
string message = "Guard Close All (" + ToString(positionsCount) + ") Positions Successfully ...";
mTradeHandler.ForceClose(
int forceClosed = mTradeHandler.ForceClose(
positions,
comment,
message //
);
//
if (forceClosed)
{
RestEA(120 * 60);
}
}
}
@@ -2040,11 +2046,17 @@ class XC121SMCExpert : public XCBaseExpert
//
string comment = "Guard Close Longs ...";
string message = "Guard Close (" + ToString(longPositionsCount) + ") Long Positions Successfully ...";
mTradeHandler.ForceClose(
bool isClosed = mTradeHandler.ForceClose(
longPositions,
comment,
message //
);
//
if (isClosed)
{
RestEA(120 * 60);
}
}
}
@@ -2079,11 +2091,17 @@ class XC121SMCExpert : public XCBaseExpert
//
string comment = "Guard Close Shorts ...";
string message = "Guard Close (" + ToString(shortPositionsCount) + ") Short Positions Successfully ...";
mTradeHandler.ForceClose(
bool isClosed = mTradeHandler.ForceClose(
shortPositions,
comment,
message //
);
//
if (isClosed)
{
RestEA(120 * 60);
}
}
}
@@ -2114,11 +2132,17 @@ class XC121SMCExpert : public XCBaseExpert
//
string comment = "Guard Close ...";
string message = "Guard Close " + (isLong ? "Long" : "Short") + " Position: (" + ToString(iGuard.ticket) + ") Successfully ...";
mTradeHandler.ForceClose(
bool isClosed = mTradeHandler.ForceClose(
positions,
comment,
message //
);
//
if (isClosed)
{
RestEA(120 * 60);
}
}
}
@@ -2181,6 +2205,9 @@ class XC121SMCExpert : public XCBaseExpert
iPosition,
comment //
);
//
RestEA(120 * 60);
}
}
}
@@ -2238,11 +2265,17 @@ class XC121SMCExpert : public XCBaseExpert
//
string comment = "Guard Hedge ...";
string message = "Guard Hedge (" + ToString(count) + ") Positions by: (" + ToString(profits) + ") Successfully ...";
mTradeHandler.ForceClose(
bool isClosed = mTradeHandler.ForceClose(
positions,
comment,
message //
);
//
if (isClosed)
{
RestEA(120 * 60);
}
}
}
}
@@ -2335,6 +2368,12 @@ class XC121SMCExpert : public XCBaseExpert
ArrayFree(guards);
}
//
void RestEA(int seconds)
{
//
}
//
};
+122 -64
View File
@@ -309,35 +309,18 @@ bool DetectX121SMCGuards(
//
// Trigger ...
ENUM_X_DIRECTION triggerMarketDir;
bool hasTriggerMarketDir = triggerCycleHelper
.DetectMarketStructure(triggerMarketDir);
//
bool hasTriggerBullishTrend =
hasTriggerMarketDir &&
IsBullish(triggerMarketDir);
//
bool hasTriggerBearishTrend =
hasTriggerMarketDir &&
IsBearish(triggerMarketDir);
bool hasTriggerBullishTrend = triggerXConditions.bullishTrendBuffer[1];
bool hasTriggerBearishTrend = triggerXConditions.bearishTrendBuffer[1];
//
// Decision ...
ENUM_X_DIRECTION decisionMarketDir;
bool hasDecisionMarketDir = decisionCycleHelper
.DetectMarketStructure(decisionMarketDir);
bool hasDecisionBullishTrend = decisionXConditions.bullishTrendBuffer[1];
bool hasDecisionBearishTrend = decisionXConditions.bearishTrendBuffer[1];
//
bool hasDecisionBullishTrend =
hasDecisionMarketDir &&
IsBullish(decisionMarketDir);
//
bool hasDecisionBearishTrend =
hasDecisionMarketDir &&
IsBearish(decisionMarketDir);
// Analyse ...
bool hasAnalyseBullishTrend = analyseXConditions.bullishTrendBuffer[1];
bool hasAnalyseBearishTrend = analyseXConditions.bearishTrendBuffer[1];
//
// Consolidation Zone ...
@@ -884,6 +867,9 @@ bool DetectX121SMCGuards(
iGuard.provider = provider;
iGuard.action = X_121_SMC_GUARD_ACTION_CLOSE;
//
iGuard.ticket = iPosition.ticket;
//
AddGuard(
iGuard,
@@ -892,6 +878,92 @@ bool DetectX121SMCGuards(
}
}
//
if (hasLongs)
{
//
bool hasGuard = hasDecisionBearishTrend;
//
if (hasGuard)
{
//
for (int i = 0; i < longsCount; i++)
{
//
XPosition iPosition = ownLongPositions[i];
//
// Position must be in Draw Down ...
if (iPosition.profit > 0)
{
continue;
}
//
X121SMCGuard iGuard;
//
iGuard.time = cTime;
iGuard.symbol = symbol;
iGuard.provider = provider;
iGuard.action = X_121_SMC_GUARD_ACTION_CLOSE;
//
iGuard.ticket = iPosition.ticket;
//
AddGuard(
iGuard,
guards //
);
}
}
}
//
if (hasShorts)
{
//
bool hasGuard = hasDecisionBullishTrend;
//
if (hasGuard)
{
//
for (int i = 0; i < shortsCount; i++)
{
//
XPosition iPosition = ownShortPositions[i];
//
// Position must be in Draw Down ...
if (iPosition.profit > 0)
{
continue;
}
//
X121SMCGuard iGuard;
//
iGuard.time = cTime;
iGuard.symbol = symbol;
iGuard.provider = provider;
iGuard.action = X_121_SMC_GUARD_ACTION_CLOSE;
//
iGuard.ticket = iPosition.ticket;
//
AddGuard(
iGuard,
guards //
);
}
}
}
//
// Close All ...
@@ -931,6 +1003,7 @@ bool DetectX121SMCGuards(
//
bool hasGuard =
//
hasAnalyseBearishTrend &&
hasDecisionBearishTrend
//
;
@@ -962,6 +1035,7 @@ bool DetectX121SMCGuards(
//
bool hasGuard =
//
hasAnalyseBullishTrend &&
hasDecisionBullishTrend
//
;
@@ -998,20 +1072,6 @@ bool DetectX121SMCGuards(
hasTriggerBearishTrend ||
!hasDecisionBullishTrend
//
// (hasAnalysePriceZone &&
// isAnalysePriceZoneBearish &&
// isAnalysePriceZoneValidForPeak &&
// (isAnalysePriceZoneUpperRejected ||
// isAnalysePriceZoneLowerBreakedDown))
// //
// ||
// //
// (hasVerificationPriceZone &&
// isVerificationPriceZoneBearish &&
// isVerificationPriceZoneValidForPeak &&
// (isVerificationPriceZoneUpperRejected ||
// isVerificationPriceZoneLowerBreakedDown))
//
;
//
@@ -1054,20 +1114,6 @@ bool DetectX121SMCGuards(
hasTriggerBullishTrend ||
!hasDecisionBearishTrend
//
// (hasAnalysePriceZone &&
// isAnalysePriceZoneBullish &&
// isAnalysePriceZoneValidForVale &&
// (isAnalysePriceZoneLowerRejected ||
// isAnalysePriceZoneUpperBreakedUp))
// //
// ||
// //
// (hasVerificationPriceZone &&
// isVerificationPriceZoneBullish &&
// isVerificationPriceZoneValidForVale &&
// (isVerificationPriceZoneLowerRejected ||
// isVerificationPriceZoneUpperBreakedUp))
//
;
//
@@ -1107,6 +1153,9 @@ bool DetectX121SMCGuards(
//
if (hasLongs)
{
//
bool hasTrendGuard = hasDecisionBearishTrend;
//
bool hasConsolidationGuard =
(hasConsolidationZone &&
@@ -1137,6 +1186,7 @@ bool DetectX121SMCGuards(
//
bool hasGuard =
//
hasTrendGuard ||
hasConsolidationGuard ||
hasDecisionPriceZoneGuard ||
hasAnalysePriceZoneGuard ||
@@ -1172,6 +1222,12 @@ bool DetectX121SMCGuards(
continue;
}
//
if (hasTrendGuard)
{
guardStop = decisionXConditions.strBuffer[1] - decisionXConditions.atrBuffer[1];
}
//
// Price Must Greater than Zone Lower ...
if (iPosition.price < guardStop)
@@ -1203,11 +1259,9 @@ bool DetectX121SMCGuards(
iGuard.provider = provider;
iGuard.action = X_121_SMC_GUARD_ACTION_TRAIL_STOP;
//
iGuard.ticket = iPosition.ticket;
//
iGuard.sl = guardStop;
iGuard.ticket = iPosition.ticket;
//
AddGuard(
@@ -1221,6 +1275,9 @@ bool DetectX121SMCGuards(
//
if (hasShorts)
{
//
bool hasTrendGuard = hasDecisionBullishTrend;
//
bool hasConsolidationGuard =
(hasConsolidationZone &&
@@ -1251,6 +1308,7 @@ bool DetectX121SMCGuards(
//
bool hasGuard =
//
hasTrendGuard ||
hasConsolidationGuard ||
hasDecisionPriceZoneGuard ||
hasAnalysePriceZoneGuard ||
@@ -1286,6 +1344,12 @@ bool DetectX121SMCGuards(
continue;
}
//
if (hasTrendGuard)
{
guardStop = decisionXConditions.strBuffer[1] + decisionXConditions.atrBuffer[1];
}
//
// Price Must Lesser than Zone Upper ...
if (iPosition.price > guardStop)
@@ -1317,11 +1381,9 @@ bool DetectX121SMCGuards(
iGuard.provider = provider;
iGuard.action = X_121_SMC_GUARD_ACTION_TRAIL_STOP;
//
iGuard.ticket = iPosition.ticket;
//
iGuard.sl = guardStop;
iGuard.ticket = iPosition.ticket;
//
AddGuard(
@@ -1397,11 +1459,9 @@ bool DetectX121SMCGuards(
iGuard.provider = provider;
iGuard.action = X_121_SMC_GUARD_ACTION_TRAIL_TARGET;
//
iGuard.ticket = iPosition.ticket;
//
iGuard.tp = guardTP;
iGuard.ticket = iPosition.ticket;
//
AddGuard(
@@ -1474,11 +1534,9 @@ bool DetectX121SMCGuards(
iGuard.provider = provider;
iGuard.action = X_121_SMC_GUARD_ACTION_TRAIL_TARGET;
//
iGuard.ticket = iPosition.ticket;
//
iGuard.tp = guardTP;
iGuard.ticket = iPosition.ticket;
//
AddGuard(
+12 -48
View File
@@ -414,67 +414,31 @@ bool DetectX121SMCXPZSiganlSetup(
//
// Consolidation ...
ENUM_X_DIRECTION consolidationMarketDir;
bool hasConsolidationMarketDir = consolidationCycleHelper
.DetectMarketStructure(consolidationMarketDir);
//
bool hasConsolidationBullishTrend =
hasConsolidationMarketDir &&
IsBullish(consolidationMarketDir);
if (decisionXConditions.isTrendSwirchedToBearish)
{
Print("Trend Switced To Bearish ...");
}
//
bool hasConsolidationBearishTrend =
hasConsolidationMarketDir &&
IsBearish(consolidationMarketDir);
bool hasConsolidationBullishTrend = consolidationXConditions.isTrendBullish;
bool hasConsolidationBearishTrend = consolidationXConditions.isTrendBearish;
//
// Verification ...
ENUM_X_DIRECTION verificationMarketDir;
bool hasVerificationMarketDir = verificationCycleHelper
.DetectMarketStructure(verificationMarketDir);
//
bool hasVerificationBullishTrend =
hasVerificationMarketDir &&
IsBullish(verificationMarketDir);
//
bool hasVerificationBearishTrend =
hasVerificationMarketDir &&
IsBearish(verificationMarketDir);
bool hasVerificationBullishTrend = verificationXConditions.isTrendBullish;
bool hasVerificationBearishTrend = verificationXConditions.isTrendBearish;
//
// Analyse ...
ENUM_X_DIRECTION analyseMarketDir;
bool hasAnalyseMarketDir = analyseCycleHelper
.DetectMarketStructure(analyseMarketDir);
//
bool hasAnalyseBullishTrend =
hasAnalyseMarketDir &&
IsBullish(analyseMarketDir);
//
bool hasAnalyseBearishTrend =
hasAnalyseMarketDir &&
IsBearish(analyseMarketDir);
bool hasAnalyseBullishTrend = analyseXConditions.isTrendBullish;
bool hasAnalyseBearishTrend = analyseXConditions.isTrendBearish;
//
// Decision ...
ENUM_X_DIRECTION decisionMarketDir;
bool hasDecisionMarketDir = decisionCycleHelper
.DetectMarketStructure(decisionMarketDir);
//
bool hasDecisionBullishTrend =
hasDecisionMarketDir &&
IsBullish(decisionMarketDir);
//
bool hasDecisionBearishTrend =
hasDecisionMarketDir &&
IsBearish(decisionMarketDir);
bool hasDecisionBullishTrend = decisionXConditions.isTrendBullish;
bool hasDecisionBearishTrend = decisionXConditions.isTrendBearish;
//
// Detect Bar State ...
+368 -60
View File
@@ -33,7 +33,8 @@ enum ENUM_X121_SMC_XRSPVI_CONDITIONS
X121_SMC_XRSPVI_CONDITION_1,
X121_SMC_XRSPVI_CONDITION_2,
X121_SMC_XRSPVI_CONDITION_3,
X121_SMC_XRSPVI_CONDITION_4
X121_SMC_XRSPVI_CONDITION_4,
X121_SMC_XRSPVI_CONDITION_5,
};
//
@@ -70,6 +71,7 @@ struct X121SMCStrategyXRSPVISignalConditions
bool isPriceZoneValidForVale;
//
XPVPivot pivotZone;
XConsolidationZone consolidationZone;
//
@@ -194,6 +196,7 @@ struct X121SMCStrategyXRSPVISignalConditions
point = 0;
//
pivotZone.Clean();
priceZone.Clean();
consolidationZone.Clean();
isPriceZoneValidForPeak = false;
@@ -214,6 +217,13 @@ X121SMCStrategyXRSPVISignalConditions mXRSPVIConditionsCollection[];
//
// Extension Functions ...
//
double X121SMCXRSPVIPivotPeak;
double X121SMCXRSPVIPivotVale;
datetime X121SMCXRSPVIPivotEnd;
datetime X121SMCXRSPVIPivotStart;
ENUM_XPV_PIVOTS X121SMCXRSPVIPivotType = XPV_NONE;
//
// Detect Setup Conditions ...
bool DetectX121SMCXRSPVISiganlSetup(
@@ -435,67 +445,25 @@ bool DetectX121SMCXRSPVISiganlSetup(
//
// Consolidation ...
ENUM_X_DIRECTION consolidationMarketDir;
bool hasConsolidationMarketDir = consolidationCycleHelper
.DetectMarketStructure(consolidationMarketDir);
//
bool hasConsolidationBullishTrend =
hasConsolidationMarketDir &&
IsBullish(consolidationMarketDir);
//
bool hasConsolidationBearishTrend =
hasConsolidationMarketDir &&
IsBearish(consolidationMarketDir);
bool hasConsolidationBullishTrend = consolidationXConditions.isTrendBullish;
bool hasConsolidationBearishTrend = consolidationXConditions.isTrendBearish;
//
// Verification ...
ENUM_X_DIRECTION verificationMarketDir;
bool hasVerificationMarketDir = verificationCycleHelper
.DetectMarketStructure(verificationMarketDir);
//
bool hasVerificationBullishTrend =
hasVerificationMarketDir &&
IsBullish(verificationMarketDir);
//
bool hasVerificationBearishTrend =
hasVerificationMarketDir &&
IsBearish(verificationMarketDir);
bool hasVerificationBullishTrend = verificationXConditions.isTrendBullish;
bool hasVerificationBearishTrend = verificationXConditions.isTrendBearish;
//
// Analyse ...
ENUM_X_DIRECTION analyseMarketDir;
bool hasAnalyseMarketDir = analyseCycleHelper
.DetectMarketStructure(analyseMarketDir);
//
bool hasAnalyseBullishTrend =
hasAnalyseMarketDir &&
IsBullish(analyseMarketDir);
//
bool hasAnalyseBearishTrend =
hasAnalyseMarketDir &&
IsBearish(analyseMarketDir);
bool hasAnalyseBullishTrend = analyseXConditions.isTrendBullish;
bool hasAnalyseBearishTrend = analyseXConditions.isTrendBearish;
//
// Decision ...
ENUM_X_DIRECTION decisionMarketDir;
bool hasDecisionMarketDir = decisionCycleHelper
.DetectMarketStructure(decisionMarketDir);
//
bool hasDecisionBullishTrend =
hasDecisionMarketDir &&
IsBullish(decisionMarketDir);
//
bool hasDecisionBearishTrend =
hasDecisionMarketDir &&
IsBearish(decisionMarketDir);
bool hasDecisionBullishTrend = decisionXConditions.isTrendBullish;
bool hasDecisionBearishTrend = decisionXConditions.isTrendBearish;
//
// Detect Bar State ...
@@ -614,6 +582,8 @@ bool DetectX121SMCXRSPVISiganlSetup(
bool isDecisionPriceZoneBearish = false;
bool isDecisionPriceZoneValidForPeak = false;
bool isDecisionPriceZoneValidForVale = false;
//
if (hasDecisionPriceZone)
{
//
@@ -660,6 +630,8 @@ bool DetectX121SMCXRSPVISiganlSetup(
bool isAnalysePriceZoneBearish = false;
bool isAnalysePriceZoneValidForPeak = false;
bool isAnalysePriceZoneValidForVale = false;
//
if (hasAnalysePriceZone)
{
//
@@ -706,6 +678,8 @@ bool DetectX121SMCXRSPVISiganlSetup(
bool isVerificationPriceZoneBearish = false;
bool isVerificationPriceZoneValidForPeak = false;
bool isVerificationPriceZoneValidForVale = false;
//
if (hasVerificationPriceZone)
{
//
@@ -890,6 +864,314 @@ bool DetectX121SMCXRSPVISiganlSetup(
//
;
//
// 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(X121SMCXRSPVIPivotStart);
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)
{
//
X121SMCXRSPVIPivotStart = cTime;
X121SMCXRSPVIPivotType =
isPeakStart
? XPV_PEAK
: XPV_VALE;
//
X121SMCXRSPVIPivotPeak = decisionXConditions.peaksBuffer[1];
X121SMCXRSPVIPivotVale = decisionXConditions.valesBuffer[1];
}
//
hasPivot = IsValid(X121SMCXRSPVIPivotStart);
//
// Create XPVPivot instance ...
if (hasPivot)
{
//
conditions.pivotZone.symbol = symbol;
conditions.pivotZone.period = period;
//
conditions.pivotZone.to = cTime;
conditions.pivotZone.repetition = 3;
//
conditions.pivotZone.upper = X121SMCXRSPVIPivotPeak;
conditions.pivotZone.lower = X121SMCXRSPVIPivotVale;
//
conditions.pivotZone.type = X121SMCXRSPVIPivotType;
conditions.pivotZone.from = X121SMCXRSPVIPivotStart;
}
}
}
//
if (hasPivot)
{
//
bool isBreaked = X121SMCXRSPVIPivotType == XPV_PEAK
? decisionXConditions.isBreakedUpPrevPeak
: decisionXConditions.isBreakedDownPrevVale;
//
if (!isBreaked)
{
//
X121SMCXRSPVIPivotPeak = decisionXConditions.peaksBuffer[1];
X121SMCXRSPVIPivotVale = decisionXConditions.valesBuffer[1];
//
conditions.pivotZone.to = cTime;
conditions.pivotZone.repetition++;
conditions.pivotZone.upper = X121SMCXRSPVIPivotPeak;
conditions.pivotZone.lower = X121SMCXRSPVIPivotVale;
}
else
{
//
X121SMCXRSPVIPivotEnd = 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(X121SMCXRSPVIPivotEnd);
if (isPivotEnded)
{
//
X121SMCXRSPVIPivotPeak = 0;
X121SMCXRSPVIPivotVale = 0;
X121SMCXRSPVIPivotEnd = NULL;
X121SMCXRSPVIPivotStart = NULL;
X121SMCXRSPVIPivotType = XPV_NONE;
//
conditions.pivotZone.Clean();
}
//
// Summarize Conditions ...
@@ -1109,7 +1391,7 @@ bool DetectX121SMCXRSPVISiganlSetup(
//
// Manipulate Conditions Pivot ...
//
double pivot = decisionXConditions.sarBuffer[1];
pivot = (decisionXConditions.sarBuffer[1] + decisionXConditions.strBuffer[1]) / 2;
@@ -1191,19 +1473,45 @@ bool DetectX121SMCXRSPVISiganlSetup(
: pzPeak;
}
//
//
//
//
bool isCond5Bullish =
//
hasDecisionBullishTrend &&
isPivotValeZoneRejected
//
;
//
bool isCond5Bearish =
//
hasDecisionBearishTrend &&
isPivotPeakZoneRejected
//
;
//
bool hasCond5Conditions = isCond5Bullish ||
isCond5Bearish;
//
isBullish =
isCond1Bullish ||
isCond2Bullish ||
isCond3Bullish ||
isCond4Bullish;
isCond5Bullish &&
(isCond1Bullish ||
isCond2Bullish ||
isCond3Bullish ||
isCond4Bullish);
//
isBearish =
isCond1Bearish ||
isCond2Bearish ||
isCond3Bearish ||
isCond4Bearish;
isCond5Bearish &&
(isCond1Bearish ||
isCond2Bearish ||
isCond3Bearish ||
isCond4Bearish);
//
result = isBullish ||
@@ -412,68 +412,26 @@ bool DetectX121SMCXSTRPVSiganlSetup(
//
// Consolidation ...
ENUM_X_DIRECTION consolidationMarketDir;
bool hasConsolidationMarketDir = consolidationCycleHelper
.DetectMarketStructure(consolidationMarketDir);
//
bool hasConsolidationBullishTrend =
hasConsolidationMarketDir &&
IsBullish(consolidationMarketDir);
//
bool hasConsolidationBearishTrend =
hasConsolidationMarketDir &&
IsBearish(consolidationMarketDir);
bool hasConsolidationBullishTrend = consolidationXConditions.isTrendBullish;
bool hasConsolidationBearishTrend = consolidationXConditions.isTrendBearish;
//
// Verification ...
ENUM_X_DIRECTION verificationMarketDir;
bool hasVerificationMarketDir = verificationCycleHelper
.DetectMarketStructure(verificationMarketDir);
//
bool hasVerificationBullishTrend =
hasVerificationMarketDir &&
IsBullish(verificationMarketDir);
//
bool hasVerificationBearishTrend =
hasVerificationMarketDir &&
IsBearish(verificationMarketDir);
bool hasVerificationBullishTrend = verificationXConditions.isTrendBullish;
bool hasVerificationBearishTrend = verificationXConditions.isTrendBearish;
//
// Analyse ...
ENUM_X_DIRECTION analyseMarketDir;
bool hasAnalyseMarketDir = analyseCycleHelper
.DetectMarketStructure(analyseMarketDir);
//
bool hasAnalyseBullishTrend =
hasAnalyseMarketDir &&
IsBullish(analyseMarketDir);
//
bool hasAnalyseBearishTrend =
hasAnalyseMarketDir &&
IsBearish(analyseMarketDir);
bool hasAnalyseBullishTrend = analyseXConditions.isTrendBullish;
bool hasAnalyseBearishTrend = analyseXConditions.isTrendBearish;
//
// Decision ...
ENUM_X_DIRECTION decisionMarketDir;
bool hasDecisionMarketDir = decisionCycleHelper
.DetectMarketStructure(decisionMarketDir);
//
bool hasDecisionBullishTrend =
hasDecisionMarketDir &&
IsBullish(decisionMarketDir);
//
bool hasDecisionBearishTrend =
hasDecisionMarketDir &&
IsBearish(decisionMarketDir);
bool hasDecisionBullishTrend = decisionXConditions.isTrendBullish;
bool hasDecisionBearishTrend = decisionXConditions.isTrendBearish;
//
// Detect Bar State ...