prepare for test ...
This commit is contained in:
@@ -57,14 +57,17 @@ struct X121SMCStrategyXOBSSignalConditions
|
||||
//
|
||||
// Extwnsion ...
|
||||
|
||||
//
|
||||
datetime vOBAt;
|
||||
XCOrderBlock *vOB;
|
||||
bool isVOBActivated;
|
||||
|
||||
//
|
||||
datetime cOBAt;
|
||||
XCOrderBlock *cOB;
|
||||
bool isCOBActivated;
|
||||
datetime cOBActivatedAt;
|
||||
|
||||
//
|
||||
datetime aOBAt;
|
||||
XCOrderBlock *aOB;
|
||||
bool isAOBActivated;
|
||||
datetime aOBActivatedAt;
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
@@ -188,15 +191,16 @@ struct X121SMCStrategyXOBSSignalConditions
|
||||
point = 0;
|
||||
|
||||
//
|
||||
vOB = NULL;
|
||||
cOB = NULL;
|
||||
|
||||
//
|
||||
vOBAt = NULL;
|
||||
cOBAt = NULL;
|
||||
cOBActivatedAt = NULL;
|
||||
isCOBActivated = false;
|
||||
|
||||
//
|
||||
isVOBActivated = false;
|
||||
aOB = NULL;
|
||||
aOBAt = NULL;
|
||||
aOBActivatedAt = NULL;
|
||||
isAOBActivated = false;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -728,12 +732,6 @@ bool DetectX121SMCXOBSSignalSetup(
|
||||
//
|
||||
// Detect OrderBlocks ...
|
||||
|
||||
//
|
||||
bool hasVOB =
|
||||
conditions.vOB != NULL &&
|
||||
conditions.vOB.IsValid() &&
|
||||
IsValid(conditions.vOBAt);
|
||||
|
||||
//
|
||||
bool hasCOB =
|
||||
conditions.cOB != NULL &&
|
||||
@@ -741,23 +739,23 @@ bool DetectX121SMCXOBSSignalSetup(
|
||||
IsValid(conditions.cOBAt);
|
||||
|
||||
//
|
||||
if (!hasVOB)
|
||||
if (!hasCOB)
|
||||
{
|
||||
//
|
||||
int poiEvntsCount = ArraySize(visionPoiEvents);
|
||||
int poiEvntsCount = ArraySize(consolidationPoiEvents);
|
||||
bool hasEvent = IsValidSize(poiEvntsCount);
|
||||
if (hasEvent)
|
||||
{
|
||||
//
|
||||
bool hasNewBullOB = Contains(
|
||||
X_BULLISH_ORDERBLOCK_DETECTED,
|
||||
visionPoiEvents //
|
||||
consolidationPoiEvents //
|
||||
);
|
||||
|
||||
//
|
||||
bool hasNewBearOB = Contains(
|
||||
X_BEARISH_ORDERBLOCK_DETECTED,
|
||||
visionPoiEvents //
|
||||
consolidationPoiEvents //
|
||||
);
|
||||
|
||||
//
|
||||
@@ -769,110 +767,155 @@ bool DetectX121SMCXOBSSignalSetup(
|
||||
if (hasNewOB)
|
||||
{
|
||||
//
|
||||
XCOrderBlock *ob = NULL;
|
||||
if (hasNewBullOB)
|
||||
{
|
||||
//
|
||||
int lastIDX = visionState.CountBullishOrderBlocks() - 1;
|
||||
conditions.vOB = visionState.bullishOrderBlocks[lastIDX];
|
||||
int lastIDX = consolidationState.CountBullishOrderBlocks() - 1;
|
||||
ob = consolidationState.bullishOrderBlocks[lastIDX];
|
||||
|
||||
//
|
||||
// Validate OB ...
|
||||
}
|
||||
else if (hasNewBearOB)
|
||||
{
|
||||
//
|
||||
int lastIDX = visionState.CountBearishOrderBlocks() - 1;
|
||||
conditions.vOB = visionState.bearishOrderBlocks[lastIDX];
|
||||
int lastIDX = consolidationState.CountBearishOrderBlocks() - 1;
|
||||
ob = consolidationState.bearishOrderBlocks[lastIDX];
|
||||
|
||||
//
|
||||
// Validate OB ...
|
||||
}
|
||||
|
||||
//
|
||||
conditions.vOBAt = cTime;
|
||||
if (ob != NULL && ob.IsValid())
|
||||
{
|
||||
//
|
||||
conditions.cOB = ob;
|
||||
|
||||
//
|
||||
hasVOB =
|
||||
conditions.vOB != NULL &&
|
||||
conditions.vOB.IsValid() &&
|
||||
IsValid(conditions.vOBAt);
|
||||
//
|
||||
conditions.cOBAt = cTime;
|
||||
|
||||
//
|
||||
hasCOB =
|
||||
conditions.cOB != NULL &&
|
||||
conditions.cOB.IsValid() &&
|
||||
IsValid(conditions.cOBAt);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
//
|
||||
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)
|
||||
{
|
||||
//
|
||||
X121SMCCycleState vState;
|
||||
bool hasVState = visionCycleHelper.GetCycleState(vState);
|
||||
bool hasNewBullOB = Contains(
|
||||
X_BULLISH_ORDERBLOCK_DETECTED,
|
||||
analysePoiEvents //
|
||||
);
|
||||
|
||||
//
|
||||
bool hasYoungestOB = vState.GetYoungestOB(conditions.vOB);
|
||||
if (hasYoungestOB)
|
||||
bool hasNewBearOB = Contains(
|
||||
X_BEARISH_ORDERBLOCK_DETECTED,
|
||||
analysePoiEvents //
|
||||
);
|
||||
|
||||
//
|
||||
bool hasNewOB =
|
||||
hasNewBullOB ||
|
||||
hasNewBearOB;
|
||||
|
||||
//
|
||||
if (hasNewOB)
|
||||
{
|
||||
//
|
||||
conditions.vOBAt = cTime;
|
||||
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 ...
|
||||
}
|
||||
|
||||
//
|
||||
hasVOB =
|
||||
conditions.vOB != NULL &&
|
||||
conditions.vOB.IsValid() &&
|
||||
IsValid(conditions.vOBAt);
|
||||
if (ob != NULL && ob.IsValid())
|
||||
{
|
||||
//
|
||||
conditions.aOB = ob;
|
||||
|
||||
//
|
||||
conditions.aOBAt = cTime;
|
||||
|
||||
//
|
||||
hasAOB =
|
||||
conditions.aOB != NULL &&
|
||||
conditions.aOB.IsValid() &&
|
||||
IsValid(conditions.aOBAt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Update To Time ...
|
||||
if (hasVOB)
|
||||
if (hasAOB)
|
||||
{
|
||||
//
|
||||
conditions.vOB.To(cTime);
|
||||
conditions.aOB.To(cTime);
|
||||
}
|
||||
|
||||
//
|
||||
// Vait for Order Block Activation ...
|
||||
if (hasVOB &&
|
||||
!conditions.isVOBActivated)
|
||||
{
|
||||
//
|
||||
conditions.isVOBActivated =
|
||||
//
|
||||
cBar.low >= conditions.vOB.Lower() &&
|
||||
cBar.high <= conditions.vOB.Upper() &&
|
||||
//
|
||||
bid >= conditions.vOB.Lower() &&
|
||||
bid <= conditions.vOB.Upper()
|
||||
//
|
||||
;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Result ...
|
||||
result = hasVOB &&
|
||||
conditions.isVOBActivated;
|
||||
result = hasCOB &&
|
||||
hasAOB;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Market Trend ...
|
||||
bool isTrendOveralBullish = hasVisionBullishTrend &&
|
||||
hasConsolidationBullishTrend;
|
||||
bool isTrendOveralBearish = hasVisionBearishTrend &&
|
||||
hasConsolidationBearishTrend;
|
||||
result = (isTrendOveralBullish &&
|
||||
!isTrendOveralBearish) ||
|
||||
(!isTrendOveralBullish &&
|
||||
isTrendOveralBearish);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
// DRAW ...
|
||||
//
|
||||
|
||||
//
|
||||
bool isBullishOB = conditions.vOB.IsBullish();
|
||||
if (isBullishOB)
|
||||
// Draw Orer Block ...
|
||||
bool isBullishCOB = conditions.cOB.IsBullish();
|
||||
if (isBullishCOB)
|
||||
{
|
||||
//
|
||||
XCBullishOrderBlockObject *iObj;
|
||||
bool isCreated = visionCycleHelper
|
||||
bool isCreated = consolidationCycleHelper
|
||||
.mPOIDrawer
|
||||
.CreateBullishOrderBlock(
|
||||
conditions.vOB,
|
||||
conditions.cOB,
|
||||
iObj //
|
||||
);
|
||||
}
|
||||
@@ -880,14 +923,158 @@ bool DetectX121SMCXOBSSignalSetup(
|
||||
{
|
||||
//
|
||||
XCBearishOrderBlockObject *iObj;
|
||||
bool isCreated = visionCycleHelper
|
||||
bool isCreated = consolidationCycleHelper
|
||||
.mPOIDrawer
|
||||
.CreateBearishOrderBlock(
|
||||
conditions.vOB,
|
||||
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;
|
||||
}
|
||||
|
||||
//
|
||||
double upper = 0;
|
||||
double lower = 0;
|
||||
|
||||
Reference in New Issue
Block a user