This commit is contained in:
2025-03-04 03:05:25 +03:30
parent 6a3fb91e9c
commit ec006cd6b7
6 changed files with 1278 additions and 357 deletions
+15 -15
View File
@@ -44,23 +44,23 @@ input string eaSymbols = "EURUSDb,GBPUSDb,USDCHFb,USDJPYb,XAUUSDb"; // Trading S
// //
// Signalling ... // Signalling ...
input group "Signalling"; input group "Signalling";
input bool eaAllowLong = true; // Allow Long Signals input bool eaAllowLong = true; // Allow Long Signals
input bool eaAllowShort = true; // Allow Short Signals input bool eaAllowShort = true; // Allow Short Signals
input int eaMaxAllowedLongs = 5; // Max Allowed Long Signals input int eaMaxAllowedLongs = 5; // Max Allowed Long Signals
input int eaMaxAllowedShorts = 5; // Max Allowed Short Signals input int eaMaxAllowedShorts = 5; // Max Allowed Short Signals
input bool eaUseMaxAllowedSignalsPerSymbol = true; // Use Max Allowed Signal Types Per Symbol input bool eaUseMaxAllowedSignalsPerSymbol = true; // Use Max Allowed Signal Types Per Symbol
input double eaLastPositionProfitForAcceptNextInPoint = 0; // Last Position Profit In Points for Accept new Signal input double eaLastPositionProfitForAcceptNextInPoint = 30; // Last Position Profit In Points for Accept new Signal
input int eaDelaysBetweenTwoSignalsInBar = 0; // Delay between two Signals in Bars input int eaDelaysBetweenTwoSignalsInBar = 12; // Delay between two Signals in Bars
input double eaMaxAllowedSpread = 25; // Max Allowed Spread for Signalling input double eaMaxAllowedSpread = 25; // Max Allowed Spread for Signalling
input int eaMinRequiredVerificationForSpreadPass = 20; // Minimum Spread Verification for Signalling input int eaMinRequiredVerificationForSpreadPass = 20; // Minimum Spread Verification for Signalling
// //
// Trade ... // Trade ...
input group "Trade"; input group "Trade";
input bool eaAllowTrade = true; // Allow Open Trade On Signals input bool eaAllowTrade = true; // Allow Open Trade On Signals
input string eaStartTradeAt = ""; // Enable Trade on Signals on Time input string eaStartTradeAt = "02:30"; // Enable Trade on Signals on Time
input string eaStopTradeAt = ""; // Enable Trade on Signals on Time input string eaStopTradeAt = "23:30"; // Enable Trade on Signals on Time
input string eaCloseAllTradesAt = ""; // Enable Close All Trades on Signals on Time input string eaCloseAllTradesAt = ""; // Enable Close All Trades on Signals on Time
// //
// Risk Management ... // Risk Management ...
@@ -82,9 +82,9 @@ input int eaPauseSignallingAfterReachesMaxAllowedSLInSecconds = 10800; // Pause
// Protection ... // Protection ...
input group "Protection"; input group "Protection";
input bool eaAllowHedging = true; // Allow Hedge Positions input bool eaAllowHedging = true; // Allow Hedge Positions
input int eaMinOpenTradesFroHedging = 4; // Minimum Open Positions for Hedging input int eaMinOpenTradesFroHedging = 3; // Minimum Open Positions for Hedging
input double eaHedgingMinVolumeStep = 0.01; // Minimum Volume Step for Hedging input double eaHedgingMinVolumeStep = 0.01; // Minimum Volume Step for Hedging
input double eaHedgeingMinRequiredProfitPerVolumeStep = 4.0; // Minimum Required Profit Per Volume Step for Hedging input double eaHedgeingMinRequiredProfitPerVolumeStep = 1.0; // Minimum Required Profit Per Volume Step for Hedging
// //
// Alert ... // Alert ...
@@ -1299,7 +1299,7 @@ bool HasInsideBox(
// //
bool isInside = !iBox.IsSameAs(source) && bool isInside = !iBox.IsSameAs(source) &&
IsBoxInside( IsBoxInsideOr(
iBox, iBox,
source // source //
); );
@@ -169,12 +169,14 @@ class XC121SMCCycleHelper : public XCBase
// //
int maxLoopbackBars = mPOIDetector.MaxAllowedLoopbackForInit(); int maxLoopbackBars = mPOIDetector.MaxAllowedLoopbackForInit();
int periodSeconds = PeriodSeconds(period); int periodSeconds = PeriodSeconds(period);
if (periodSeconds > PeriodSeconds(PERIOD_M15)) { if (periodSeconds > PeriodSeconds(PERIOD_M15))
{
// //
int multiplier = periodSeconds / PeriodSeconds(PERIOD_M15); int multiplier = periodSeconds / PeriodSeconds(PERIOD_M15);
// //
if (multiplier >= 1) { if (multiplier >= 1)
{
maxLoopbackBars *= 2; maxLoopbackBars *= 2;
} }
} }
@@ -450,6 +452,134 @@ class XC121SMCCycleHelper : public XCBase
return result; return result;
} }
bool GeneratePVBox(
XBoxZone &box,
int barIndex = 0 //
)
{
//
bool result = false;
//
if (barIndex < 0)
{
barIndex = 0;
}
//
box.Clean();
box.symbol = GetSymbol();
box.period = GetPeriod();
//
int index = barIndex;
//
// Peak ...
datetime peaksSameFrom = NULL;
double peak = mX121Helper.xpvHelper.GetPeak(index);
double prevPeak = mX121Helper.xpvHelper.GetPeak(index + 1);
bool startsByPeak = peak == prevPeak;
//
// Vale ...
datetime valesSameFrom = NULL;
double vale = mX121Helper.xpvHelper.GetVale(index);
double prevVale = mX121Helper.xpvHelper.GetVale(index + 1);
bool startsByVale = vale == prevVale;
//
bool canBreak = false;
while (!canBreak)
{
//
index++;
//
datetime cTime = iTime(
box.symbol,
box.period,
index //
);
//
// Peak ...
double iPeak = mX121Helper.xpvHelper.GetPeak(index);
//
// Vale ...
double iVale = mX121Helper.xpvHelper.GetVale(index);
//
// Start By Peak or Value ...
bool isSame = false;
if (startsByPeak)
{
//
isSame = iPeak == peak;
bool canSetVale = vale == 0
? true
: iVale > vale;
if (canSetVale)
{
vale = iVale;
}
}
else if (startsByVale)
{
//
isSame = iVale == vale;
bool canSetPeak = peak == 0
? true
: iPeak < peak;
if (canSetPeak)
{
peak = iPeak;
}
}
//
if (isSame)
{
//
box.from = cTime;
box.upper = peak;
box.lower = vale;
}
else if (IsValid(box.from))
{
//
// Complete Box ...
box.to = iTime(
box.symbol,
box.period,
barIndex //
);
//
box.type = "XPVBox";
box.dir = startsByPeak
? X_DIRECTION_BEARISH
: startsByVale
? X_DIRECTION_BULLISH
: X_DIRECTION_NONE;
}
//
canBreak = !isSame;
}
//
result = box.IsValid();
if (!result)
{
box.Clean();
}
//
return result;
}
// //
// Virtuals ... // Virtuals ...
+413 -110
View File
@@ -500,6 +500,7 @@ class XCX121SMCXWZSignalDetector : public XCBase
idx = i; idx = i;
signalBox = iBox; signalBox = iBox;
hasSignalBox = has; hasSignalBox = has;
signalBox.to = cTime;
signalBoxDir = iBox.dir; signalBoxDir = iBox.dir;
isSignalBoxReversal = false; isSignalBoxReversal = false;
provider = X121SMC_XWZ_PROVIDER_ACTIVATED_ZONE; provider = X121SMC_XWZ_PROVIDER_ACTIVATED_ZONE;
@@ -553,119 +554,25 @@ class XCX121SMCXWZSignalDetector : public XCBase
if (!hasSignalBox) if (!hasSignalBox)
{ {
// //
// Score Conditions ... // Senari A ...
double scoreMultiplier = 3;
bool isBullishScorePassed =
//
analyseBullishScore > (analyseBearishScore * scoreMultiplier) &&
decisionBullishScore > (decisionBearishScore * scoreMultiplier)
//
;
bool isBearishScorePassed =
//
analyseBearishScore > (analyseBullishScore * scoreMultiplier) &&
decisionBearishScore > (decisionBullishScore * scoreMultiplier)
//
;
// //
// X3Ma ... hasSignalBox = hasWorkingZone &&
workingZone.DetectSenarioASignalBox(
// signalBox,
// X3Ma Bullish ... signalBoxDir,
bool isX3MaBullish = decisionXConditions,
// analyseXConditions,
decisionXConditions.isX3MaBullishState && decisionCycleHelper,
decisionXConditions.isX3MaSwitchedToBullishOrdered && drawer,
decisionXConditions.x3maMidBuffer[1] > decisionXConditions.x3maSlowBuffer[1] zIndex //
// );
; if (hasSignalBox)
//
// X3Ma Bearish ...
bool isX3MaBearish =
//
decisionXConditions.isX3MaBearishState &&
decisionXConditions.isX3MaSwitchedToBearishOrdered &&
decisionXConditions.x3maMidBuffer[1] < decisionXConditions.x3maSlowBuffer[1]
//
;
//
bool isX3MaHasCondition =
(isX3MaBullish &&
isBullishScorePassed) ||
(isX3MaBearish &&
isBearishScorePassed);
//
// VWap ...
//
// VWap Bullish ...
bool isVWapBullish =
//
decisionXConditions.isVWapBullishState &&
decisionXConditions.isVWapSwitchedToBullishOrdered &&
decisionXConditions.vwapMidBuffer[1] > decisionXConditions.vwapSlowBuffer[1]
//
;
//
// VWap Bearish ...
bool isVWapBearish =
//
decisionXConditions.isVWapBearishState &&
decisionXConditions.isVWapSwitchedToBearishOrdered &&
decisionXConditions.vwapMidBuffer[1] < decisionXConditions.vwapSlowBuffer[1]
//
;
//
bool isVWapHasCondition =
(isVWapBullish &&
isBullishScorePassed) ||
(isVWapBearish &&
isBearishScorePassed);
//
// Checking Other Conditions XWZ Reject on EMA 20 ...
//
// Check Has Conditions ...
bool hasXConditions =
(isX3MaHasCondition ||
isVWapHasCondition);
//
if (hasXConditions)
{ {
// //
if (isX3MaHasCondition) signalBox.to = cTime;
{ isSignalBoxReversal = false;
// provider = X121SMC_XWZ_PROVIDER_PV_ZONE;
signalBoxDir =
isX3MaBullish
? X_DIRECTION_BULLISH
: isX3MaBearish
? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
}
//
if (isVWapHasCondition)
{
//
signalBoxDir =
isVWapBullish
? X_DIRECTION_BULLISH
: isVWapBearish
? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
}
//
Print("X Conditions ...");
} }
} }
@@ -711,10 +618,394 @@ class XCX121SMCXWZSignalDetector : public XCBase
iObj.BoxWidth(1); iObj.BoxWidth(1);
iObj.BoxColor(clrYellow); iObj.BoxColor(clrYellow);
iObj.BoxStyle(STYLE_SOLID); iObj.BoxStyle(STYLE_SOLID);
}
//
isBullish = IsBullish(signalBoxDir);
isBearish = IsBearish(signalBoxDir);
//
pivot = isBullish
? signalBox.lower
: signalBox.upper;
//
point = isBullish
? signalBox.upper
: signalBox.lower;
//
double iSL = 0;
double signalBoxRange = (signalBox.upper - signalBox.lower);
if (signalBoxRange < points * 100)
{
iSL = pivot;
}
else
{
iSL = signalBox.lower + (signalBox.upper - signalBox.lower) / 2;
}
//
Add(
iSL,
sls //
);
//
// Targets ...
//
// Based On Priority ...
has = priority != X121SMC_XWZ_PRIORITY_NONE;
if (has)
{
//
switch (priority)
{
//
case X121SMC_XWZ_PRIORITY_WEAK:
//
if (isBullish)
{
//
// Weak ...
Add(
workingZone.supplyZone.Lower(),
targets //
);
}
else
{
//
// Weak ...
Add(
workingZone.demandZone.Upper(),
targets //
);
}
break;
// //
Print("Signal Box Exists ..."); case X121SMC_XWZ_PRIORITY_LOW:
//
if (isBullish)
{
//
// Weak ...
Add(
workingZone.supplyZone.Lower(),
targets //
);
//
// Low ...
Add(
workingZone.quarter1,
targets //
);
}
else
{
//
// Weak ...
Add(
workingZone.demandZone.Upper(),
targets //
);
//
// Low ...
Add(
workingZone.quarter3,
targets //
);
}
break;
//
case X121SMC_XWZ_PRIORITY_REGULAR:
//
if (isBullish)
{
//
// Weak ...
Add(
workingZone.supplyZone.Lower(),
targets //
);
//
// Low ...
Add(
workingZone.quarter1,
targets //
);
//
// Regular ...
Add(
workingZone.quarter2,
targets //
);
}
else
{
//
// Weak ...
Add(
workingZone.demandZone.Upper(),
targets //
);
//
// Low ...
Add(
workingZone.quarter3,
targets //
);
//
// Regular ...
Add(
workingZone.quarter2,
targets //
);
}
break;
//
case X121SMC_XWZ_PRIORITY_HIGH:
//
if (isBullish)
{
//
// Weak ...
Add(
workingZone.supplyZone.Lower(),
targets //
);
//
// Low ...
Add(
workingZone.quarter1,
targets //
);
//
// Regular ...
Add(
workingZone.quarter2,
targets //
);
//
// High ...
Add(
workingZone.quarter3,
targets //
);
}
else
{
//
// Weak ...
Add(
workingZone.demandZone.Upper(),
targets //
);
//
// Low ...
Add(
workingZone.quarter3,
targets //
);
//
// Regular ...
Add(
workingZone.quarter2,
targets //
);
//
// High ...
Add(
workingZone.quarter1,
targets //
);
}
break;
//
case X121SMC_XWZ_PRIORITY_STRONG_HIGH:
//
if (isBullish)
{
//
// Weak ...
Add(
workingZone.supplyZone.Lower(),
targets //
);
//
// Low ...
Add(
workingZone.quarter1,
targets //
);
//
// Regular ...
Add(
workingZone.quarter2,
targets //
);
//
// High ...
Add(
workingZone.quarter3,
targets //
);
//
// Strong High ...
Add(
workingZone.demandZone.Upper(),
targets //
);
}
else
{
//
// Weak ...
Add(
workingZone.demandZone.Upper(),
targets //
);
//
// Low ...
Add(
workingZone.quarter3,
targets //
);
//
// Regular ...
Add(
workingZone.quarter2,
targets //
);
//
// High ...
Add(
workingZone.quarter1,
targets //
);
//
// Strong High ...
Add(
workingZone.supplyZone.Lower(),
targets //
);
}
break;
}
} }
//
XBoxZone waitingBoxes[];
has = workingZone.HasWaitingBoxes();
if (has)
{
//
Copy(
workingZone.waitingBoxes,
waitingBoxes //
);
//
while (HasChild(waitingBoxes))
{
//
XBoxZone iBox;
idx = GetYoungest(waitingBoxes);
has = IsValidIndex(idx);
if (!has)
{
//
iBox.Clean();
continue;
}
//
iBox = waitingBoxes[idx];
ArrayRemove(
waitingBoxes,
idx,
1 //
);
//
bool hasInside = workingZone.HasInsideBox(iBox);
if (!hasInside)
{
continue;
}
//
double iTarget =
IsBullish(signalBoxDir)
? iBox.lower
: iBox.upper;
//
Add(
iTarget,
targets //
);
//
iBox.Clean();
}
}
}
//
result = hasPriority &&
hasSignalBox &&
hasRewardAmount;
//
if (result)
{
//
Copy(
sls,
mConditions.sls //
);
Copy(
targets,
mConditions.targets //
);
//
mConditions.pivot = pivot;
mConditions.point = point;
mConditions.reward = reward;
mConditions.setupTime = cTime;
mConditions.dir = signalBoxDir;
mConditions.priority = priority;
mConditions.provider = provider;
mConditions.signalBox = signalBox;
mConditions.amountPercent = amountPercent;
} }
// //
@@ -953,6 +1244,18 @@ class XCX121SMCXWZSignalDetector : public XCBase
? longSL ? longSL
: shortSL; : shortSL;
//
// Add TP 2 as Target ...
double risk = MathAbs(entry - sl);
double reward2 = 2 * risk;
double iTP2 = isBullish
? entry + reward2
: entry - reward2;
Add(
iTP2,
conditions.targets //
);
// //
conditions.sl = sl; conditions.sl = sl;
conditions.triggerTime = cTime; conditions.triggerTime = cTime;
File diff suppressed because it is too large Load Diff
+13 -13
View File
@@ -763,7 +763,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// XTREND ... // XTREND ...
x121Inputs.xtrendInputs.showUpTrend = showAll || false; x121Inputs.xtrendInputs.showUpTrend = showAll || false;
x121Inputs.xtrendInputs.showDownTrend = showAll || false; x121Inputs.xtrendInputs.showDownTrend = showAll || false;
x121Inputs.xtrendInputs.showOnlyTrendStart = showAll || false; x121Inputs.xtrendInputs.showOnlyTrendStart = showAll || true;
// //
// XPV ... // XPV ...
@@ -775,26 +775,26 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// XHK ... // XHK ...
// //
x121Inputs.xhkInputs.drawRawXHKCandles = showAll || false; x121Inputs.xhkInputs.drawRawXHKCandles = showAll || true;
x121Inputs.xhkInputs.drawSmoothedXHKCandles = showAll || false; x121Inputs.xhkInputs.drawSmoothedXHKCandles = showAll || true;
// //
// XATR ... // XATR ...
x121Inputs.xatrInputs.showATRUpper = showAll || false; x121Inputs.xatrInputs.showATRUpper = showAll || true;
x121Inputs.xatrInputs.showATRLower = showAll || false; x121Inputs.xatrInputs.showATRLower = showAll || true;
// //
// XSTR ... // XSTR ...
x121Inputs.xstrInputs.showStr = showAll || false; x121Inputs.xstrInputs.showStr = showAll || true;
x121Inputs.xstrInputs.showStrUpper = showAll || false; x121Inputs.xstrInputs.showStrUpper = showAll || false;
x121Inputs.xstrInputs.showStrLower = showAll || false; x121Inputs.xstrInputs.showStrLower = showAll || false;
// //
// XCHE ... // XCHE ...
x121Inputs.xcheInputs.showLE1 = showAll || false; x121Inputs.xcheInputs.showLE1 = showAll || true;
x121Inputs.xcheInputs.showLE2 = showAll || false; x121Inputs.xcheInputs.showLE2 = showAll || true;
x121Inputs.xcheInputs.showSE1 = showAll || false; x121Inputs.xcheInputs.showSE1 = showAll || true;
x121Inputs.xcheInputs.showSE2 = showAll || false; x121Inputs.xcheInputs.showSE2 = showAll || true;
// //
// XDON ... // XDON ...
@@ -805,9 +805,9 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// //
// XVWAP ... // XVWAP ...
x121Inputs.xvwapInputs.showVWapFast = showAll || false; x121Inputs.xvwapInputs.showVWapFast = showAll || true;
x121Inputs.xvwapInputs.showVWapMedium = showAll || false; x121Inputs.xvwapInputs.showVWapMedium = showAll || true;
x121Inputs.xvwapInputs.showVWapSlow = showAll || false; x121Inputs.xvwapInputs.showVWapSlow = showAll || true;
// //
// X3MA ... // X3MA ...