This commit is contained in:
2025-03-30 01:20:09 +03:30
parent 1b93b469a1
commit ac95a26e24
10 changed files with 1798 additions and 174 deletions
@@ -1047,6 +1047,256 @@ class XC121SMCCycleHelper : public XCBase
return result;
}
//
bool DetectNearestVolumeSwitched(
XOHCL &bar,
ENUM_X_DIRECTION &dir,
int barIndex = 0,
int maxAllowedBars = 20 //
)
{
//
bool result = false;
//
bar.Clean();
dir = X_DIRECTION_NONE;
barIndex = NormalizeInt(barIndex, 0);
maxAllowedBars = NormalizeInt(maxAllowedBars, 20);
//
// Looping Through LoopBack Period ...
// for Detecting Result ...
for (int i = barIndex; i < barIndex + maxAllowedBars; i++)
{
//
XOHCL iBar;
result = iBar.Init(
GetSymbol(),
GetPeriod(),
i //
);
if (!result)
{
//
iBar.Clean();
break;
}
//
double iBullVMa = mX121Helper.xvolumeHelper.GetBullishVolumeMa(i);
double iBullVMaP = mX121Helper.xvolumeHelper.GetBullishVolumeMa(i + 1);
//
double iBearVMa = mX121Helper.xvolumeHelper.GetBearishVolumeMa(i);
double iBearVMaP = mX121Helper.xvolumeHelper.GetBearishVolumeMa(i + 1);
//
bool isBullVMaOverBearVMa = iBullVMa > iBearVMa;
bool isBullVMaOverBearVMaP = iBullVMaP > iBearVMaP;
bool isCrossOver = isBullVMaOverBearVMa &&
!isBullVMaOverBearVMaP;
//
bool isBullVMaUnderBearVMa = iBullVMa < iBearVMa;
bool isBullVMaUnderBearVMaP = iBullVMaP < iBearVMaP;
bool isCrossUnder = isBullVMaUnderBearVMa &&
!isBullVMaUnderBearVMaP;
//
result = isCrossOver ||
isCrossUnder;
if (result)
{
//
bar = iBar;
//
dir = isCrossOver
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
iBar.Clean();
break;
}
//
iBar.Clean();
}
//
return result;
}
//
bool DetectNearestDeltaSwitched(
XOHCL &bar,
ENUM_X_DIRECTION &dir,
int barIndex = 0,
int maxAllowedBars = 20 //
)
{
//
bool result = false;
//
bar.Clean();
dir = X_DIRECTION_NONE;
barIndex = NormalizeInt(barIndex, 0);
maxAllowedBars = NormalizeInt(maxAllowedBars, 20);
//
// Looping Through LoopBack Period ...
// for Detecting Result ...
for (int i = barIndex; i < barIndex + maxAllowedBars; i++)
{
//
XOHCL iBar;
result = iBar.Init(
GetSymbol(),
GetPeriod(),
i //
);
if (!result)
{
//
iBar.Clean();
break;
}
//
double iDelta = mX121Helper.xdeltaHelper.GetDelta(i);
double iDeltaP = mX121Helper.xdeltaHelper.GetDelta(i + 1);
//
double iDeltaMa = mX121Helper.xdeltaHelper.GetDeltaMa(i);
double iDeltaMaP = mX121Helper.xdeltaHelper.GetDeltaMa(i + 1);
//
bool isDeltaOverMa = iDelta > iDeltaMa;
bool isDeltaOverMaP = iDeltaP > iDeltaMaP;
//
bool isDeltaUnderMa = iDelta < iDeltaMa;
bool isDeltaUnderMaP = iDeltaP < iDeltaMaP;
//
bool isCrossOver = isDeltaOverMa &&
!isDeltaOverMaP;
//
bool isCrossUnder = isDeltaUnderMa &&
!isDeltaUnderMaP;
//
result = isCrossOver ||
isCrossUnder;
if (result)
{
//
bar = iBar;
//
dir = isCrossOver
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
iBar.Clean();
break;
}
//
iBar.Clean();
}
//
return result;
}
//
bool DetectNearestStrSwitched(
XOHCL &bar,
ENUM_X_DIRECTION &dir,
int barIndex = 0,
int maxAllowedBars = 20 //
)
{
//
bool result = false;
//
bar.Clean();
dir = X_DIRECTION_NONE;
barIndex = NormalizeInt(barIndex, 0);
maxAllowedBars = NormalizeInt(maxAllowedBars, 20);
//
// Looping Through LoopBack Period ...
// for Detecting Result ...
for (int i = barIndex; i < barIndex + maxAllowedBars; i++)
{
//
XOHCL iBar;
result = iBar.Init(
GetSymbol(),
GetPeriod(),
i //
);
if (!result)
{
//
iBar.Clean();
break;
}
//
double iStrState = mX121Helper.xstrHelper.GetSTRState(i);
double iStrStateP = mX121Helper.xstrHelper.GetSTRState(i + 1);
//
bool isStrBullish = iStrState > 0;
bool isStrBullishP = iStrStateP > 0;
//
bool isStrBearish = iStrState < 0;
bool isStrBearishP = iStrStateP < 0;
//
bool isBullish = isStrBullish &&
!isStrBullishP;
//
bool isBearish = isStrBearish &&
!isStrBearishP;
//
result = isBullish ||
isBearish;
if (result)
{
//
bar = iBar;
//
dir = isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
iBar.Clean();
break;
}
//
iBar.Clean();
}
//
return result;
}
//
// Virtuals ...
@@ -2411,7 +2661,7 @@ struct X121SMCStrategyConditionParser
//
// Rejected Boxes ...
bool HasRejectedBoxConditions(
bool HasRejectedBocXConditions(
ENUM_X_CYCLES cycle,
XSignalBox &box,
ENUM_X_DIRECTION &dir,
@@ -2702,7 +2952,7 @@ struct X121SMCStrategyConditionParser
//
// Activated Boxes ...
bool HasActivatedBoxConditions(
bool HasActivatedBocXConditions(
ENUM_X_CYCLES cycle,
XSignalBox &box,
ENUM_X_DIRECTION &dir,
@@ -3017,7 +3267,7 @@ struct X121SMCStrategyConditionParser
//
// Breaked Boxes ...
bool HasBreakedBoxConditions(
bool HasBreakedBocXConditions(
ENUM_X_CYCLES cycle,
XSignalBox &box,
ENUM_X_DIRECTION &dir,
@@ -4069,5 +4319,310 @@ struct X121SMCStrategyConditionParser
return result;
}
//
bool HasXICHConditions(
ENUM_X_CYCLES cycle,
XBoxZone &box,
ENUM_X_DIRECTION &dir,
X121SMCStrategySignalProviderData &provider,
int barIndex = 0 //
)
{
//
bool result = false;
//
box.Clean();
dir = X_DIRECTION_NONE;
//
// Fil Selected Data ...
XPOIState cState;
X121Conditions cXConditions;
XPOIStateEvents cStateEvents;
XC121SMCCycleHelper *cHelper;
X121SMCCycleConditions cConditions;
result = provider.SelectCycle(
cycle,
cState,
cStateEvents,
cXConditions,
cHelper,
cConditions //
);
if (!result)
{
//
cState.Clean();
ZeroMemory(cHelper);
cConditions.Clean();
cXConditions.Clean();
cStateEvents.Clean();
//
return result;
}
Parse(cXConditions);
//
// Normalize Args ...
//
if (barIndex < 0)
{
barIndex = 0;
}
//
int idx = -1;
int count = 0;
bool has = false;
//
int zIDX = barIndex;
int cIDX = zIDX + 1;
int pIDX = cIDX + 1;
int ppIDX = pIDX + 1;
//
bool isBullish = false;
bool isBearish = false;
//
XOHCL zBar;
XOHCL cBar;
XOHCL pBar;
XOHCL pPBar;
//
// Initial Bars ...
result = zBar.Init(
cState.symbol,
cState.period,
barIndex //
);
result =
result &&
zBar.GetPreviousBar(cBar);
result =
result &&
cBar.GetPreviousBar(pBar);
result =
result &&
pBar.GetPreviousBar(pPBar);
if (!result)
{
//
zBar.Clean();
cBar.Clean();
pBar.Clean();
cState.Clean();
ZeroMemory(cHelper);
cConditions.Clean();
cXConditions.Clean();
//
return result;
}
//
// Checking Conditions ...
//
// XDELTA ...
//
bool isDeltaSwitchedToBullish =
(cXConditions.isDeltaCrossedOverMa &&
cXConditions.isDeltaSwitchedToBullish);
bool isDeltaBullish =
(cXConditions.isDeltaOverMa &&
cXConditions.isDeltaBullish);
bool isDeltaIsBullish =
isDeltaBullish ||
isDeltaSwitchedToBullish;
//
bool isDeltaSwitchedToBearish =
(cXConditions.isDeltaCrossedUnderMa &&
cXConditions.isDeltaSwitchedToBearish);
bool isDeltaBearish =
(cXConditions.isDeltaUnderMa &&
cXConditions.isDeltaBearish);
bool isDeltaIsBearish =
isDeltaBearish ||
isDeltaSwitchedToBearish;
//
// XVOLUME ...
//
bool isVolumeSwitchedToBullish =
(cXConditions.isVolumeSwitchedToBullish &&
cXConditions.isBullishVolumeSwitchedToIncreased);
bool isVolumeBullish =
(cXConditions.isBullishVolumeIncreased &&
cXConditions.isBullishVolumeMaOverBearishVolumeMa);
bool isVolumeIsBullish =
isVolumeBullish ||
isVolumeSwitchedToBullish;
//
bool isVolumeSwitchedToBearish =
(cXConditions.isVolumeSwitchedToBearish &&
cXConditions.isBearishVolumeSwitchedToIncreased);
bool isVolumeBearish =
(cXConditions.isBullishVolumeMaUnderBearishVolumeMa &&
cXConditions.isBearishVolumeIncreased);
bool isVolumeIsBearish =
isVolumeBearish ||
isVolumeSwitchedToBearish;
//
// XSTR ...
bool isStrIsBullish =
(cXConditions.isStrBullish ||
cXConditions.isStrSwitchedToBullish);
bool isStrIsBearish =
(cXConditions.isStrBearish ||
cXConditions.isStrSwitchedToBearish);
//
// XICH ...
bool isIchIsBullish =
(cXConditions.isTenkanSenOverKijunSen ||
cXConditions.isTenkanSenCrossedOverKijunSen);
bool isIchIsBearish =
(cXConditions.isTenkanSenUnderKijunSen ||
cXConditions.isTenkanSenCrossedUnderKijunSen);
//
// Checking TK Zone ...
//
bool isBullishTKZone =
isIchIsBullish &&
cBar.low < cXConditions.tenkanSenBuffer[cIndex] &&
cBar.low > cXConditions.kijunSenBuffer[cIndex] &&
cBar.low < pBar.low &&
zBar.open > cBar.low;
//
bool isBearishTKZone =
isIchIsBearish &&
cBar.high > cXConditions.tenkanSenBuffer[cIndex] &&
cBar.high < cXConditions.kijunSenBuffer[cIndex] &&
cBar.high > pBar.high &&
zBar.open < cBar.high;
//
// Summarize Conditions ...
//
isBullish =
//
// false
isStrIsBullish &&
isIchIsBullish &&
isBullishTKZone &&
isDeltaIsBullish &&
isVolumeIsBullish
//
//
;
//
isBearish =
//
// false
isStrIsBearish &&
isIchIsBearish &&
isBearishTKZone &&
isDeltaIsBearish &&
isVolumeIsBearish
//
;
//
// Filling Requirements ...
result =
isBullish ||
isBearish;
if (result)
{
//
dir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
box.dir = dir;
box.from = pPBar.time;
box.to = TimeCurrent();
box.symbol = cBar.symbol;
box.period = cBar.period;
//
pivot = isBullish
? cBar.low - (points * 5)
: cBar.high + (points * 5);
//
point = GetEntry(
cBar.symbol,
signalBoxDir //
);
//
box.upper =
isBullish
? point
: pivot;
//
box.lower =
isBullish
? pivot
: point;
//
bool drawBoxes = true;
if (drawBoxes)
{
//
}
//
Print("Signal ...");
result = false;
isBearish = false;
isBullish = false;
}
//
// Check All Conditions ...
result =
box.IsValid() &&
HasDirection(dir) &&
(isBullish ||
isBearish);
//
// Cleanup Resources ...
zBar.Clean();
cBar.Clean();
pBar.Clean();
pPBar.Clean();
cState.Clean();
cConditions.Clean();
cConditions.Clean();
ZeroMemory(cHelper);
cStateEvents.Clean();
cXConditions.Clean();
//
return result;
}
//
};
+24 -163
View File
@@ -206,157 +206,23 @@ class XCX121SMCXICHSignalDetector : public XCBase
//
//
// Update Models To Time ...
UpdateTo(cTime);
// Provider XTkKumo ...
X121SMCStrategyConditionParser cParser;
hasSignalBox = cParser.HasXICHConditions(
X_CYCLE_ANALYSE,
signalBox,
signalBoxDir,
provider,
zIndex //
);
if (hasSignalBox)
{
signalProvider = X121SMC_XICH_PROVIDER_XTKKUMO;
}
//
// Here we Detect Signal Box ...
if (!hasSignalBox)
{
//
// HTF Proves ...
//
double scoreMultiplier = 1.5;
//
bool isConsolidationScoreBullish =
provider.consolidationBullishScore > (provider.consolidationBearishScore * scoreMultiplier);
//
bool isConsolidationScoreBearish =
provider.consolidationBearishScore > (provider.consolidationBullishScore * scoreMultiplier);
//
// Detect Kumo Trend ...
bool isKumoBullish = provider.decisionXConditions.isSenkouSpanAOverB;
bool isKumoBearish = provider.decisionXConditions.isSenkouSpanAUnderB;
//
// Detect Nearest Cross ...
XOHCL tkCrossedBar;
ENUM_X_DIRECTION tkCrossDir;
bool hasNearestTenkanSenKijunSenCross =
provider
.decisionCycleHelper
.DetectNearestTenKijCross(
tkCrossedBar,
tkCrossDir,
zIndex //
);
//
bool isNearestTenkensSenCrossedOverKijunSen =
hasNearestTenkanSenKijunSenCross &&
IsBullish(tkCrossDir);
//
bool isNearestTenkensSenCrossedUnderKijunSen =
hasNearestTenkanSenKijunSenCross &&
IsBearish(tkCrossDir);
//
// Detect Price in TK Zone ...
bool isBarInsideTKZone =
isNearestTenkensSenCrossedOverKijunSen
? cBar.low < provider.decisionXConditions.tenkanSenBuffer[cIndex]
: isNearestTenkensSenCrossedUnderKijunSen
? cBar.high > provider.decisionXConditions.tenkanSenBuffer[cIndex]
: false;
//
// Checking Bar Based on Positions State ...
ENUM_X_DIRECTION iBarPosDir;
bool isBarValidForDir = provider.decisionCycleHelper
.mBarAnalyser
.IsValidForPosition(
cBar,
iBarPosDir //
);
bool isBarValidForBullish =
isBarValidForDir &&
IsBullish(iBarPosDir);
bool isBarValidForBearish =
isBarValidForDir &&
IsBearish(iBarPosDir);
//
// Summarize Conditions ...
//
isBullish =
//
isKumoBullish &&
isBarInsideTKZone &&
isBarValidForBullish &&
isConsolidationScoreBullish &&
isNearestTenkensSenCrossedOverKijunSen
//
;
//
isBearish =
//
isKumoBearish &&
isBarInsideTKZone &&
isBarValidForBearish &&
isConsolidationScoreBearish &&
isNearestTenkensSenCrossedUnderKijunSen
//
;
//
result =
isBullish ||
isBearish;
if (result)
{
//
signalProvider = X121SMC_XICH_PROVIDER_XTKKUMO;
//
signalBoxDir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
signalBox.from = pPBar.time;
signalBox.to = TimeCurrent();
signalBox.dir = signalBoxDir;
signalBox.symbol = cBar.symbol;
signalBox.period = cBar.period;
//
pivot = isBullish
? cBar.low - (points * 5)
: cBar.high + (points * 5);
//
point = GetEntry(
cBar.symbol,
signalBoxDir //
);
//
signalBox.upper =
isBullish
? point
: pivot;
//
signalBox.lower =
isBullish
? pivot
: point;
}
//
hasSignalBox = signalBox.IsValid();
//
tkCrossedBar.Clean();
}
// Update Models To Time ...
UpdateTo(cTime);
//
// Cleanup Signal if UnApproved ...
@@ -370,8 +236,11 @@ class XCX121SMCXICHSignalDetector : public XCBase
}
//
// Check Signal Conditions ...
if (hasSignalBox)
// Summarize Results ...
result = hasSignalBox;
//
if (result)
{
//
int idx = -1;
@@ -437,7 +306,7 @@ class XCX121SMCXICHSignalDetector : public XCBase
//
// Fix rf Reward ...
rfRewar = 2;
rfRewar = 1.5;
}
//
@@ -488,18 +357,7 @@ class XCX121SMCXICHSignalDetector : public XCBase
targets //
);
}
}
//
// Summarize Results ...
// result = hasPriority &&
// hasSignalBox &&
// hasRewardAmount;
result = hasSignalBox;
//
if (result)
{
//
Copy(
sls,
@@ -531,6 +389,9 @@ class XCX121SMCXICHSignalDetector : public XCBase
Clean(sls);
Clean(targets);
//
cParser.Clean();
//
provider.Clean();
@@ -2184,6 +2184,9 @@ struct X121SMCStrategyXWZWorkingZone
box.Clean();
}
//
cPraser.Clean();
//
return result;
}
@@ -999,7 +999,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
x121Inputs.xichInputs.shiftKumo = true;
//
x121Inputs.showRSI = showAll || false;
x121Inputs.showRSI = showAll || true;
//
// x121Inputs.xcheInputs.cheLength = 14;
@@ -1058,7 +1058,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
// XSTR ...
x121Inputs.xstrInputs.showStr = showAll || false;
x121Inputs.xstrInputs.showStr = showAll || true;
x121Inputs.xstrInputs.showStrUpper = showAll || false;
x121Inputs.xstrInputs.showStrLower = showAll || false;
@@ -1092,10 +1092,12 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// XICH ...
x121Inputs.xichInputs.showTenkanSen = showAll || true;
x121Inputs.xichInputs.showKijunSen = showAll || true;
x121Inputs.xichInputs.showChikouSpan = showAll || true;
x121Inputs.xichInputs.showSenkouSpanA = showAll || true;
x121Inputs.xichInputs.showSenkouSpanB = showAll || true;
x121Inputs.xichInputs.showKumo = showAll || true;
x121Inputs.xichInputs.showChikouSpan = showAll || false;
x121Inputs.xichInputs.showSenkouSpanA = showAll || false;
x121Inputs.xichInputs.showSenkouSpanB = showAll || false;
x121Inputs.xichInputs.showKumo = showAll || false;
//
//
// Initialize Cycle Helpers ...