This commit is contained in:
2025-02-04 03:33:59 +03:30
parent 6984b8365f
commit 7e32ebab82
20 changed files with 31271 additions and 12329 deletions
+4 -578
View File
@@ -54,10 +54,6 @@ struct X121SMCStrategyXSignalConditions
double pivot;
double point;
//
XCOrderBlock *bullishOBs[];
XCOrderBlock *bearishOBs[];
//
// Constructor ...
X121SMCStrategyXSignalConditions()
@@ -180,34 +176,6 @@ struct X121SMCStrategyXSignalConditions
point = 0;
//
Clean(bullishOBs);
Clean(bearishOBs);
//
}
//
int CountBullishOBs()
{
return ArraySize(bullishOBs);
}
//
bool HasBullishOBs()
{
return IsValidSize(CountBullishOBs());
}
//
int CountBearishOBs()
{
return ArraySize(bearishOBs);
}
//
bool HasBearishOBs()
{
return IsValidSize(CountBearishOBs());
}
//
@@ -434,69 +402,6 @@ bool DetectX121SMCXSignalSetup(
//
// Setup Conditions ...
//
// Detect Trend ...
//
// Consolidation ...
ENUM_X_DIRECTION consolidationTrendDir;
bool hasConsolidationTrend =
consolidationCycleHelper
.DetectMarketStructure(
consolidationTrendDir //
);
bool hasConsolidationBullishTrend =
hasConsolidationTrend &&
IsBullish(consolidationTrendDir);
bool hasConsolidationBearishTrend =
hasConsolidationTrend &&
IsBearish(consolidationTrendDir);
//
// Verification ...
ENUM_X_DIRECTION verificationTrendDir;
bool hasVerificationTrend =
verificationCycleHelper
.DetectMarketStructure(
verificationTrendDir //
);
bool hasVerificationBullishTrend =
hasVerificationTrend &&
IsBullish(verificationTrendDir);
bool hasVerificationBearishTrend =
hasVerificationTrend &&
IsBearish(verificationTrendDir);
//
// Analyse ...
ENUM_X_DIRECTION analyseTrendDir;
bool hasAnalyseTrend =
analyseCycleHelper
.DetectMarketStructure(
analyseTrendDir //
);
bool hasAnalyseBullishTrend =
hasAnalyseTrend &&
IsBullish(analyseTrendDir);
bool hasAnalyseBearishTrend =
hasAnalyseTrend &&
IsBearish(analyseTrendDir);
//
// Decision ...
ENUM_X_DIRECTION decisionTrendDir;
bool hasDecisionTrend =
decisionCycleHelper
.DetectMarketStructure(
decisionTrendDir //
);
bool hasDecisionBullishTrend =
hasDecisionTrend &&
IsBullish(decisionTrendDir);
bool hasDecisionBearishTrend =
hasDecisionTrend &&
IsBearish(decisionTrendDir);
//
// Detect Bar State ...
@@ -714,457 +619,6 @@ bool DetectX121SMCXSignalSetup(
//
;
//
// Detect Order Block ...
//
bool hasBullishOrderBlocks = conditions.HasBullishOBs();
int bullishOrderBlocksCount = conditions.CountBullishOBs();
//
bool hasBearishOrderBlocks = conditions.HasBearishOBs();
int bearishOrderBlocksCount = conditions.CountBearishOBs();
//
bool hasOrderBlocks = hasBullishOrderBlocks &&
hasBearishOrderBlocks;
if (!hasOrderBlocks)
{
//
XCOrderBlock *bullishOBs[];
XCOrderBlock *bearishOBs[];
bool hasOrderBlocks = visionCycleHelper.DetectOrderBlocks(
bullishOBs,
bearishOBs //
);
//
if (!hasBullishOrderBlocks)
{
//
Copy(
bullishOBs,
conditions.bullishOBs //
);
}
//
if (!hasBearishOrderBlocks)
{
//
Copy(
bearishOBs,
conditions.bearishOBs //
);
}
//
hasBullishOrderBlocks = conditions.HasBullishOBs();
bullishOrderBlocksCount = conditions.CountBullishOBs();
//
hasBearishOrderBlocks = conditions.HasBearishOBs();
bearishOrderBlocksCount = conditions.CountBearishOBs();
}
//
bool hasOldestBullishOB = false;
bool hasYoungestBullishOB = false;
XCOrderBlock *oldestBullishOB = NULL;
XCOrderBlock *youngestBullishOB = NULL;
if (hasBullishOrderBlocks)
{
//
XCZone *zones[];
bool isConverted = ToZone(
conditions.bullishOBs,
zones //
);
//
int oldestIDX = GetOldest(zones);
hasOldestBullishOB = IsValidIndex(oldestIDX);
if (hasOldestBullishOB)
{
oldestBullishOB = conditions.bullishOBs[oldestIDX];
}
//
int youngestIDX = GetYoungest(zones);
hasYoungestBullishOB = IsValidIndex(youngestIDX);
if (hasYoungestBullishOB)
{
youngestBullishOB = conditions.bullishOBs[youngestIDX];
}
}
//
bool hasOldestBearishOB = false;
bool hasYoungestBearishOB = false;
XCOrderBlock *oldestBearishOB = NULL;
XCOrderBlock *youngestBearishOB = NULL;
if (hasBearishOrderBlocks)
{
//
XCZone *zones[];
bool isConverted = ToZone(
conditions.bearishOBs,
zones //
);
//
int oldestIDX = GetOldest(zones);
hasOldestBearishOB = IsValidIndex(oldestIDX);
if (hasOldestBearishOB)
{
oldestBearishOB = conditions.bearishOBs[oldestIDX];
}
//
int youngestIDX = GetYoungest(zones);
hasYoungestBearishOB = IsValidIndex(youngestIDX);
if (hasYoungestBearishOB)
{
youngestBearishOB = conditions.bearishOBs[youngestIDX];
}
}
//
bool hasPriceInsideOB = false;
XCOrderBlock *priceInsideOB = NULL;
//
if (!hasPriceInsideOB &&
hasBullishOrderBlocks)
{
//
for (int i = 0; i < bullishOrderBlocksCount; i++)
{
//
XCOrderBlock *iOb = conditions.bullishOBs[i];
//
bool isInside = IsPriceInsideZone(
decisionXConditions.valesBuffer[1],
(XCZone *)iOb //
);
if (isInside)
{
//
hasPriceInsideOB = true;
priceInsideOB = iOb;
break;
}
}
}
//
if (!hasPriceInsideOB &&
hasBearishOrderBlocks)
{
//
for (int i = 0; i < bearishOrderBlocksCount; i++)
{
//
XCOrderBlock *iOb = conditions.bearishOBs[i];
//
bool isInside = IsPriceInsideZone(
decisionXConditions.peaksBuffer[1],
(XCZone *)iOb //
);
if (isInside)
{
//
hasPriceInsideOB = true;
priceInsideOB = iOb;
break;
}
}
}
//
XStateZones obState;
bool hasOBState = false;
XOHCL priceInsideOBBreakerBar;
if (hasPriceInsideOB)
{
//
XOHCL toBar;
XOHCL fromBar;
ENUM_X_DIRECTION forDir =
priceInsideOB.IsBullish()
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
bool hasBreakerBar = HasBreakerBar(
toBar,
fromBar,
priceInsideOBBreakerBar,
forDir,
priceInsideOB.GetSymbol(),
priceInsideOB.GetPeriod(),
priceInsideOB.Upper(),
priceInsideOB.Lower(),
priceInsideOB.From(),
priceInsideOB.To() //
);
if (hasBreakerBar)
{
//
CalculateStateZones(
obState,
consolidationState,
priceInsideOB.Upper(),
priceInsideOB.Lower(),
priceInsideOBBreakerBar.time //
);
}
//
hasOBState = obState.IsValid();
}
//
bool isSameCyclesPeak =
//
triggerXConditions.peaksBuffer[1] == decisionXConditions.peaksBuffer[1] &&
decisionXConditions.peaksBuffer[1] == analyseXConditions.peaksBuffer[1] &&
analyseXConditions.peaksBuffer[1] == verificationXConditions.peaksBuffer[1] &&
verificationXConditions.peaksBuffer[1] == consolidationXConditions.peaksBuffer[1]
//
;
//
bool isSameCyclesVale =
//
triggerXConditions.valesBuffer[1] == decisionXConditions.valesBuffer[1] &&
decisionXConditions.valesBuffer[1] == analyseXConditions.valesBuffer[1] &&
analyseXConditions.valesBuffer[1] == verificationXConditions.valesBuffer[1] &&
verificationXConditions.valesBuffer[1] == consolidationXConditions.valesBuffer[1]
//
;
//
bool hasSameCyclesPV =
hasOBState &&
hasPriceInsideOB &&
(isSameCyclesPeak ||
isSameCyclesVale);
//
// DRAW ...
//
//
XCBaseObject *drawnObjects[];
//
if (hasBullishOrderBlocks)
{
//
for (int i = 0; i < bullishOrderBlocksCount; i++)
{
//
XCOrderBlock *iOb = conditions.bullishOBs[i];
//
XCBullishOrderBlockObject *iObObj;
bool isCreated = visionCycleHelper
.mPOIDrawer
.CreateBullishOrderBlock(
iOb,
iObObj //
);
if (isCreated)
{
//
Add(
(XCBaseObject *)iObObj,
drawnObjects //
);
}
}
}
//
if (hasBearishOrderBlocks)
{
//
for (int i = 0; i < bearishOrderBlocksCount; i++)
{
//
XCOrderBlock *iOb = conditions.bearishOBs[i];
//
XCBearishOrderBlockObject *iObObj;
bool isCreated = visionCycleHelper
.mPOIDrawer
.CreateBearishOrderBlock(
iOb,
iObObj //
);
if (isCreated)
{
//
Add(
(XCBaseObject *)iObObj,
drawnObjects //
);
}
}
}
//
// if (hasOldestBullishOB)
// {
// //
// XCBullishOrderBlockObject *iObj;
// bool isCreated = visionCycleHelper
// .mPOIDrawer
// .CreateBullishOrderBlock(
// oldestBullishOB,
// iObj //
// );
// if (isCreated)
// {
// }
// }
// //
// if (hasYoungestBullishOB)
// {
// //
// XCBullishOrderBlockObject *iObj;
// bool isCreated = visionCycleHelper
// .mPOIDrawer
// .CreateBullishOrderBlock(
// youngestBullishOB,
// iObj //
// );
// if (isCreated)
// {
// }
// }
// //
// if (hasOldestBearishOB)
// {
// //
// XCBearishOrderBlockObject *iObj;
// bool isCreated = visionCycleHelper
// .mPOIDrawer
// .CreateBearishOrderBlock(
// oldestBearishOB,
// iObj //
// );
// if (isCreated)
// {
// }
// }
// //
// if (hasYoungestBearishOB)
// {
// //
// XCBearishOrderBlockObject *iObj;
// bool isCreated = visionCycleHelper
// .mPOIDrawer
// .CreateBearishOrderBlock(
// youngestBearishOB,
// iObj //
// );
// if (isCreated)
// {
// }
// }
//
if (hasPriceInsideOB)
{
//
bool isBullish = priceInsideOB.IsBullish();
//
bool isCreated = false;
XCBaseObject *iObObj = NULL;
if (isBullish)
{
//
XCBullishOrderBlockObject *iObj;
isCreated = visionCycleHelper
.mPOIDrawer
.CreateBullishOrderBlock(
priceInsideOB,
iObj //
);
//
if (isCreated)
{
//
iObj.ZoneColor(clrYellow);
iObObj = (XCBaseObject *)iObj;
}
}
else
{
//
XCBearishOrderBlockObject *iObj;
isCreated = visionCycleHelper
.mPOIDrawer
.CreateBearishOrderBlock(
priceInsideOB,
iObj //
);
//
if (isCreated)
{
//
iObj.ZoneColor(clrOrangeRed);
iObObj = (XCBaseObject *)iObj;
}
}
//
if (isCreated)
{
//
Add(
iObObj,
drawnObjects //
);
}
}
//
if (hasOBState)
{
//
XCBaseObject *stateObjects[];
int stateObjectsCount = consolidationCycleHelper
.mPOIDrawer
.DrawStateZones(
obState,
stateObjects //
);
if (IsValidSize(stateObjectsCount))
{
//
Copy(
stateObjects,
drawnObjects,
false //
);
}
}
//
int drawnCount = ArraySize(drawnObjects);
if (IsValidSize(drawnCount))
{
}
//
//
//
@@ -1175,42 +629,14 @@ bool DetectX121SMCXSignalSetup(
//
bool isCondition1Bullish =
//
hasSameCyclesPV &&
isCBarBullishFormed &&
priceInsideOB.IsBullish() &&
//
(decisionXConditions.isBreakedUpPrevSar ||
decisionXConditions.isBreakedUpPrevStr ||
decisionXConditions.isVWapMaxBreakedUp ||
decisionXConditions.isBreakedUpPrevCheMax ||
decisionXConditions.isBreakedUpPrevAtrLower) &&
//
(decisionXConditions.isSarSwitchedToBullish ||
decisionXConditions.isStrSwitchedToBullish ||
decisionXConditions.isCheSwitchedToBullish ||
decisionXConditions.isVWapSwitchedToBullishState ||
decisionXConditions.isVWapSwitchedToBullishOrdered)
false
//
;
//
bool isCondition1Bearish =
//
hasSameCyclesPV &&
isCBarBearishFormed &&
priceInsideOB.IsBearish() &&
//
(decisionXConditions.isBreakedDownPrevSar ||
decisionXConditions.isBreakedDownPrevStr ||
decisionXConditions.isVWapMinBreakedDown ||
decisionXConditions.isBreakedDownPrevCheMin ||
decisionXConditions.isBreakedDownPrevAtrUpper) &&
//
(decisionXConditions.isSarSwitchedToBearish ||
decisionXConditions.isStrSwitchedToBearish ||
decisionXConditions.isCheSwitchedToBearish ||
decisionXConditions.isVWapSwitchedToBearishState ||
decisionXConditions.isVWapSwitchedToBearishOrdered)
false
//
;
@@ -1243,8 +669,8 @@ bool DetectX121SMCXSignalSetup(
//
conditions.pivot =
isCondition1Bullish
? priceInsideOB.Upper()
: priceInsideOB.Lower();
? 0 // priceInsideOB.Upper()
: 0; // priceInsideOB.Lower();
}
//
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+303 -434
View File
@@ -26,6 +26,53 @@
#include "../Libraries/x-121.smc.guard.lib.mq5"
#include "../Libraries/x-121.smc.lib.mq5"
//
struct XOBTest
{
//
// Props ...
//
string symbol;
ENUM_TIMEFRAMES period;
//
XCOrderBlock *ob;
XCFVG *fvg;
//
datetime fvgActivatedAt;
datetime rewardedAt;
//
double reward;
//
// Constructor ...
XOBTest()
{
Clean();
}
//
// Tools ...
//
void Clean()
{
//
ob = NULL;
fvg = NULL;
symbol = NULL;
period = NULL;
rewardedAt = NULL;
fvgActivatedAt = NULL;
//
reward = 0;
}
};
//
// Definitions ...
struct X121SMCStrategyXOBSSignalConditions
@@ -56,18 +103,7 @@ struct X121SMCStrategyXOBSSignalConditions
//
// Extwnsion ...
//
datetime cOBAt;
XCOrderBlock *cOB;
bool isCOBActivated;
datetime cOBActivatedAt;
//
datetime aOBAt;
XCOrderBlock *aOB;
bool isAOBActivated;
datetime aOBActivatedAt;
XOBTest obTests[];
//
// Constructor ...
@@ -191,16 +227,7 @@ struct X121SMCStrategyXOBSSignalConditions
point = 0;
//
cOB = NULL;
cOBAt = NULL;
cOBActivatedAt = NULL;
isCOBActivated = false;
//
aOB = NULL;
aOBAt = NULL;
aOBActivatedAt = NULL;
isAOBActivated = false;
Clean(obTests);
}
//
@@ -434,84 +461,6 @@ bool DetectX121SMCXOBSSignalSetup(
//
// Setup Conditions ...
//
// Detect Trend ...
//
// Vision ...
ENUM_X_DIRECTION visionTrendDir;
bool hasVisionTrend =
visionCycleHelper
.DetectMarketStructure(
visionTrendDir //
);
bool hasVisionBullishTrend =
hasVisionTrend &&
IsBullish(visionTrendDir);
bool hasVisionBearishTrend =
hasVisionTrend &&
IsBearish(visionTrendDir);
//
// Consolidation ...
ENUM_X_DIRECTION consolidationTrendDir;
bool hasConsolidationTrend =
consolidationCycleHelper
.DetectMarketStructure(
consolidationTrendDir //
);
bool hasConsolidationBullishTrend =
hasConsolidationTrend &&
IsBullish(consolidationTrendDir);
bool hasConsolidationBearishTrend =
hasConsolidationTrend &&
IsBearish(consolidationTrendDir);
//
// Verification ...
ENUM_X_DIRECTION verificationTrendDir;
bool hasVerificationTrend =
verificationCycleHelper
.DetectMarketStructure(
verificationTrendDir //
);
bool hasVerificationBullishTrend =
hasVerificationTrend &&
IsBullish(verificationTrendDir);
bool hasVerificationBearishTrend =
hasVerificationTrend &&
IsBearish(verificationTrendDir);
//
// Analyse ...
ENUM_X_DIRECTION analyseTrendDir;
bool hasAnalyseTrend =
analyseCycleHelper
.DetectMarketStructure(
analyseTrendDir //
);
bool hasAnalyseBullishTrend =
hasAnalyseTrend &&
IsBullish(analyseTrendDir);
bool hasAnalyseBearishTrend =
hasAnalyseTrend &&
IsBearish(analyseTrendDir);
//
// Decision ...
ENUM_X_DIRECTION decisionTrendDir;
bool hasDecisionTrend =
decisionCycleHelper
.DetectMarketStructure(
decisionTrendDir //
);
bool hasDecisionBullishTrend =
hasDecisionTrend &&
IsBullish(decisionTrendDir);
bool hasDecisionBearishTrend =
hasDecisionTrend &&
IsBearish(decisionTrendDir);
//
// Detect Bar State ...
@@ -730,350 +679,36 @@ bool DetectX121SMCXOBSSignalSetup(
;
//
// Detect OrderBlocks ...
// Detect Order Flow ...
//
bool hasCOB =
conditions.cOB != NULL &&
conditions.cOB.IsValid() &&
IsValid(conditions.cOBAt);
//
if (!hasCOB)
// Test Market For Order Flow ...
int obTestsCount = ArraySize(conditions.obTests);
bool isOBTested = obTestsCount == 2;
if (!isOBTested)
{
//
int poiEvntsCount = ArraySize(consolidationPoiEvents);
bool hasEvent = IsValidSize(poiEvntsCount);
if (hasEvent)
XOBTest test;
bool hasTest = ReTestMarket(
test,
conditions.obTests,
consolidationState,
analyseState,
decisionState,
visionCycleHelper.mPOIDrawer //
);
if (hasTest)
{
//
bool hasNewBullOB = Contains(
X_BULLISH_ORDERBLOCK_DETECTED,
consolidationPoiEvents //
);
//
bool hasNewBearOB = Contains(
X_BEARISH_ORDERBLOCK_DETECTED,
consolidationPoiEvents //
);
//
bool hasNewOB =
hasNewBullOB ||
hasNewBearOB;
//
if (hasNewOB)
{
//
XCOrderBlock *ob = NULL;
if (hasNewBullOB)
{
//
int lastIDX = consolidationState.CountBullishOrderBlocks() - 1;
ob = consolidationState.bullishOrderBlocks[lastIDX];
//
// Validate OB ...
}
else if (hasNewBearOB)
{
//
int lastIDX = consolidationState.CountBearishOrderBlocks() - 1;
ob = consolidationState.bearishOrderBlocks[lastIDX];
//
// Validate OB ...
}
//
if (ob != NULL && ob.IsValid())
{
//
conditions.cOB = ob;
//
conditions.cOBAt = cTime;
//
hasCOB =
conditions.cOB != NULL &&
conditions.cOB.IsValid() &&
IsValid(conditions.cOBAt);
}
}
AddRef(
test,
conditions.obTests);
}
}
//
if (hasCOB)
{
conditions.cOB.To(cTime);
}
//
bool hasAOB =
conditions.aOB != NULL &&
conditions.aOB.IsValid() &&
IsValid(conditions.aOBAt);
//
if (hasCOB &&
!hasAOB)
{
//
int poiEvntsCount = ArraySize(analysePoiEvents);
bool hasEvent = IsValidSize(poiEvntsCount);
if (hasEvent)
{
//
bool hasNewBullOB = Contains(
X_BULLISH_ORDERBLOCK_DETECTED,
analysePoiEvents //
);
//
bool hasNewBearOB = Contains(
X_BEARISH_ORDERBLOCK_DETECTED,
analysePoiEvents //
);
//
bool hasNewOB =
hasNewBullOB ||
hasNewBearOB;
//
if (hasNewOB)
{
//
XCOrderBlock *ob = NULL;
if (hasNewBullOB)
{
//
int lastIDX = analyseState.CountBullishOrderBlocks() - 1;
ob = analyseState.bullishOrderBlocks[lastIDX];
//
// Validate OB ...
}
else if (hasNewBearOB)
{
//
int lastIDX = analyseState.CountBearishOrderBlocks() - 1;
ob = analyseState.bearishOrderBlocks[lastIDX];
//
// Validate OB ...
}
//
if (ob != NULL && ob.IsValid())
{
//
conditions.aOB = ob;
//
conditions.aOBAt = cTime;
//
hasAOB =
conditions.aOB != NULL &&
conditions.aOB.IsValid() &&
IsValid(conditions.aOBAt);
}
}
}
}
//
if (hasAOB)
{
conditions.aOB.To(cTime);
}
//
result = hasCOB &&
hasAOB;
if (!result)
{
return result;
}
//
// DRAW ...
//
//
// Draw Orer Block ...
bool isBullishCOB = conditions.cOB.IsBullish();
if (isBullishCOB)
{
//
XCBullishOrderBlockObject *iObj;
bool isCreated = consolidationCycleHelper
.mPOIDrawer
.CreateBullishOrderBlock(
conditions.cOB,
iObj //
);
}
else
{
//
XCBearishOrderBlockObject *iObj;
bool isCreated = consolidationCycleHelper
.mPOIDrawer
.CreateBearishOrderBlock(
conditions.cOB,
iObj //
);
}
bool isBullishAOB = conditions.aOB.IsBullish();
if (isBullishAOB)
{
//
XCBullishOrderBlockObject *iObj;
bool isCreated = analyseCycleHelper
.mPOIDrawer
.CreateBullishOrderBlock(
conditions.aOB,
iObj //
);
}
else
{
//
XCBearishOrderBlockObject *iObj;
bool isCreated = analyseCycleHelper
.mPOIDrawer
.CreateBearishOrderBlock(
conditions.aOB,
iObj //
);
}
//
// Draw From Bar ...
XOHCL cOBFromBar;
bool hasCOBFromBar = cOBFromBar.Init(
conditions.cOB.GetSymbol(),
conditions.cOB.GetPeriod(),
conditions.cOB.From() //
);
if (hasCOBFromBar)
{
//
XCOHCLObject *barObject;
bool iCreated = consolidationCycleHelper
.mPOIDrawer
.CreateBar(
cOBFromBar,
barObject //
);
}
//
// Draw From Bar ...
XOHCL aOBFromBar;
bool hasAOBFromBar = aOBFromBar.Init(
conditions.aOB.GetSymbol(),
conditions.aOB.GetPeriod(),
conditions.aOB.From() //
);
if (hasAOBFromBar)
{
//
XCOHCLObject *barObject;
bool iCreated = analyseCycleHelper
.mPOIDrawer
.CreateBar(
aOBFromBar,
barObject //
);
}
//
// END DRAW ...
//
//
// Check AOB Activation ...
if (!conditions.isAOBActivated)
{
//
int aPeakRepetition = analyseCycleHelper.CountPrevPeakRepetition();
int aValeRepetition = analyseCycleHelper.CountPrevValeRepetition();
//
bool isActivated =
//
bid >= conditions.aOB.Lower() &&
bid <= conditions.aOB.Upper() &&
//
cBar.low >= conditions.aOB.Lower() &&
cBar.high <= conditions.aOB.Upper() &&
//
(conditions.aOB.IsBullish()
? decisionXConditions.valesBuffer[1] >= conditions.aOB.Lower() &&
decisionXConditions.valesBuffer[1] <= conditions.aOB.Upper()
: decisionXConditions.peaksBuffer[1] >= conditions.aOB.Lower() &&
decisionXConditions.peaksBuffer[1] <= conditions.aOB.Upper())
//
;
//
if (isActivated)
{
//
conditions.aOBActivatedAt = cTime;
conditions.isAOBActivated = isActivated;
}
}
//
// Check COB Activation ...
if (!conditions.isCOBActivated)
{
//
int aPeakRepetition = analyseCycleHelper.CountPrevPeakRepetition();
int aValeRepetition = analyseCycleHelper.CountPrevValeRepetition();
//
bool isActivated =
//
bid >= conditions.cOB.Lower() &&
bid <= conditions.cOB.Upper() &&
//
cBar.low >= conditions.cOB.Lower() &&
cBar.high <= conditions.cOB.Upper() &&
//
(conditions.cOB.IsBullish()
? decisionXConditions.valesBuffer[1] >= conditions.cOB.Lower() &&
decisionXConditions.valesBuffer[1] <= conditions.cOB.Upper()
: decisionXConditions.peaksBuffer[1] >= conditions.cOB.Lower() &&
decisionXConditions.peaksBuffer[1] <= conditions.cOB.Upper())
//
;
//
if (isActivated)
{
//
conditions.cOBActivatedAt = cTime;
conditions.isCOBActivated = isActivated;
}
}
//
result = conditions.isAOBActivated ||
conditions.isCOBActivated;
if (!result)
{
return result;
}
// TODO:
return false;
//
double upper = 0;
@@ -1607,3 +1242,237 @@ int AddX121SMCXOBSConditionsIfNotExists(
}
//
//
//
/**
* Retest Market ...
*
* @param test: XOBTest instance Reference, Represet Result Test ...
* @param tests: XOBTest instance Reference Collection, Represet Founded Tests till now ...
* @param htfState: XPOIState instance Reference ...
* @param mtfState: XPOIState instance Reference ...
* @param ttfState: XPOIState instance Reference ...
*
* @return ( bool )
*/
bool ReTestMarket(
XOBTest &test,
XOBTest &tests[],
XPOIState &htfState,
XPOIState &mtfState,
XPOIState &ttfState, //
//
XCPOIDrawer *drawer
//
)
{
//
bool result = false;
//
test.Clean();
//
int testsCount = ArraySize(tests);
bool hasTests = IsValidSize(testsCount);
XOBTest lastTest;
if (hasTests)
{
lastTest = tests[testsCount - 1];
}
//
// Detect Order Blocks ...
// HTF ...
//
// Bullish OBs ...
XCOrderBlock *bullOBs[];
bool hasYoungestBullOB = false;
XCOrderBlock *youngestBullOB = NULL;
int bullOBsCount = ExtractUnActivatedOBs(
htfState.bullishOrderBlocks,
bullOBs //
);
//
bool isBullOBsPassed = bullOBsCount >= 1;
if (isBullOBsPassed)
{
//
XBoxZone boxes[];
int boxesCount = ToBox(
bullOBs,
boxes //
);
int youngestBoxIDX = GetYoungest(boxes);
hasYoungestBullOB = IsValidIndex(youngestBoxIDX);
if (hasYoungestBullOB)
{
youngestBullOB = bullOBs[youngestBoxIDX];
}
}
//
// Bearish OBs ...
XCOrderBlock *bearOBs[];
bool hasYoungestBearOB = false;
XCOrderBlock *youngestBearOB = NULL;
int bearOBsCount = ExtractUnActivatedOBs(
htfState.bearishOrderBlocks,
bearOBs //
);
//
bool isBearOBsPassed = bearOBsCount >= 1;
if (isBearOBsPassed)
{
//
XBoxZone boxes[];
int boxesCount = ToBox(
bearOBs,
boxes //
);
int youngestBoxIDX = GetYoungest(boxes);
hasYoungestBearOB = IsValidIndex(youngestBoxIDX);
if (hasYoungestBearOB)
{
youngestBearOB = bearOBs[youngestBoxIDX];
}
}
//
result = isBullOBsPassed ||
isBearOBsPassed;
if (!result)
{
return result;
}
//
// DRAW ...
//
//
XCBaseObject *drawnObjects[];
//
if (hasYoungestBullOB)
{
//
XCBullishOrderBlockObject *iObj;
bool isCreated = drawer
.CreateBullishOrderBlock(
youngestBullOB,
iObj //
);
//
if (isCreated)
{
//
Add(
(XCBaseObject *)iObj,
drawnObjects //
);
}
}
//
if (hasYoungestBearOB)
{
//
XCBearishOrderBlockObject *iObj;
bool isCreated = drawer
.CreateBearishOrderBlock(
youngestBearOB,
iObj //
);
//
if (isCreated)
{
//
Add(
(XCBaseObject *)iObj,
drawnObjects //
);
}
}
//
// END DRAW ...
//
//
Print("OBs Passed ...");
//
return result;
}
/**
* Extract UnActivated Order Blocks ...
*
* @return ( int )
*/
int ExtractUnActivatedOBs(
XCOrderBlock *&source[],
XCOrderBlock *&obs[] //
)
{
//
int result = 0;
//
Clean(obs);
//
int count = ArraySize(source);
bool hasOB = IsValidSize(count);
if (!hasOB)
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
bool isBullish = source[i].IsBullish();
ENUM_X_DIRECTION forDir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
//
//
//
XOHCL activatedBar;
ENUM_X_DIRECTION activatedDir;
bool isActivated = source[i].IsActivated(
forDir,
activatedBar,
activatedDir //
);
if (!isActivated)
{
//
Add(
source[i],
obs //
);
}
}
//
result = ArraySize(obs);
//
return result;
}
//