last ...
This commit is contained in:
@@ -27,7 +27,6 @@
|
||||
#include "../Classes/x-121.smc.market.cycle.helper.class.mq5"
|
||||
|
||||
//
|
||||
#include "../Signals/x-121.smc.xsupdemobs.signal.class.mq5"
|
||||
#include "../Signals/x-121.smc.xwz.signal.class.mq5"
|
||||
|
||||
//
|
||||
@@ -43,9 +42,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
//
|
||||
// Props ...
|
||||
bool useXWZSignal;
|
||||
bool useXSupDemOBSSignal;
|
||||
XCX121SMCXWZSignalDetector *mXWZSignalDetector;
|
||||
XCX121SMCXSupDemOBSSignalDetector *mXSupDemOBSSignalDetector;
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
@@ -62,7 +59,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
|
||||
//
|
||||
mXWZSignalDetector = new XCX121SMCXWZSignalDetector();
|
||||
mXSupDemOBSSignalDetector = new XCX121SMCXSupDemOBSSignalDetector();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -110,12 +106,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
*/
|
||||
void Destroy() override
|
||||
{
|
||||
//
|
||||
delete mDecisionCycleHelper;
|
||||
delete mAnalyseCycleHelper;
|
||||
delete mConsolidationCycleHelper;
|
||||
delete mVisionCycleHelper;
|
||||
|
||||
//
|
||||
ZeroMemory(mDecisionCycleHelper);
|
||||
ZeroMemory(mAnalyseCycleHelper);
|
||||
@@ -123,12 +113,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
ZeroMemory(mVisionCycleHelper);
|
||||
|
||||
//
|
||||
delete mXWZSignalDetector;
|
||||
ZeroMemory(mXWZSignalDetector);
|
||||
|
||||
//
|
||||
delete mXSupDemOBSSignalDetector;
|
||||
ZeroMemory(mXSupDemOBSSignalDetector);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -208,7 +193,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
|
||||
//
|
||||
bool hasXWZSignal = false;
|
||||
bool hasXSupDemOBSSignal = false;
|
||||
|
||||
//
|
||||
// XSupDemOBS Signal ...
|
||||
@@ -223,19 +207,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
hasSignal = hasXWZSignal;
|
||||
}
|
||||
|
||||
//
|
||||
// XSupDemOBS Signal ...
|
||||
X121SMCStrategyXSupDemOBSSignalConditions mXSupDemOBSConditions;
|
||||
if (useXSupDemOBSSignal && !hasSignal)
|
||||
{
|
||||
//
|
||||
hasXSupDemOBSSignal = DetectXSupDemOBSSignal(
|
||||
conditions,
|
||||
mXSupDemOBSConditions //
|
||||
);
|
||||
hasSignal = hasXSupDemOBSSignal;
|
||||
}
|
||||
|
||||
//
|
||||
result = hasSignal;
|
||||
if (!result)
|
||||
@@ -342,18 +313,18 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
if (useXSupDemOBSSignal &&
|
||||
hasXSupDemOBSSignal)
|
||||
if (useXWZSignal &&
|
||||
hasXWZSignal)
|
||||
{
|
||||
//
|
||||
// Configuring Amount Percent and ETC ...
|
||||
bool ignoreEAVolume = mXSupDemOBSConditions.reward > 0 &&
|
||||
mXSupDemOBSConditions.amountPercent > 0;
|
||||
bool ignoreEAVolume = mXWZConditions.reward > 0 &&
|
||||
mXWZConditions.amountPercent > 0;
|
||||
if (ignoreEAVolume)
|
||||
{
|
||||
//
|
||||
double cReward = mXSupDemOBSConditions.reward;
|
||||
double cAmountPercent = mXSupDemOBSConditions.amountPercent;
|
||||
double cReward = mXWZConditions.reward;
|
||||
double cAmountPercent = mXWZConditions.amountPercent;
|
||||
|
||||
//
|
||||
double cRiskReward = risk * cReward;
|
||||
@@ -385,8 +356,8 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
// Fix Signal TP Based On Working Zone ...
|
||||
double maxAllowedTP =
|
||||
hasLong
|
||||
? mXSupDemOBSConditions.workingZone.upper
|
||||
: mXSupDemOBSConditions.workingZone.lower;
|
||||
? mXWZConditions.workingZone.upper
|
||||
: mXWZConditions.workingZone.lower;
|
||||
bool canApplyMaxAlowedTP = (hasLong &&
|
||||
signal.tp > maxAllowedTP) ||
|
||||
(!hasLong && signal.tp < maxAllowedTP);
|
||||
@@ -448,7 +419,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
}
|
||||
|
||||
//
|
||||
mXSupDemOBSConditions.Clean();
|
||||
mXWZConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -501,33 +472,9 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
false //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// XSupDemOBS Guard Detection ...
|
||||
if (useXSupDemOBSSignal)
|
||||
{
|
||||
//
|
||||
X121SMCGuard xsupDemOBSGuards[];
|
||||
bool hasGuard = mXSupDemOBSSignalDetector.DetectGuards(
|
||||
xsupDemOBSGuards,
|
||||
positions,
|
||||
mDecisionCycleHelper,
|
||||
mAnalyseCycleHelper,
|
||||
mConsolidationCycleHelper,
|
||||
mVisionCycleHelper //
|
||||
);
|
||||
|
||||
//
|
||||
if (hasGuard)
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
xsupDemOBSGuards,
|
||||
guards,
|
||||
false //
|
||||
);
|
||||
}
|
||||
Clean(xwzGuards);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -618,51 +565,11 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
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_XSUPDEMOBS;
|
||||
ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_XWZ;
|
||||
string providerStr = ToString(provider);
|
||||
|
||||
//
|
||||
@@ -813,240 +720,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XSupDemOBS Signal ...
|
||||
bool DetectXSupDemOBSSignal(
|
||||
X121SMCStrategyConditions &conditions,
|
||||
X121SMCStrategyXSupDemOBSSignalConditions &xSupDemOBSConditions //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Validate Cycle Helpers ...
|
||||
result =
|
||||
//
|
||||
mVisionCycleHelper != NULL &&
|
||||
mAnalyseCycleHelper != NULL &&
|
||||
mDecisionCycleHelper != NULL &&
|
||||
mConsolidationCycleHelper != NULL
|
||||
//
|
||||
;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
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_XSUPDEMOBS;
|
||||
string providerStr = ToString(provider);
|
||||
|
||||
//
|
||||
// Detect Setup Conditions ...
|
||||
datetime setupTime = mXSupDemOBSSignalDetector.mConditions.setupTime;
|
||||
bool isSetuped = mXSupDemOBSSignalDetector.mConditions.IsSetuped();
|
||||
ENUM_X_DIRECTION setupDir = mXSupDemOBSSignalDetector.mConditions.dir;
|
||||
if (!isSetuped)
|
||||
{
|
||||
//
|
||||
// Detect Signal Setup ...
|
||||
isSetuped = mXSupDemOBSSignalDetector.DetectSignalSetup(
|
||||
symbol,
|
||||
period,
|
||||
mDecisionCycleHelper,
|
||||
mAnalyseCycleHelper,
|
||||
mConsolidationCycleHelper,
|
||||
mVisionCycleHelper //
|
||||
);
|
||||
|
||||
//
|
||||
setupDir = mXSupDemOBSSignalDetector.mConditions.dir;
|
||||
setupTime = mXSupDemOBSSignalDetector.mConditions.setupTime;
|
||||
|
||||
//
|
||||
if (isSetuped)
|
||||
{
|
||||
//
|
||||
int items = mXSupDemOBSSignalDetector
|
||||
.AddConditionsIfNotExists();
|
||||
|
||||
//
|
||||
mXSupDemOBSSignalDetector.mConditions.Clean();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
int conditionsCount = ArraySize(mXSupDemOBSSignalDetector.mConditionsCollection);
|
||||
result = IsValidSize(conditionsCount);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Looking For Conditions ...
|
||||
int selectedIndex = 0;
|
||||
X121SMCStrategyXSupDemOBSSignalConditions mTmpConditions[];
|
||||
Copy(
|
||||
mXSupDemOBSSignalDetector.mConditionsCollection,
|
||||
mTmpConditions //
|
||||
);
|
||||
X121SMCStrategyXSupDemOBSSignalConditions 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 = mXSupDemOBSSignalDetector
|
||||
.DetectSignalTrigger(
|
||||
mTmpConditions[i],
|
||||
symbol,
|
||||
period,
|
||||
mDecisionCycleHelper,
|
||||
mAnalyseCycleHelper,
|
||||
mConsolidationCycleHelper,
|
||||
mVisionCycleHelper //
|
||||
);
|
||||
|
||||
//
|
||||
result = canTrigger;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bool isISetuped = mTmpConditions[i].IsSetuped();
|
||||
if (!isISetuped)
|
||||
{
|
||||
//
|
||||
ArrayRemove(
|
||||
mXSupDemOBSSignalDetector.mConditionsCollection,
|
||||
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(
|
||||
mXSupDemOBSSignalDetector.mConditionsCollection,
|
||||
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;
|
||||
|
||||
//
|
||||
xSupDemOBSConditions = mConditions;
|
||||
|
||||
//
|
||||
mConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
@@ -1063,7 +736,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
{
|
||||
//
|
||||
useXWZSignal = true;
|
||||
useXSupDemOBSSignal = false;
|
||||
|
||||
//
|
||||
string symbol = GetSymbol();
|
||||
|
||||
Reference in New Issue
Block a user