This commit is contained in:
2025-01-10 18:48:58 +03:30
parent c7133ea3d7
commit c6cfd9b115
4 changed files with 538 additions and 186 deletions
+279 -10
View File
@@ -29,6 +29,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"
//
// Definitions ...
@@ -184,11 +185,13 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
bool useTestSignal = false;
bool useXOBGPVSignal = true;
bool useXOBGPVSignal = false;
bool useXOBSPVSignal = true;
//
bool hasTestSignal = false;
bool hasXOBGPVSignal = false;
bool hasXOBSPVSignal = false;
//
// Test Signal ...
@@ -208,6 +211,15 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
hasSignal = hasXOBGPVSignal;
}
//
// XOBSPV Signal ...
if (useXOBSPVSignal && !hasSignal)
{
//
hasXOBSPVSignal = DetectXOBSPVSignal(conditions);
hasSignal = hasXOBSPVSignal;
}
//
result = hasSignal;
if (!result)
@@ -477,8 +489,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
// XOBGPV Signal ...
X121SMCStrategyXOBGPVSignalConditions mXOBGPVConditions;
X121SMCStrategyXOBGPVSignalConditions mXOBGPVConditionsCollection[];
bool DetectXOBGPVSignal(
X121SMCStrategyConditions &conditions //
)
@@ -736,6 +746,265 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
return result;
}
//
// XOBSPV Signal ...
bool DetectXOBSPVSignal(
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_XOBSPV;
string providerStr = ToString(provider);
//
// Detect Setup Conditions ...
datetime setupTime = mXOBSPVConditions.setupTime;
bool isSetuped = mXOBSPVConditions.IsSetuped();
ENUM_X_DIRECTION setupDir = mXOBSPVConditions.dir;
if (!isSetuped)
{
//
// Detect Signal Setup ...
isSetuped = DetectX121SMCXOBSPVSiganlSetup(
symbol,
period,
mXOBSPVConditions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
setupDir = mXOBSPVConditions.dir;
setupTime = mXOBSPVConditions.setupTime;
//
if (isSetuped)
{
//
int items = AddX121SMCXOBSPVConditionsIfNotExists(
mXOBSPVConditions,
mXOBSPVConditionsCollection //
);
//
mXOBSPVConditions.Clean();
}
}
//
int conditionsCount = ArraySize(mXOBSPVConditionsCollection);
result = IsValidSize(conditionsCount);
if (!result)
{
return result;
}
//
// Looking For Conditions ...
int selectedIndex = 0;
X121SMCStrategyXOBSPVSignalConditions mTmpConditions[];
Copy(
mXOBSPVConditionsCollection,
mTmpConditions //
);
X121SMCStrategyXOBSPVSignalConditions mConditions;
for (int i = 0; i < conditionsCount; i++)
{
//
// Update Conditions ...
// mTmpConditions[i].UpdateOrderBlocks();
//
// Retrieve Required Data ...
// ENUM_X_DIRECTION iDir = mTmpConditions[i].dir;
// bool isIBullish = IsBullish(iDir);
// double iUpper = 0;
// double iLower = 0;
// bool iHasBoundary = mTmpConditions[i].fvgOB.GetBoundary(
// iUpper,
// iLower //
// );
// if (!iHasBoundary)
// {
// continue;
// }
//
// Draw Conditions ...
//
// XFVGOrderBlock iFVGOB = mTmpConditions[i].fvgOB;
// XCBaseObject *drawnObjects[];
// mPOIDrawer.DrawFVGOrderBlock(
// iFVGOB,
// drawnObjects //
// );
// AddObjectsIfNotExists(drawnObjects);
//
// Check Broken Order Blocks and Remove them ...
// bool isBreaked =
// isBullish
// ? (cBar.high < iLower ||
// pBar.high < iLower)
// : (cBar.low > iUpper ||
// cBar.low > iUpper);
// if (isBreaked)
// {
// //
// ArrayRemove(
// mXOBSPVConditionsCollection,
// i,
// 1 //
// );
// //
// continue;
// }
//
// Check Triggers ...
bool canTrigger = mTmpConditions[i].CanTrigger();
datetime triggerTime = mTmpConditions[i].triggerTime;
if (!canTrigger)
{
//
// Detect Signal Trigger ...
canTrigger = DetectX121SMCXOBSPVSiganlTrigger(
mTmpConditions[i],
symbol,
period,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
result = canTrigger;
if (!result)
{
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(
mXOBSPVConditionsCollection,
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:
@@ -813,14 +1082,14 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
// XATR ...
x121Inputs.xatrInputs.showATRUpper = false;
x121Inputs.xatrInputs.showATRLower = false;
x121Inputs.xatrInputs.showATRUpper = true;
x121Inputs.xatrInputs.showATRLower = true;
//
// XSTR ...
x121Inputs.xstrInputs.showStr = true;
x121Inputs.xstrInputs.showStrUpper = false;
x121Inputs.xstrInputs.showStrLower = false;
x121Inputs.xstrInputs.showStrUpper = true;
x121Inputs.xstrInputs.showStrLower = true;
//
// XDON ...
@@ -831,9 +1100,9 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
// XVWAP ...
x121Inputs.xvwapInputs.showVWapFast = false;
x121Inputs.xvwapInputs.showVWapMedium = false;
x121Inputs.xvwapInputs.showVWapSlow = false;
x121Inputs.xvwapInputs.showVWapFast = true;
x121Inputs.xvwapInputs.showVWapMedium = true;
x121Inputs.xvwapInputs.showVWapSlow = true;
//
// Initialize Cycle Helpers ...