add xche to supports list ...

This commit is contained in:
2025-01-13 09:33:02 +03:30
parent 83694f54ff
commit 218dda0a72
14 changed files with 4021 additions and 414 deletions
@@ -128,7 +128,8 @@ class XC121SMCCycleHelper : public XCBase
bool result = false;
//
if (requiredPOIS < 10) {
if (requiredPOIS < 10)
{
requiredPOIS = 10;
}
@@ -882,6 +883,199 @@ class XC121SMCCycleHelper : public XCBase
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 ...
+11
View File
@@ -38,6 +38,7 @@ const string X121SMCStrategyToken = "X121SMC";
const string X121SMCXTestToken = "X121XTest";
const string X121SMCXOBGPVToken = "X121XOBGPV";
const string X121SMCXOBSPVToken = "X121XOBSPV";
const string X121SMCXSTRPVToken = "X121XSTRPV";
//
// X121 SMC Providers ...
@@ -48,6 +49,7 @@ enum ENUM_X_121_SMC_PROVIDERS
X_121_SMC_PROVIDER_XTEST,
X_121_SMC_PROVIDER_XOBGPV,
X_121_SMC_PROVIDER_XOBSPV,
X_121_SMC_PROVIDER_XSTRPV,
};
//
@@ -684,6 +686,11 @@ string ToString(ENUM_X_121_SMC_PROVIDERS value)
case X_121_SMC_PROVIDER_XOBSPV:
result = X121SMCXOBSPVToken;
break;
//
case X_121_SMC_PROVIDER_XSTRPV:
result = X121SMCXSTRPVToken;
break;
}
//
@@ -721,6 +728,10 @@ ENUM_X_121_SMC_PROVIDERS ParseProvider(string value)
{
result = X_121_SMC_PROVIDER_XOBSPV;
}
else if (Contains(X121SMCXSTRPVToken, value))
{
result = X_121_SMC_PROVIDER_XSTRPV;
}
//
return result;
@@ -816,7 +816,11 @@ bool DetectX121SMCXOBGPVSiganlTrigger(
if (isBullish)
{
//
double lowerVale = triggerCycleHelper.mX121Helper.xpvHelper.GetLowerVale(vale);
int idx = -1;
double lowerVale = triggerCycleHelper.mX121Helper.xpvHelper.GetLowerVale(
idx,
vale //
);
if (lowerVale > 0)
{
//
@@ -835,7 +839,11 @@ bool DetectX121SMCXOBGPVSiganlTrigger(
else if (isBearish)
{
//
double higherPeak = triggerCycleHelper.mX121Helper.xpvHelper.GetHigherPeak(peak);
int idx = -1;
double higherPeak = triggerCycleHelper.mX121Helper.xpvHelper.GetHigherPeak(
idx,
peak //
);
if (higherPeak > 0)
{
//
@@ -881,6 +881,7 @@ bool DetectX121SMCXOBSPVSiganlTrigger(
isBullish =
//
isBullish &&
cBar.IsBullish() &&
isDecisionLastBearishStrBreakedUp
//
;
@@ -890,6 +891,7 @@ bool DetectX121SMCXOBSPVSiganlTrigger(
isBearish =
//
isBearish &&
cBar.IsBearish() &&
isDecisionLastBullishStrBreakedDown
//
;
@@ -953,15 +955,19 @@ bool DetectX121SMCXOBSPVSiganlTrigger(
double sls[];
//
double iAtr = triggerConditions.x121Conditions.atrBuffer[1];
double iPeak = triggerConditions.x121Conditions.peaksBuffer[1];
double iVale = triggerConditions.x121Conditions.valesBuffer[1];
double iAtr = decisionConditions.x121Conditions.atrBuffer[1];
double iPeak = decisionConditions.x121Conditions.peaksBuffer[1];
double iVale = decisionConditions.x121Conditions.valesBuffer[1];
//
if (isBullish)
{
//
double lowerVale = triggerCycleHelper.mX121Helper.xpvHelper.GetLowerVale(iVale);
int lowerValeIDX = -1;
double lowerVale = triggerCycleHelper.mX121Helper.xpvHelper.GetLowerVale(
lowerValeIDX,
iVale //
);
if (lowerVale > 0)
{
//
@@ -980,7 +986,11 @@ bool DetectX121SMCXOBSPVSiganlTrigger(
else if (isBearish)
{
//
double higherPeak = triggerCycleHelper.mX121Helper.xpvHelper.GetHigherPeak(iPeak);
int higherPeakIDX = -1;
double higherPeak = triggerCycleHelper.mX121Helper.xpvHelper.GetHigherPeak(
higherPeakIDX,
iPeak //
);
if (higherPeak > 0)
{
//
File diff suppressed because it is too large Load Diff
+269 -17
View File
@@ -30,6 +30,7 @@
#include "../Signals/x-121.smc.test.signal.lib.mq5"
#include "../Signals/x-121.smc.xobgpv.signal.lib.mq5"
#include "../Signals/x-121.smc.xobspv.signal.lib.mq5"
#include "../Signals/x-121.smc.xstrpv.signal.lib.mq5"
//
// Definitions ...
@@ -185,13 +186,15 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
bool useTestSignal = false;
bool useXOBGPVSignal = true;
bool useXOBSPVSignal = true;
bool useXOBGPVSignal = false;
bool useXOBSPVSignal = false;
bool useXSTRPVSignal = true;
//
bool hasTestSignal = false;
bool hasXOBGPVSignal = false;
bool hasXOBSPVSignal = false;
bool hasXSTRPVSignal = false;
//
// Test Signal ...
@@ -220,6 +223,15 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
hasSignal = hasXOBSPVSignal;
}
//
// XSTRPV Signal ...
if (useXSTRPVSignal && !hasSignal)
{
//
hasXSTRPVSignal = DetectXSTRPVSignal(conditions);
hasSignal = hasXSTRPVSignal;
}
//
result = hasSignal;
if (!result)
@@ -325,6 +337,18 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
if (result)
{
//
// Configure Signal Protector ...
if (useXSTRPVSignal)
{
//
signal.trailSL = false;
signal.fullTPLevel = r2r;
signal.partialCloseOnTPLevel = 2;
signal.partialCloseMultiplier = 0.5;
signal.trailSLStartOnReachTPLevel = 2;
}
//
// TODO: Remove this ...
// XCSignalObject *iObj;
@@ -964,6 +988,224 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
return result;
}
//
// XSTRPV Signal ...
bool DetectXSTRPVSignal(
X121SMCStrategyConditions &conditions //
)
{
//
bool result = false;
//
bool isBullish = false;
bool isBearish = false;
//
int zIndex = 0;
int cIndex = zIndex + 1;
int pIndex = cIndex + 1;
int ppIndex = pIndex + 1;
//
string symbol = GetSymbol();
ENUM_TIMEFRAMES period = GetPeriod();
//
XOHCL zBar;
result = zBar.Init(
symbol,
period,
zIndex //
);
if (!result)
{
return result;
}
//
XOHCL cBar;
result = cBar.Init(
symbol,
period,
cIndex //
);
if (!result)
{
return result;
}
//
XOHCL pBar;
result = pBar.Init(
symbol,
period,
pIndex //
);
if (!result)
{
return result;
}
//
double cLL = cBar.FindLowest(7, MODE_LOW);
double cHH = cBar.FindHighest(7, MODE_HIGH);
//
datetime cTime = TimeCurrent();
//
ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_XSTRPV;
string providerStr = ToString(provider);
//
// Detect Setup Conditions ...
datetime setupTime = mXSTRPVConditions.setupTime;
bool isSetuped = mXSTRPVConditions.IsSetuped();
ENUM_X_DIRECTION setupDir = mXSTRPVConditions.dir;
if (!isSetuped)
{
//
// Detect Signal Setup ...
isSetuped = DetectX121SMCXSTRPVSiganlSetup(
symbol,
period,
mXSTRPVConditions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
setupDir = mXSTRPVConditions.dir;
setupTime = mXSTRPVConditions.setupTime;
//
if (isSetuped)
{
//
int items = AddX121SMCXSTRPVConditionsIfNotExists(
mXSTRPVConditions,
mXSTRPVConditionsCollection //
);
//
mXSTRPVConditions.Clean();
}
}
//
int conditionsCount = ArraySize(mXSTRPVConditionsCollection);
result = IsValidSize(conditionsCount);
if (!result)
{
return result;
}
//
// Looking For Conditions ...
int selectedIndex = 0;
X121SMCStrategyXSTRPVSignalConditions mTmpConditions[];
Copy(
mXSTRPVConditionsCollection,
mTmpConditions //
);
X121SMCStrategyXSTRPVSignalConditions mConditions;
for (int i = 0; i < conditionsCount; i++)
{
//
// Check Triggers ...
bool canTrigger = mTmpConditions[i].CanTrigger();
datetime triggerTime = mTmpConditions[i].triggerTime;
if (!canTrigger)
{
//
// Detect Signal Trigger ...
canTrigger = DetectX121SMCXSTRPVSiganlTrigger(
mTmpConditions[i],
symbol,
period,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
result = canTrigger;
if (!result)
{
//
bool isISetuped = mTmpConditions[i].IsSetuped();
if (!isISetuped)
{
//
ArrayRemove(
mXSTRPVConditionsCollection,
i,
1 //
);
}
continue;
}
//
triggerTime = mTmpConditions[i].triggerTime;
}
//
if (canTrigger)
{
//
selectedIndex = i;
mConditions = mTmpConditions[i];
break;
}
}
//
result = IsValid(mConditions.setupTime) &&
HasDirection(mConditions.dir);
if (!result)
{
return result;
}
//
// Remove Selected Index from Main Collection ...
ArrayRemove(
mXSTRPVConditionsCollection,
selectedIndex,
1 //
);
//
// Check Signal Direction ...
isBullish = IsBullish(mConditions.dir);
isBearish = IsBearish(mConditions.dir);
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
//
// Issues Signal on Conditions ...
conditions.sl = mConditions.sl;
conditions.provider = providerStr;
conditions.signalDir = mConditions.dir;
conditions.target = mConditions.target;
//
return result;
}
//
// Private ...
private:
@@ -1015,6 +1257,9 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
x121Inputs.Default();
//
bool showAll = false;
//
x121Inputs.showRSI = false;
@@ -1035,33 +1280,40 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
x121Inputs.xpvInputs.hcPeriod = hcPeriod;
//
x121Inputs.xpvInputs.showSar = true;
x121Inputs.xpvInputs.showPeaks = true;
x121Inputs.xpvInputs.showVales = true;
x121Inputs.xpvInputs.showSar = showAll || true;
x121Inputs.xpvInputs.showPeaks = showAll || true;
x121Inputs.xpvInputs.showVales = showAll || true;
//
// XATR ...
x121Inputs.xatrInputs.showATRUpper = false;
x121Inputs.xatrInputs.showATRLower = false;
x121Inputs.xatrInputs.showATRUpper = showAll || false;
x121Inputs.xatrInputs.showATRLower = showAll || false;
//
// XSTR ...
x121Inputs.xstrInputs.showStr = true;
x121Inputs.xstrInputs.showStrUpper = false;
x121Inputs.xstrInputs.showStrLower = false;
x121Inputs.xstrInputs.showStr = showAll || true;
x121Inputs.xstrInputs.showStrUpper = showAll || false;
x121Inputs.xstrInputs.showStrLower = showAll || false;
//
// XCHE ...
x121Inputs.xcheInputs.showLE1 = showAll || true;
x121Inputs.xcheInputs.showLE2 = showAll || true;
x121Inputs.xcheInputs.showSE1 = showAll || true;
x121Inputs.xcheInputs.showSE2 = showAll || true;
//
// XDON ...
x121Inputs.xdonInputs.showOpen = false;
x121Inputs.xdonInputs.showClose = true;
x121Inputs.xdonInputs.showLow = true;
x121Inputs.xdonInputs.showHigh = true;
x121Inputs.xdonInputs.showOpen = showAll || false;
x121Inputs.xdonInputs.showClose = showAll || false;
x121Inputs.xdonInputs.showLow = showAll || false;
x121Inputs.xdonInputs.showHigh = showAll || false;
//
// XVWAP ...
x121Inputs.xvwapInputs.showVWapFast = false;
x121Inputs.xvwapInputs.showVWapMedium = false;
x121Inputs.xvwapInputs.showVWapSlow = false;
x121Inputs.xvwapInputs.showVWapFast = showAll || false;
x121Inputs.xvwapInputs.showVWapMedium = showAll || false;
x121Inputs.xvwapInputs.showVWapSlow = showAll || false;
//
// Initialize Cycle Helpers ...