last ...
This commit is contained in:
@@ -35,8 +35,8 @@
|
||||
const string X121SMCStrategyToken = "X121SMC";
|
||||
|
||||
//
|
||||
const string X121SMCXToken = "X121X";
|
||||
const string X121SMCXOBSToken = "X121XOBS";
|
||||
const string X121SMCXSupDemOBSToken = "X121XSupDemOBS";
|
||||
|
||||
//
|
||||
// X121 SMC Providers ...
|
||||
@@ -44,8 +44,8 @@ enum ENUM_X_121_SMC_PROVIDERS
|
||||
{
|
||||
//
|
||||
X_121_SMC_PROVIDER_NONE,
|
||||
X_121_SMC_PROVIDER_X,
|
||||
X_121_SMC_PROVIDER_XOBS,
|
||||
X_121_SMC_PROVIDER_XSUPDEMOBS,
|
||||
};
|
||||
|
||||
//
|
||||
@@ -709,8 +709,8 @@ string ToString(ENUM_X_121_SMC_PROVIDERS value)
|
||||
switch (value)
|
||||
{
|
||||
//
|
||||
case X_121_SMC_PROVIDER_X:
|
||||
result = X121SMCXToken;
|
||||
case X_121_SMC_PROVIDER_XSUPDEMOBS:
|
||||
result = X121SMCXSupDemOBSToken;
|
||||
break;
|
||||
|
||||
//
|
||||
@@ -742,9 +742,9 @@ ENUM_X_121_SMC_PROVIDERS ParseProvider(string value)
|
||||
}
|
||||
|
||||
//
|
||||
if (Contains(X121SMCXToken, value))
|
||||
if (Contains(X121SMCXSupDemOBSToken, value))
|
||||
{
|
||||
result = X_121_SMC_PROVIDER_X;
|
||||
result = X_121_SMC_PROVIDER_XSUPDEMOBS;
|
||||
}
|
||||
else if (Contains(X121SMCXOBSToken, value))
|
||||
{
|
||||
|
||||
@@ -680,77 +680,141 @@ bool DetectX121SMCXOBSSignalSetup(
|
||||
UpdateTo(conditions.validBullishOBs);
|
||||
UpdateTo(conditions.validBearishOBs);
|
||||
|
||||
//
|
||||
DrawX121SMCXOBSConditions(
|
||||
conditions,
|
||||
drawer //
|
||||
);
|
||||
|
||||
//
|
||||
DrawX121SMCXOBSPOIs(
|
||||
visionState,
|
||||
drawer //
|
||||
);
|
||||
|
||||
//
|
||||
DrawX121SMCXOBSPOIs(
|
||||
consolidationState,
|
||||
drawer //
|
||||
);
|
||||
|
||||
//
|
||||
// Lookup for new Order Block ...
|
||||
// for Clearing Conditions ....
|
||||
|
||||
//
|
||||
XCOrderBlock *newBullishOB = NULL;
|
||||
bool hasNewBullishOB = Contains(
|
||||
X_BULLISH_ORDERBLOCK_DETECTED,
|
||||
consolidationPoiEvents //
|
||||
);
|
||||
if (hasNewBullishOB)
|
||||
{
|
||||
//
|
||||
int hasOBs = consolidationState.HasBullishOrderBlocks();
|
||||
int count = consolidationState.CountBullishOrderBlocks();
|
||||
if (hasOBs)
|
||||
{
|
||||
//
|
||||
newBullishOB = consolidationState.bullishOrderBlocks[count - 1];
|
||||
}
|
||||
|
||||
//
|
||||
hasNewBullishOB = newBullishOB != NULL &&
|
||||
newBullishOB.IsValid();
|
||||
}
|
||||
|
||||
//
|
||||
XCOrderBlock *newBearishOB = NULL;
|
||||
bool hasNewBearishOB = Contains(
|
||||
X_BEARISH_ORDERBLOCK_DETECTED,
|
||||
consolidationPoiEvents //
|
||||
);
|
||||
if (hasNewBearishOB)
|
||||
{
|
||||
//
|
||||
int hasOBs = consolidationState.HasBearishOrderBlocks();
|
||||
int count = consolidationState.CountBearishOrderBlocks();
|
||||
if (hasOBs)
|
||||
{
|
||||
newBearishOB = consolidationState.bearishOrderBlocks[count - 1];
|
||||
}
|
||||
|
||||
//
|
||||
hasNewBearishOB = newBearishOB != NULL &&
|
||||
newBearishOB.IsValid();
|
||||
}
|
||||
|
||||
//
|
||||
bool isNewOBDetected = hasNewBullishOB ||
|
||||
hasNewBearishOB;
|
||||
if (isNewOBDetected)
|
||||
if (hasYoungestOB)
|
||||
{
|
||||
//
|
||||
XCOrderBlock *newBullishOB = NULL;
|
||||
bool hasNewBullishOB = Contains(
|
||||
X_BULLISH_ORDERBLOCK_DETECTED,
|
||||
consolidationPoiEvents //
|
||||
);
|
||||
if (hasNewBullishOB)
|
||||
{
|
||||
//
|
||||
DrawX121SMCXOBSOrderBlock(
|
||||
newBullishOB,
|
||||
consolidationCycleHelper.mPOIDrawer //
|
||||
);
|
||||
int hasOBs = consolidationState.HasBullishOrderBlocks();
|
||||
int count = consolidationState.CountBullishOrderBlocks();
|
||||
if (hasOBs)
|
||||
{
|
||||
//
|
||||
newBullishOB = consolidationState.bullishOrderBlocks[count - 1];
|
||||
}
|
||||
|
||||
//
|
||||
hasNewBullishOB = newBullishOB != NULL &&
|
||||
newBullishOB.IsValid();
|
||||
}
|
||||
|
||||
//
|
||||
XCOrderBlock *newBearishOB = NULL;
|
||||
bool hasNewBearishOB = Contains(
|
||||
X_BEARISH_ORDERBLOCK_DETECTED,
|
||||
consolidationPoiEvents //
|
||||
);
|
||||
if (hasNewBearishOB)
|
||||
{
|
||||
//
|
||||
DrawX121SMCXOBSOrderBlock(
|
||||
newBearishOB,
|
||||
consolidationCycleHelper.mPOIDrawer //
|
||||
);
|
||||
int hasOBs = consolidationState.HasBearishOrderBlocks();
|
||||
int count = consolidationState.CountBearishOrderBlocks();
|
||||
if (hasOBs)
|
||||
{
|
||||
newBearishOB = consolidationState.bearishOrderBlocks[count - 1];
|
||||
}
|
||||
|
||||
//
|
||||
hasNewBearishOB = newBearishOB != NULL &&
|
||||
newBearishOB.IsValid();
|
||||
}
|
||||
|
||||
//
|
||||
bool isNewOBDetected = hasNewBullishOB ||
|
||||
hasNewBearishOB;
|
||||
if (isNewOBDetected)
|
||||
{
|
||||
//
|
||||
if (hasNewBullishOB)
|
||||
{
|
||||
//
|
||||
DrawX121SMCXOBSOrderBlock(
|
||||
newBullishOB,
|
||||
drawer //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
if (hasNewBearishOB)
|
||||
{
|
||||
//
|
||||
DrawX121SMCXOBSOrderBlock(
|
||||
newBearishOB,
|
||||
drawer //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Check Conditions ...
|
||||
if (isNewOBDetected)
|
||||
{
|
||||
//
|
||||
bool isSameOB = false;
|
||||
|
||||
//
|
||||
if (hasNewBullishOB &&
|
||||
hasYoungestBullishOB)
|
||||
{
|
||||
//
|
||||
isSameOB = IsSame(
|
||||
newBullishOB,
|
||||
conditions.youngestBullishOB //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
if (!isSameOB &&
|
||||
hasNewBearishOB &&
|
||||
hasYoungestBearishOB)
|
||||
{
|
||||
//
|
||||
isSameOB = IsSame(
|
||||
newBearishOB,
|
||||
conditions.youngestBearishOB //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
if (!isSameOB)
|
||||
{
|
||||
//
|
||||
result = false;
|
||||
conditions.Clean();
|
||||
mX121SMCXOBSObjects.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1104,12 +1168,6 @@ bool DetectX121SMCXOBSSignalSetup(
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
DrawX121SMCXOBSConditions(
|
||||
conditions,
|
||||
visionCycleHelper.mPOIDrawer //
|
||||
);
|
||||
|
||||
//
|
||||
return false;
|
||||
|
||||
@@ -1536,7 +1594,7 @@ bool DetectX121SMCXOBSGuards(
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
string provider = ToString(X_121_SMC_PROVIDER_X);
|
||||
string provider = ToString(X_121_SMC_PROVIDER_XOBS);
|
||||
|
||||
//
|
||||
result = DetectX121SMCGuards(
|
||||
@@ -1855,3 +1913,165 @@ void DrawX121SMCXOBSConditions(
|
||||
}
|
||||
|
||||
//
|
||||
void DrawX121SMCXOBSPOIs(
|
||||
XPOIState &state,
|
||||
XCPOIDrawer *drawer //
|
||||
)
|
||||
{
|
||||
//
|
||||
if (!state.IsValid() &&
|
||||
drawer == NULL &&
|
||||
!state.HasChild())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
bool hasSupplyZones = state.HasSupplyZones();
|
||||
int supplyZonesCount = state.CountSupplyZones();
|
||||
if (hasSupplyZones)
|
||||
{
|
||||
//
|
||||
int idx = GetHighest(state.supplyZones);
|
||||
if (IsValidIndex(idx))
|
||||
{
|
||||
//
|
||||
XCSupplyZone *iZone = state.supplyZones[idx];
|
||||
|
||||
//
|
||||
iZone.To(TimeCurrent());
|
||||
|
||||
//
|
||||
XCSupplyZoneObject *iObj;
|
||||
bool isCreated = drawer.CreateSupplyZone(
|
||||
iZone,
|
||||
iObj //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
iObj.ZoneColor(clrRed);
|
||||
mX121SMCXOBSObjects.Add(iObj);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// for (int i = 0; i < supplyZonesCount; i++)
|
||||
// {
|
||||
// //
|
||||
// XCSupplyZone *iZone = state.supplyZones[i];
|
||||
|
||||
// //
|
||||
// iZone.To(TimeCurrent());
|
||||
|
||||
// //
|
||||
// XCSupplyZoneObject *iObj;
|
||||
// bool isCreated = drawer.CreateSupplyZone(
|
||||
// iZone,
|
||||
// iObj //
|
||||
// );
|
||||
// if (isCreated)
|
||||
// {
|
||||
// iObj.ZoneColor(clrRed);
|
||||
// mX121SMCXOBSObjects.Add(iObj);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
//
|
||||
bool hasDemandZones = state.HasDemandZones();
|
||||
int demandZonesCount = state.CountDemandZones();
|
||||
if (hasDemandZones)
|
||||
{
|
||||
int idx = GetLowest(state.demandZones);
|
||||
if (IsValidIndex(idx))
|
||||
{
|
||||
//
|
||||
XCDemandZone *iZone = state.demandZones[idx];
|
||||
|
||||
//
|
||||
iZone.To(TimeCurrent());
|
||||
|
||||
//
|
||||
XCDemandZoneObject *iObj;
|
||||
bool isCreated = drawer.CreateDemandZone(
|
||||
iZone,
|
||||
iObj //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
iObj.ZoneColor(clrLime);
|
||||
mX121SMCXOBSObjects.Add(iObj);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// for (int i = 0; i < demandZonesCount; i++)
|
||||
// {
|
||||
// //
|
||||
// XCDemandZone *iZone = state.demandZones[i];
|
||||
|
||||
// //
|
||||
// iZone.To(TimeCurrent());
|
||||
|
||||
// //
|
||||
// XCDemandZoneObject *iObj;
|
||||
// bool isCreated = drawer.CreateDemandZone(
|
||||
// iZone,
|
||||
// iObj //
|
||||
// );
|
||||
// if (isCreated)
|
||||
// {
|
||||
// //
|
||||
// iObj.ZoneColor(clrLime);
|
||||
// mX121SMCXOBSObjects.Add(iObj);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
//
|
||||
// bool hasBullishOrderBlocks = state.HasBullishOrderBlocks();
|
||||
// int bullishOrderBlocksCount = state.CountBullishOrderBlocks();
|
||||
// if (hasBullishOrderBlocks)
|
||||
// {
|
||||
// //
|
||||
// for (int i = 0; i < bullishOrderBlocksCount; i++)
|
||||
// {
|
||||
// //
|
||||
// XCOrderBlock *iZone = state.bullishOrderBlocks[i];
|
||||
|
||||
// //
|
||||
// iZone.To(TimeCurrent());
|
||||
|
||||
// //
|
||||
// DrawX121SMCXOBSOrderBlock(
|
||||
// iZone,
|
||||
// drawer //
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
// bool hasBearishOrderBlocks = state.HasBearishOrderBlocks();
|
||||
// int bearishOrderBlocksCount = state.CountBearishOrderBlocks();
|
||||
// if (hasBearishOrderBlocks)
|
||||
// {
|
||||
// //
|
||||
// for (int i = 0; i < bearishOrderBlocksCount; i++)
|
||||
// {
|
||||
// //
|
||||
// XCOrderBlock *iZone = state.bearishOrderBlocks[i];
|
||||
|
||||
// //
|
||||
// iZone.To(TimeCurrent());
|
||||
|
||||
// //
|
||||
// DrawX121SMCXOBSOrderBlock(
|
||||
// iZone,
|
||||
// drawer //
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -27,8 +27,8 @@
|
||||
#include "../Classes/x-121.smc.market.cycle.helper.class.mq5"
|
||||
|
||||
//
|
||||
#include "../Signals/x-121.smc.x.signal.lib.mq5"
|
||||
#include "../Signals/x-121.smc.xobs.signal.lib.mq5"
|
||||
#include "../Signals/x-121.smc.xsupdemobs.signal.lib.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
@@ -42,8 +42,8 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
bool useXSignal;
|
||||
bool useXOBSSignal;
|
||||
bool useXSupDemOBSSignal;
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
@@ -104,8 +104,8 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
void Destroy() override
|
||||
{
|
||||
//
|
||||
Clean(mXConditionsCollection);
|
||||
Clean(mX121SMCXOBSConditionsCollection);
|
||||
Clean(mX121SMCXSupDemOBSConditionsCollection);
|
||||
|
||||
//
|
||||
ZeroMemory(mTriggerCycleHelper);
|
||||
@@ -200,17 +200,8 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
bool hasSignal = false;
|
||||
|
||||
//
|
||||
bool hasXSignal = false;
|
||||
bool hasXOBSSignal = false;
|
||||
|
||||
//
|
||||
// X Signal ...
|
||||
if (useXSignal && !hasSignal)
|
||||
{
|
||||
//
|
||||
hasXSignal = DetectXSignal(conditions);
|
||||
hasSignal = hasXSignal;
|
||||
}
|
||||
bool hasXSupDemOBSSignal = false;
|
||||
|
||||
//
|
||||
// XOBS Signal ...
|
||||
@@ -221,6 +212,15 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
hasSignal = hasXOBSSignal;
|
||||
}
|
||||
|
||||
//
|
||||
// XSupDemOBS Signal ...
|
||||
if (useXSupDemOBSSignal && !hasSignal)
|
||||
{
|
||||
//
|
||||
hasXSupDemOBSSignal = DetectXSupDemOBSSignal(conditions);
|
||||
hasSignal = hasXSupDemOBSSignal;
|
||||
}
|
||||
|
||||
//
|
||||
result = hasSignal;
|
||||
if (!result)
|
||||
@@ -377,11 +377,11 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
}
|
||||
|
||||
//
|
||||
// X Guard Detection ...
|
||||
if (useXSignal)
|
||||
// XOBS Guard Detection ...
|
||||
if (useXOBSSignal)
|
||||
{
|
||||
//
|
||||
bool hasGuard = DetectX121SMCXGuards(
|
||||
bool hasGuard = DetectX121SMCXOBSGuards(
|
||||
guards,
|
||||
positions,
|
||||
mTriggerCycleHelper,
|
||||
@@ -394,11 +394,11 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
}
|
||||
|
||||
//
|
||||
// XOBS Guard Detection ...
|
||||
if (useXOBSSignal)
|
||||
// XSupDemOBS Guard Detection ...
|
||||
if (useXSupDemOBSSignal)
|
||||
{
|
||||
//
|
||||
bool hasGuard = DetectX121SMCXOBSGuards(
|
||||
bool hasGuard = DetectX121SMCXSupDemOBSGuards(
|
||||
guards,
|
||||
positions,
|
||||
mTriggerCycleHelper,
|
||||
@@ -448,241 +448,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
//
|
||||
// Signalling Functions ...
|
||||
|
||||
//
|
||||
// X Signal ...
|
||||
bool DetectXSignal(
|
||||
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_X;
|
||||
string providerStr = ToString(provider);
|
||||
|
||||
//
|
||||
// Detect Setup Conditions ...
|
||||
datetime setupTime = mXConditions.setupTime;
|
||||
bool isSetuped = mXConditions.IsSetuped();
|
||||
ENUM_X_DIRECTION setupDir = mXConditions.dir;
|
||||
if (!isSetuped)
|
||||
{
|
||||
//
|
||||
// Detect Signal Setup ...
|
||||
isSetuped = DetectX121SMCXSignalSetup(
|
||||
symbol,
|
||||
period,
|
||||
mXConditions,
|
||||
mTriggerCycleHelper,
|
||||
mDecisionCycleHelper,
|
||||
mAnalyseCycleHelper,
|
||||
mVerificationCycleHelper,
|
||||
mConsolidationCycleHelper,
|
||||
mVisionCycleHelper //
|
||||
);
|
||||
|
||||
//
|
||||
setupDir = mXConditions.dir;
|
||||
setupTime = mXConditions.setupTime;
|
||||
|
||||
// //
|
||||
// bool hasPivot = mXConditions.pivotZone.IsValid();
|
||||
// if (hasPivot)
|
||||
// {
|
||||
// //
|
||||
// XCBaseObject *drawnObjects[];
|
||||
// int drawnCount = DrawX121SMCXConditions(
|
||||
// mXConditions,
|
||||
// drawnObjects,
|
||||
// mPOIDrawer //
|
||||
// );
|
||||
// if (IsValidSize(drawnCount))
|
||||
// {
|
||||
// AddObjectsIfNotExists(drawnObjects);
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
if (isSetuped)
|
||||
{
|
||||
//
|
||||
int items = AddX121SMCXConditionsIfNotExists(
|
||||
mXConditions,
|
||||
mXConditionsCollection //
|
||||
);
|
||||
|
||||
//
|
||||
mXConditions.Clean();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
int conditionsCount = ArraySize(mXConditionsCollection);
|
||||
result = IsValidSize(conditionsCount);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Looking For Conditions ...
|
||||
int selectedIndex = 0;
|
||||
X121SMCStrategyXSignalConditions mTmpConditions[];
|
||||
Copy(
|
||||
mXConditionsCollection,
|
||||
mTmpConditions //
|
||||
);
|
||||
X121SMCStrategyXSignalConditions 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 = DetectX121SMCXSignalTrigger(
|
||||
mTmpConditions[i],
|
||||
symbol,
|
||||
period,
|
||||
mTriggerCycleHelper,
|
||||
mDecisionCycleHelper,
|
||||
mAnalyseCycleHelper,
|
||||
mVerificationCycleHelper,
|
||||
mConsolidationCycleHelper,
|
||||
mVisionCycleHelper //
|
||||
);
|
||||
|
||||
//
|
||||
result = canTrigger;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bool isISetuped = mTmpConditions[i].IsSetuped();
|
||||
if (!isISetuped)
|
||||
{
|
||||
//
|
||||
ArrayRemove(
|
||||
mXConditionsCollection,
|
||||
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(
|
||||
mXConditionsCollection,
|
||||
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;
|
||||
}
|
||||
|
||||
//
|
||||
// XOBS Signal ...
|
||||
bool DetectXOBSSignal(
|
||||
@@ -901,6 +666,225 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XSupDemOBS Signal ...
|
||||
bool DetectXSupDemOBSSignal(
|
||||
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_XSUPDEMOBS;
|
||||
string providerStr = ToString(provider);
|
||||
|
||||
//
|
||||
// Detect Setup Conditions ...
|
||||
datetime setupTime = mX121SMCXSupDemOBSConditions.setupTime;
|
||||
bool isSetuped = mX121SMCXSupDemOBSConditions.IsSetuped();
|
||||
ENUM_X_DIRECTION setupDir = mX121SMCXSupDemOBSConditions.dir;
|
||||
if (!isSetuped)
|
||||
{
|
||||
//
|
||||
// Detect Signal Setup ...
|
||||
isSetuped = DetectX121SMCXSupDemOBSSignalSetup(
|
||||
symbol,
|
||||
period,
|
||||
mX121SMCXSupDemOBSConditions,
|
||||
mTriggerCycleHelper,
|
||||
mDecisionCycleHelper,
|
||||
mAnalyseCycleHelper,
|
||||
mVerificationCycleHelper,
|
||||
mConsolidationCycleHelper,
|
||||
mVisionCycleHelper //
|
||||
);
|
||||
|
||||
//
|
||||
setupDir = mX121SMCXSupDemOBSConditions.dir;
|
||||
setupTime = mX121SMCXSupDemOBSConditions.setupTime;
|
||||
|
||||
//
|
||||
if (isSetuped)
|
||||
{
|
||||
//
|
||||
int items = AddX121SMCXSupDemOBSConditionsIfNotExists(
|
||||
mX121SMCXSupDemOBSConditions,
|
||||
mX121SMCXSupDemOBSConditionsCollection //
|
||||
);
|
||||
|
||||
//
|
||||
mX121SMCXSupDemOBSConditions.Clean();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
int conditionsCount = ArraySize(mX121SMCXSupDemOBSConditionsCollection);
|
||||
result = IsValidSize(conditionsCount);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Looking For Conditions ...
|
||||
int selectedIndex = 0;
|
||||
X121SMCStrategyXSupDemOBSSignalConditions mTmpConditions[];
|
||||
Copy(
|
||||
mX121SMCXSupDemOBSConditionsCollection,
|
||||
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 = DetectX121SMCXSupDemOBSSignalTrigger(
|
||||
mTmpConditions[i],
|
||||
symbol,
|
||||
period,
|
||||
mTriggerCycleHelper,
|
||||
mDecisionCycleHelper,
|
||||
mAnalyseCycleHelper,
|
||||
mVerificationCycleHelper,
|
||||
mConsolidationCycleHelper,
|
||||
mVisionCycleHelper //
|
||||
);
|
||||
|
||||
//
|
||||
result = canTrigger;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bool isISetuped = mTmpConditions[i].IsSetuped();
|
||||
if (!isISetuped)
|
||||
{
|
||||
//
|
||||
ArrayRemove(
|
||||
mX121SMCXSupDemOBSConditionsCollection,
|
||||
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(
|
||||
mX121SMCXSupDemOBSConditionsCollection,
|
||||
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:
|
||||
@@ -916,8 +900,8 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
void InitialHelpers()
|
||||
{
|
||||
//
|
||||
useXSignal = false;
|
||||
useXOBSSignal = true;
|
||||
useXOBSSignal = false;
|
||||
useXSupDemOBSSignal = true;
|
||||
|
||||
//
|
||||
string symbol = GetSymbol();
|
||||
|
||||
Reference in New Issue
Block a user