last ...
This commit is contained in:
@@ -169,15 +169,17 @@ class XC121SMCCycleHelper : public XCBase
|
||||
//
|
||||
int maxLoopbackBars = mPOIDetector.MaxAllowedLoopbackForInit();
|
||||
int periodSeconds = PeriodSeconds(period);
|
||||
if (periodSeconds > PeriodSeconds(PERIOD_M15)) {
|
||||
if (periodSeconds > PeriodSeconds(PERIOD_M15))
|
||||
{
|
||||
//
|
||||
int multiplier = periodSeconds / PeriodSeconds(PERIOD_M15);
|
||||
|
||||
//
|
||||
if (multiplier >= 1) {
|
||||
if (multiplier >= 1)
|
||||
{
|
||||
maxLoopbackBars *= 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
mPOIDetector.MaxAllowedLoopbackForInit(maxLoopbackBars);
|
||||
mPOIDetector.Init();
|
||||
|
||||
@@ -450,6 +452,134 @@ class XC121SMCCycleHelper : public XCBase
|
||||
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 ...
|
||||
|
||||
|
||||
@@ -500,6 +500,7 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
idx = i;
|
||||
signalBox = iBox;
|
||||
hasSignalBox = has;
|
||||
signalBox.to = cTime;
|
||||
signalBoxDir = iBox.dir;
|
||||
isSignalBoxReversal = false;
|
||||
provider = X121SMC_XWZ_PROVIDER_ACTIVATED_ZONE;
|
||||
@@ -553,119 +554,25 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
if (!hasSignalBox)
|
||||
{
|
||||
//
|
||||
// Score Conditions ...
|
||||
double scoreMultiplier = 3;
|
||||
bool isBullishScorePassed =
|
||||
//
|
||||
analyseBullishScore > (analyseBearishScore * scoreMultiplier) &&
|
||||
decisionBullishScore > (decisionBearishScore * scoreMultiplier)
|
||||
//
|
||||
;
|
||||
bool isBearishScorePassed =
|
||||
//
|
||||
analyseBearishScore > (analyseBullishScore * scoreMultiplier) &&
|
||||
decisionBearishScore > (decisionBullishScore * scoreMultiplier)
|
||||
//
|
||||
;
|
||||
// Senari A ...
|
||||
|
||||
//
|
||||
// X3Ma ...
|
||||
|
||||
//
|
||||
// X3Ma Bullish ...
|
||||
bool isX3MaBullish =
|
||||
//
|
||||
decisionXConditions.isX3MaBullishState &&
|
||||
decisionXConditions.isX3MaSwitchedToBullishOrdered &&
|
||||
decisionXConditions.x3maMidBuffer[1] > decisionXConditions.x3maSlowBuffer[1]
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// 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)
|
||||
hasSignalBox = hasWorkingZone &&
|
||||
workingZone.DetectSenarioASignalBox(
|
||||
signalBox,
|
||||
signalBoxDir,
|
||||
decisionXConditions,
|
||||
analyseXConditions,
|
||||
decisionCycleHelper,
|
||||
drawer,
|
||||
zIndex //
|
||||
);
|
||||
if (hasSignalBox)
|
||||
{
|
||||
//
|
||||
if (isX3MaHasCondition)
|
||||
{
|
||||
//
|
||||
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 ...");
|
||||
signalBox.to = cTime;
|
||||
isSignalBoxReversal = false;
|
||||
provider = X121SMC_XWZ_PROVIDER_PV_ZONE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -711,10 +618,394 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
iObj.BoxWidth(1);
|
||||
iObj.BoxColor(clrYellow);
|
||||
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
|
||||
: 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.triggerTime = cTime;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -763,7 +763,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
// XTREND ...
|
||||
x121Inputs.xtrendInputs.showUpTrend = showAll || false;
|
||||
x121Inputs.xtrendInputs.showDownTrend = showAll || false;
|
||||
x121Inputs.xtrendInputs.showOnlyTrendStart = showAll || false;
|
||||
x121Inputs.xtrendInputs.showOnlyTrendStart = showAll || true;
|
||||
|
||||
//
|
||||
// XPV ...
|
||||
@@ -775,26 +775,26 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
// XHK ...
|
||||
|
||||
//
|
||||
x121Inputs.xhkInputs.drawRawXHKCandles = showAll || false;
|
||||
x121Inputs.xhkInputs.drawSmoothedXHKCandles = showAll || false;
|
||||
x121Inputs.xhkInputs.drawRawXHKCandles = showAll || true;
|
||||
x121Inputs.xhkInputs.drawSmoothedXHKCandles = showAll || true;
|
||||
|
||||
//
|
||||
// XATR ...
|
||||
x121Inputs.xatrInputs.showATRUpper = showAll || false;
|
||||
x121Inputs.xatrInputs.showATRLower = showAll || false;
|
||||
x121Inputs.xatrInputs.showATRUpper = showAll || true;
|
||||
x121Inputs.xatrInputs.showATRLower = showAll || true;
|
||||
|
||||
//
|
||||
// XSTR ...
|
||||
x121Inputs.xstrInputs.showStr = showAll || false;
|
||||
x121Inputs.xstrInputs.showStr = showAll || true;
|
||||
x121Inputs.xstrInputs.showStrUpper = showAll || false;
|
||||
x121Inputs.xstrInputs.showStrLower = showAll || false;
|
||||
|
||||
//
|
||||
// XCHE ...
|
||||
x121Inputs.xcheInputs.showLE1 = showAll || false;
|
||||
x121Inputs.xcheInputs.showLE2 = showAll || false;
|
||||
x121Inputs.xcheInputs.showSE1 = showAll || false;
|
||||
x121Inputs.xcheInputs.showSE2 = showAll || false;
|
||||
x121Inputs.xcheInputs.showLE1 = showAll || true;
|
||||
x121Inputs.xcheInputs.showLE2 = showAll || true;
|
||||
x121Inputs.xcheInputs.showSE1 = showAll || true;
|
||||
x121Inputs.xcheInputs.showSE2 = showAll || true;
|
||||
|
||||
//
|
||||
// XDON ...
|
||||
@@ -805,9 +805,9 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
|
||||
//
|
||||
// XVWAP ...
|
||||
x121Inputs.xvwapInputs.showVWapFast = showAll || false;
|
||||
x121Inputs.xvwapInputs.showVWapMedium = showAll || false;
|
||||
x121Inputs.xvwapInputs.showVWapSlow = showAll || false;
|
||||
x121Inputs.xvwapInputs.showVWapFast = showAll || true;
|
||||
x121Inputs.xvwapInputs.showVWapMedium = showAll || true;
|
||||
x121Inputs.xvwapInputs.showVWapSlow = showAll || true;
|
||||
|
||||
//
|
||||
// X3MA ...
|
||||
|
||||
Reference in New Issue
Block a user