Updte Clean method for Use ZeroMemory on Collections ...

This commit is contained in:
2025-02-01 19:41:39 +03:30
parent 43837bcf16
commit 8c7bdfa9fa
24 changed files with 3816 additions and 248 deletions
+504 -6
View File
@@ -28,8 +28,10 @@
//
#include "../Signals/x-121.smc.x.signal.lib.mq5"
#include "../Signals/x-121.smc.xobs.signal.lib.mq5"
#include "../Signals/x-121.smc.xhkpv.signal.lib.mq5"
#include "../Signals/x-121.smc.xobpv.signal.lib.mq5"
#include "../Signals/x-121.smc.xiobpv.signal.lib.mq5"
//
// Definitions ...
@@ -44,8 +46,10 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
// Props ...
bool useXSignal;
bool useXOBSSignal;
bool useXHKPVSignal;
bool useXOBPVSignal;
bool useXIOBPVSignal;
//
// Constructor(s) ...
@@ -68,9 +72,11 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
Destroy();
//
ArrayFree(mXConditionsCollection);
ArrayFree(mXHKPVConditionsCollection);
ArrayFree(mXOBPVConditionsCollection);
Clean(mXConditionsCollection);
Clean(mXOBSConditionsCollection);
Clean(mXHKPVConditionsCollection);
Clean(mXOBPVConditionsCollection);
Clean(mXIOBPVConditionsCollection);
}
//
@@ -197,8 +203,10 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
bool hasXSignal = false;
bool hasXOBSSignal = false;
bool hasXHKPVSignal = false;
bool hasXOBPVSignal = false;
bool hasXIOBPVSignal = false;
//
// X Signal ...
@@ -209,6 +217,15 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
hasSignal = hasXSignal;
}
//
// XOBS Signal ...
if (useXOBSSignal && !hasSignal)
{
//
hasXOBSSignal = DetectXOBSSignal(conditions);
hasSignal = hasXOBSSignal;
}
//
// XHKPV Signal ...
if (useXHKPVSignal && !hasSignal)
@@ -227,6 +244,15 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
hasSignal = hasXOBPVSignal;
}
//
// XIOBPV Signal ...
if (useXIOBPVSignal && !hasSignal)
{
//
hasXIOBPVSignal = DetectXIOBPVSignal(conditions);
hasSignal = hasXIOBPVSignal;
}
//
result = hasSignal;
if (!result)
@@ -399,6 +425,23 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
);
}
//
// XOBS Guard Detection ...
if (useXOBSSignal)
{
//
bool hasGuard = DetectX121SMCXOBSGuards(
guards,
positions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
}
//
// XHKPV Guard Detection ...
if (useXHKPVSignal)
@@ -417,7 +460,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
}
//
// XPZ Guard Detection ...
// XOBPV Guard Detection ...
if (useXOBPVSignal)
{
//
@@ -433,6 +476,23 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
);
}
//
// XIOBPV Guard Detection ...
if (useXIOBPVSignal)
{
//
bool hasGuard = DetectX121SMCXIOBPVGuards(
guards,
positions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
}
//
count = ArraySize(guards);
result = IsValidSize(count);
@@ -706,6 +766,224 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
return result;
}
//
// XOBS Signal ...
bool DetectXOBSSignal(
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_XOBS;
string providerStr = ToString(provider);
//
// Detect Setup Conditions ...
datetime setupTime = mXOBSConditions.setupTime;
bool isSetuped = mXOBSConditions.IsSetuped();
ENUM_X_DIRECTION setupDir = mXOBSConditions.dir;
if (!isSetuped)
{
//
// Detect Signal Setup ...
isSetuped = DetectX121SMCXOBSSignalSetup(
symbol,
period,
mXOBSConditions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
setupDir = mXOBSConditions.dir;
setupTime = mXOBSConditions.setupTime;
//
if (isSetuped)
{
//
int items = AddX121SMCXOBSConditionsIfNotExists(
mXOBSConditions,
mXOBSConditionsCollection //
);
//
mXOBSConditions.Clean();
}
}
//
int conditionsCount = ArraySize(mXOBSConditionsCollection);
result = IsValidSize(conditionsCount);
if (!result)
{
return result;
}
//
// Looking For Conditions ...
int selectedIndex = 0;
X121SMCStrategyXOBSSignalConditions mTmpConditions[];
Copy(
mXOBSConditionsCollection,
mTmpConditions //
);
X121SMCStrategyXOBSSignalConditions 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 = DetectX121SMCXOBSSignalTrigger(
mTmpConditions[i],
symbol,
period,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
result = canTrigger;
if (!result)
{
//
bool isISetuped = mTmpConditions[i].IsSetuped();
if (!isISetuped)
{
//
ArrayRemove(
mXOBSConditionsCollection,
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(
mXOBSConditionsCollection,
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;
}
//
// XHKPV Signal ...
bool DetectXHKPVSignal(
@@ -1142,6 +1420,224 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
return result;
}
//
// XIOBPV Signal ...
bool DetectXIOBPVSignal(
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_XIOBPV;
string providerStr = ToString(provider);
//
// Detect Setup Conditions ...
datetime setupTime = mXIOBPVConditions.setupTime;
bool isSetuped = mXIOBPVConditions.IsSetuped();
ENUM_X_DIRECTION setupDir = mXIOBPVConditions.dir;
if (!isSetuped)
{
//
// Detect Signal Setup ...
isSetuped = DetectX121SMCXIOBPVSignalSetup(
symbol,
period,
mXIOBPVConditions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
setupDir = mXIOBPVConditions.dir;
setupTime = mXIOBPVConditions.setupTime;
//
if (isSetuped)
{
//
int items = AddX121SMCXIOBPVConditionsIfNotExists(
mXIOBPVConditions,
mXIOBPVConditionsCollection //
);
//
mXIOBPVConditions.Clean();
}
}
//
int conditionsCount = ArraySize(mXIOBPVConditionsCollection);
result = IsValidSize(conditionsCount);
if (!result)
{
return result;
}
//
// Looking For Conditions ...
int selectedIndex = 0;
X121SMCStrategyXIOBPVSignalConditions mTmpConditions[];
Copy(
mXIOBPVConditionsCollection,
mTmpConditions //
);
X121SMCStrategyXIOBPVSignalConditions 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 = DetectX121SMCXIOBPVSignalTrigger(
mTmpConditions[i],
symbol,
period,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
result = canTrigger;
if (!result)
{
//
bool isISetuped = mTmpConditions[i].IsSetuped();
if (!isISetuped)
{
//
ArrayRemove(
mXIOBPVConditionsCollection,
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(
mXIOBPVConditionsCollection,
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:
@@ -1158,8 +1654,10 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
{
//
useXSignal = false;
useXHKPVSignal = true;
useXOBPVSignal = true;
useXOBSSignal = true;
useXHKPVSignal = false;
useXOBPVSignal = false;
useXIOBPVSignal = false;
//
string symbol = GetSymbol();