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
-160
View File
@@ -2077,166 +2077,6 @@ class XCSignalObject : public XCBaseObject
CChartObjectTrend mTargetTrend; CChartObjectTrend mTargetTrend;
}; };
//
// XPVPivot Object ...
class XCXPVPivotObject : public XCBaseObject
{
//
public:
//
/**
* Creator ...
*
* @param chart_id: Long, Specified Chart ID ...
* @param window: Integer, Specified Chart Window ID ...
* @param pivot: XPVPivot instance ...
* @param prefix: String ...
*
* @return ( bool )
*/
bool Create(
long chart_id,
int window,
XPVPivot &pivot,
string prefix = NULL //
)
{
//
bool result = false;
//
result = pivot.IsValid();
if (!result)
{
return result;
}
//
string name = pivot.GetTag();
if (IsValid(prefix))
{
name = prefix + "_" + name;
}
//
result = mRect.Create(
chart_id,
name,
window,
pivot.from,
pivot.upper,
pivot.to,
pivot.lower //
);
//
if (result)
{
ObjName(name);
}
//
string mTrendName = "MID_" + name;
double mid = pivot.CalculateMid();
result = mTrend.Create(
chart_id,
mTrendName,
window,
pivot.from,
mid,
pivot.to,
mid //
);
if (!result)
{
//
mRect.Delete();
mRect.Detach();
}
//
return result;
}
//
// Getter(s) / Setter(s) ...
/**
* Set Pivot Width ...
*
* @param value: Integer ...
*/
void PivotWidth(int value)
{
//
if (value < 1)
{
value = 1;
}
//
mRect.Width(value);
mTrend.Width(value);
}
/**
* Set Pivot Color ...
*
* @param value: Color ...
*/
void PivotColor(color value)
{
//
mRect.Color(value);
mTrend.Color(value);
}
/**
* Set Pivot Style ...
*
* @param value: ENUM_LINE_STYLE member ...
*/
void PivotStyle(ENUM_LINE_STYLE value)
{
//
mRect.Style(value);
mTrend.Style(value);
}
/**
* Set Pivot Fill ...
*
* @param value: Boolean ...
*/
void PivotFill(bool value)
{
mRect.Fill(value);
}
//
// Virtual ...
/**
* Retrieve Object Type ...
*
* @return ( ENUM_XCHARTOBJECTS )
*/
virtual ENUM_XCHARTOBJECTS Type()
{
return X_XPVPIVOT_OBJ;
}
//
private:
//
//
// Props ...
CChartObjectRectangle mRect;
CChartObjectTrend mTrend;
};
class XCOHCLObject : public XCBaseObject class XCOHCLObject : public XCBaseObject
{ {
// //
File diff suppressed because it is too large Load Diff
+138
View File
@@ -0,0 +1,138 @@
//
// Detect New Order Blocks ...
bool hasNewBullishOB = Contains(
X_BULLISH_ORDERBLOCK_DETECTED,
consolidationPoiEvents //
);
bool hasNewBearishOB = Contains(
X_BEARISH_ORDERBLOCK_DETECTED,
consolidationPoiEvents //
);
bool hasNewOB = hasNewBullishOB ||
hasNewBearishOB;
result = hasNewOB;
if (!result)
{
return result;
}
//
// Make Sure New Order Block Detected ...
XCOrderBlock *liveOB = NULL;
if (hasNewBullishOB)
{
//
bool hasBullishOBs = consolidationState.HasBullishOrderBlocks();
int bullishOBsCount = consolidationState.CountBullishOrderBlocks();
if (hasBullishOBs)
{
liveOB = consolidationState.bullishOrderBlocks[bullishOBsCount - 1];
}
}
else if (hasNewBearishOB)
{
//
bool hasBearishOBs = consolidationState.HasBearishOrderBlocks();
int bearishOBsCount = consolidationState.CountBearishOrderBlocks();
if (hasBearishOBs)
{
liveOB = consolidationState.bearishOrderBlocks[bearishOBsCount - 1];
}
}
bool hasLiveOB = liveOB != NULL &&
liveOB.IsValid();
result = hasLiveOB;
if (!result)
{
return result;
}
//
bool isLiveOBBullish = liveOB.IsBullish();
bool isLiveOBBearish = liveOB.IsBearish();
//
ENUM_X_DIRECTION forDir =
isLiveOBBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
XOHCL startedBar;
ENUM_X_DIRECTION startedDir;
bool isLiveOBStarted = liveOB.IsStarted(
forDir,
startedBar,
startedDir //
);
//
XOHCL activatedBar;
ENUM_X_DIRECTION activatedDir;
bool isLiveOBActivated = liveOB.IsActivated(
forDir,
activatedBar,
activatedDir //
);
//
// DRAW ...
//
//
if (isLiveOBStarted)
{
//
XCOHCLObject *barObj;
bool isCreated = consolidationCycleHelper
.mPOIDrawer
.CreateBar(
startedBar,
barObj //
);
}
//
if (isLiveOBActivated)
{
//
XCOHCLObject *barObj;
bool isCreated = consolidationCycleHelper
.mPOIDrawer
.CreateBar(
activatedBar,
barObj //
);
if (isCreated)
{
//
barObj.BodyColor(clrGold);
barObj.HighShadowColor(clrGold);
barObj.LowShadowColor(clrGold);
}
}
//
// Draw Live OB ...
if (isLiveOBBullish)
{
//
XCBullishOrderBlockObject *iObj;
bool isCreated = consolidationCycleHelper
.mPOIDrawer
.CreateBullishOrderBlock(
liveOB,
iObj //
);
}
else
{
//
XCBearishOrderBlockObject *iObj;
bool isCreated = consolidationCycleHelper
.mPOIDrawer
.CreateBearishOrderBlock(
liveOB,
iObj //
);
}
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
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
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
+87 -542
View File
@@ -25,9 +25,6 @@
#include "../Libraries/x-121.smc.lib.mq5" #include "../Libraries/x-121.smc.lib.mq5"
// //
XPriceZones x121SMCDecisionPriceZone;
XPriceZones x121SMCAnalysePriceZone;
XPriceZones x121SMCVerificationPriceZone;
XConsolidationZone x121SMCConsolidationZone; XConsolidationZone x121SMCConsolidationZone;
bool DetectX121SMCGuards( bool DetectX121SMCGuards(
string provider, // Provider ... string provider, // Provider ...
@@ -151,12 +148,6 @@ bool DetectX121SMCGuards(
Clean(ownLongPositions); Clean(ownLongPositions);
Clean(ownShortPositions); Clean(ownShortPositions);
//
x121SMCAnalysePriceZone.Clean();
x121SMCDecisionPriceZone.Clean();
x121SMCConsolidationZone.Clean();
x121SMCVerificationPriceZone.Clean();
// //
return result; return result;
} }
@@ -349,51 +340,6 @@ bool DetectX121SMCGuards(
X121Conditions consolidationXConditions = consolidationConditions.x121Conditions; X121Conditions consolidationXConditions = consolidationConditions.x121Conditions;
X121Conditions visionXConditions = visionConditions.x121Conditions; X121Conditions visionXConditions = visionConditions.x121Conditions;
//
// Trigger ...
ENUM_X_DIRECTION triggerTrendDir;
bool hasTriggerTrend =
triggerCycleHelper
.DetectMarketStructure(
triggerTrendDir //
);
bool hasTriggerBullishTrend =
hasTriggerTrend &&
IsBullish(triggerTrendDir);
bool hasTriggerBearishTrend =
hasTriggerTrend &&
IsBearish(triggerTrendDir);
//
// Decision ...
ENUM_X_DIRECTION decisionTrendDir;
bool hasDecisionTrend =
decisionCycleHelper
.DetectMarketStructure(
decisionTrendDir //
);
bool hasDecisionBullishTrend =
hasDecisionTrend &&
IsBullish(decisionTrendDir);
bool hasDecisionBearishTrend =
hasDecisionTrend &&
IsBearish(decisionTrendDir);
//
// Analyse ...
ENUM_X_DIRECTION analyseTrendDir;
bool hasAnalyseTrend =
analyseCycleHelper
.DetectMarketStructure(
analyseTrendDir //
);
bool hasAnalyseBullishTrend =
hasAnalyseTrend &&
IsBullish(analyseTrendDir);
bool hasAnalyseBearishTrend =
hasAnalyseTrend &&
IsBearish(analyseTrendDir);
// //
// //
// //
@@ -470,402 +416,6 @@ bool DetectX121SMCGuards(
} }
} }
//
// Detect Price Zones ...
//
// Decision ...
double decisionPriceZoneUpper = 0;
double decisionPriceZoneLower = 0;
bool isDecisionPriceZoneBearish = false;
bool isDecisionPriceZoneBullish = false;
bool isDecisionPriceZoneValidForPeak = false;
bool isDecisionPriceZoneValidForVale = false;
bool isDecisionPriceZoneLowerRejected = false;
bool isDecisionPriceZoneUpperRejected = false;
bool isDecisionPriceZoneUpperBreakedUp = false;
bool isDecisionPriceZoneLowerBreakedDown = false;
bool hasDecisionPriceZone = x121SMCDecisionPriceZone.IsValid();
//
if (!hasDecisionPriceZone)
{
//
hasDecisionPriceZone = CalculatePriceInsideZones(
x121SMCDecisionPriceZone,
decisionState,
cBar //
);
}
//
if (hasDecisionPriceZone)
{
//
bool hasBoundary = x121SMCDecisionPriceZone.GetBoundary(
X_DIRECTION_ALL,
decisionPriceZoneUpper,
decisionPriceZoneLower //
);
//
isDecisionPriceZoneBearish = x121SMCDecisionPriceZone.IsBearish();
isDecisionPriceZoneBullish = x121SMCDecisionPriceZone.IsBullish();
//
XOHCL iBar;
bool isInited = iBar.Init(
symbol,
decisionXConditions.period,
cIndex //
);
//
if (hasBoundary)
{
//
isDecisionPriceZoneValidForPeak =
decisionXConditions.peaksBuffer[1] <= decisionPriceZoneUpper &&
decisionXConditions.peaksBuffer[1] >= decisionPriceZoneLower;
//
isDecisionPriceZoneValidForVale =
decisionXConditions.valesBuffer[1] <= decisionPriceZoneUpper &&
decisionXConditions.valesBuffer[1] >= decisionPriceZoneLower;
//
isDecisionPriceZoneLowerRejected =
isInited &&
IsBarReject(
decisionPriceZoneLower,
X_DIRECTION_BULLISH,
iBar //
);
//
isDecisionPriceZoneUpperRejected =
isInited &&
IsBarReject(
decisionPriceZoneUpper,
X_DIRECTION_BEARISH,
iBar //
);
//
isDecisionPriceZoneUpperBreakedUp =
isInited &&
IsBarBreak(
decisionPriceZoneUpper,
X_DIRECTION_BULLISH,
iBar //
);
//
isDecisionPriceZoneLowerBreakedDown =
isInited &&
IsBarBreak(
decisionPriceZoneUpper,
X_DIRECTION_BEARISH,
iBar //
);
}
//
// Clear Price Zone ...
bool canReset =
//
(!isInited ||
!hasBoundary)
//
||
//
(isInited &&
hasBoundary &&
(iBar.high < decisionPriceZoneLower ||
iBar.low > decisionPriceZoneUpper))
//
;
if (canReset)
{
//
x121SMCDecisionPriceZone.Clean();
//
decisionPriceZoneUpper = 0;
decisionPriceZoneLower = 0;
isDecisionPriceZoneBearish = false;
isDecisionPriceZoneBullish = false;
isDecisionPriceZoneValidForPeak = false;
isDecisionPriceZoneValidForVale = false;
isDecisionPriceZoneLowerRejected = false;
isDecisionPriceZoneUpperRejected = false;
isDecisionPriceZoneUpperBreakedUp = false;
isDecisionPriceZoneLowerBreakedDown = false;
}
}
//
// Analyse ...
double analysePriceZoneUpper = 0;
double analysePriceZoneLower = 0;
bool isAnalysePriceZoneBearish = false;
bool isAnalysePriceZoneBullish = false;
bool isAnalysePriceZoneValidForPeak = false;
bool isAnalysePriceZoneValidForVale = false;
bool isAnalysePriceZoneLowerRejected = false;
bool isAnalysePriceZoneUpperRejected = false;
bool isAnalysePriceZoneUpperBreakedUp = false;
bool isAnalysePriceZoneLowerBreakedDown = false;
bool hasAnalysePriceZone = x121SMCAnalysePriceZone.IsValid();
//
if (!hasAnalysePriceZone)
{
//
hasAnalysePriceZone = CalculatePriceInsideZones(
x121SMCAnalysePriceZone,
analyseState,
cBar //
);
}
//
if (hasAnalysePriceZone)
{
//
bool hasBoundary = x121SMCAnalysePriceZone.GetBoundary(
X_DIRECTION_ALL,
analysePriceZoneUpper,
analysePriceZoneLower //
);
//
isAnalysePriceZoneBearish = x121SMCAnalysePriceZone.IsBearish();
isAnalysePriceZoneBullish = x121SMCAnalysePriceZone.IsBullish();
//
XOHCL iBar;
bool isInited = iBar.Init(
symbol,
analyseXConditions.period,
cIndex //
);
//
if (hasBoundary)
{
//
isAnalysePriceZoneValidForPeak =
analyseXConditions.peaksBuffer[1] <= analysePriceZoneUpper &&
analyseXConditions.peaksBuffer[1] >= analysePriceZoneLower;
//
isAnalysePriceZoneValidForVale =
analyseXConditions.valesBuffer[1] <= analysePriceZoneUpper &&
analyseXConditions.valesBuffer[1] >= analysePriceZoneLower;
//
isAnalysePriceZoneLowerRejected =
isInited &&
IsBarReject(
analysePriceZoneLower,
X_DIRECTION_BULLISH,
iBar //
);
//
isAnalysePriceZoneUpperRejected =
isInited &&
IsBarReject(
analysePriceZoneUpper,
X_DIRECTION_BEARISH,
iBar //
);
//
isAnalysePriceZoneUpperBreakedUp =
isInited &&
IsBarBreak(
analysePriceZoneUpper,
X_DIRECTION_BULLISH,
iBar //
);
//
isAnalysePriceZoneLowerBreakedDown =
isInited &&
IsBarBreak(
analysePriceZoneUpper,
X_DIRECTION_BEARISH,
iBar //
);
}
//
// Clear Price Zone ...
bool canReset =
//
(!isInited ||
!hasBoundary)
//
||
//
(isInited &&
hasBoundary &&
(iBar.high < analysePriceZoneLower ||
iBar.low > analysePriceZoneUpper))
//
;
if (canReset)
{
//
x121SMCAnalysePriceZone.Clean();
//
analysePriceZoneUpper = 0;
analysePriceZoneLower = 0;
isAnalysePriceZoneBearish = false;
isAnalysePriceZoneBullish = false;
isAnalysePriceZoneValidForPeak = false;
isAnalysePriceZoneValidForVale = false;
isAnalysePriceZoneLowerRejected = false;
isAnalysePriceZoneUpperRejected = false;
isAnalysePriceZoneUpperBreakedUp = false;
isAnalysePriceZoneLowerBreakedDown = false;
}
}
//
// Verification ...
double verificationPriceZoneUpper = 0;
double verificationPriceZoneLower = 0;
bool isVerificationPriceZoneBearish = false;
bool isVerificationPriceZoneBullish = false;
bool isVerificationPriceZoneValidForPeak = false;
bool isVerificationPriceZoneValidForVale = false;
bool isVerificationPriceZoneLowerRejected = false;
bool isVerificationPriceZoneUpperRejected = false;
bool isVerificationPriceZoneUpperBreakedUp = false;
bool isVerificationPriceZoneLowerBreakedDown = false;
bool hasVerificationPriceZone = x121SMCVerificationPriceZone.IsValid();
//
if (!hasVerificationPriceZone)
{
//
hasVerificationPriceZone = CalculatePriceInsideZones(
x121SMCVerificationPriceZone,
verificationState,
cBar //
);
}
//
if (hasVerificationPriceZone)
{
//
bool hasBoundary = x121SMCVerificationPriceZone.GetBoundary(
X_DIRECTION_ALL,
verificationPriceZoneUpper,
verificationPriceZoneLower //
);
//
isVerificationPriceZoneBearish = x121SMCVerificationPriceZone.IsBearish();
isVerificationPriceZoneBullish = x121SMCVerificationPriceZone.IsBullish();
//
XOHCL iBar;
bool isInited = iBar.Init(
symbol,
verificationXConditions.period,
cIndex //
);
//
if (hasBoundary)
{
//
isVerificationPriceZoneValidForPeak =
verificationXConditions.peaksBuffer[1] <= verificationPriceZoneUpper &&
verificationXConditions.peaksBuffer[1] >= verificationPriceZoneLower;
//
isVerificationPriceZoneValidForVale =
verificationXConditions.valesBuffer[1] <= verificationPriceZoneUpper &&
verificationXConditions.valesBuffer[1] >= verificationPriceZoneLower;
//
isVerificationPriceZoneLowerRejected =
isInited &&
IsBarReject(
verificationPriceZoneLower,
X_DIRECTION_BULLISH,
iBar //
);
//
isVerificationPriceZoneUpperRejected =
isInited &&
IsBarReject(
verificationPriceZoneUpper,
X_DIRECTION_BEARISH,
iBar //
);
//
isVerificationPriceZoneUpperBreakedUp =
isInited &&
IsBarBreak(
verificationPriceZoneUpper,
X_DIRECTION_BULLISH,
iBar //
);
//
isVerificationPriceZoneLowerBreakedDown =
isInited &&
IsBarBreak(
verificationPriceZoneUpper,
X_DIRECTION_BEARISH,
iBar //
);
}
//
// Clear Price Zone ...
bool canReset =
//
(!isInited ||
!hasBoundary)
//
||
//
(isInited &&
hasBoundary &&
(iBar.high < verificationPriceZoneLower ||
iBar.low > verificationPriceZoneUpper))
//
;
if (canReset)
{
//
x121SMCVerificationPriceZone.Clean();
//
verificationPriceZoneUpper = 0;
verificationPriceZoneLower = 0;
isVerificationPriceZoneBearish = false;
isVerificationPriceZoneBullish = false;
isVerificationPriceZoneValidForPeak = false;
isVerificationPriceZoneValidForVale = false;
isVerificationPriceZoneLowerRejected = false;
isVerificationPriceZoneUpperRejected = false;
isVerificationPriceZoneUpperBreakedUp = false;
isVerificationPriceZoneLowerBreakedDown = false;
}
}
// //
// Here We Have all Requirements for Guarding Positions ... // Here We Have all Requirements for Guarding Positions ...
@@ -906,37 +456,10 @@ bool DetectX121SMCGuards(
// //
isLong isLong
? // ? //
(hasDecisionPriceZone && false
isDecisionPriceZoneBearish && //
isDecisionPriceZoneValidForPeak)
//
||
//
(hasAnalysePriceZone &&
isAnalysePriceZoneBearish &&
isAnalysePriceZoneValidForPeak)
//
||
//
(hasVerificationPriceZone &&
isVerificationPriceZoneBearish &&
isVerificationPriceZoneValidForPeak)
: // : //
(hasDecisionPriceZone && false
isDecisionPriceZoneBullish &&
isDecisionPriceZoneValidForVale)
//
||
//
(hasAnalysePriceZone &&
isAnalysePriceZoneBullish &&
isAnalysePriceZoneValidForVale)
//
||
//
(hasVerificationPriceZone &&
isVerificationPriceZoneBullish &&
isVerificationPriceZoneValidForVale)
// //
; ;
if (iHasGuard) if (iHasGuard)
@@ -969,7 +492,7 @@ bool DetectX121SMCGuards(
if (!ignoreCloseLongsOnBearishTrendGuard) if (!ignoreCloseLongsOnBearishTrendGuard)
{ {
// //
bool hasGuard = hasDecisionBearishTrend; bool hasGuard = false; // hasDecisionBearishTrend;
// //
if (hasGuard) if (hasGuard)
@@ -1016,7 +539,7 @@ bool DetectX121SMCGuards(
if (!ignoreCloseShortsOnBullishTrendGuard) if (!ignoreCloseShortsOnBullishTrendGuard)
{ {
// //
bool hasGuard = hasDecisionBullishTrend; bool hasGuard = false; // hasDecisionBullishTrend;
// //
if (hasGuard) if (hasGuard)
@@ -1100,8 +623,10 @@ bool DetectX121SMCGuards(
// //
bool hasGuard = bool hasGuard =
// //
hasAnalyseBearishTrend && false
hasDecisionBearishTrend //
// hasAnalyseBearishTrend &&
// hasDecisionBearishTrend
// //
; ;
@@ -1132,8 +657,10 @@ bool DetectX121SMCGuards(
// //
bool hasGuard = bool hasGuard =
// //
hasAnalyseBullishTrend && false
hasDecisionBullishTrend //
// hasAnalyseBullishTrend &&
// hasDecisionBullishTrend
// //
; ;
@@ -1169,8 +696,10 @@ bool DetectX121SMCGuards(
// //
bool hasGuard = bool hasGuard =
// //
hasTriggerBearishTrend || false
!hasDecisionBullishTrend //
// hasTriggerBearishTrend ||
// !hasDecisionBullishTrend
// //
; ;
@@ -1211,8 +740,10 @@ bool DetectX121SMCGuards(
// //
bool hasGuard = bool hasGuard =
// //
hasTriggerBullishTrend || false
!hasDecisionBearishTrend //
// hasTriggerBullishTrend ||
// !hasDecisionBearishTrend
// //
; ;
@@ -1256,7 +787,7 @@ bool DetectX121SMCGuards(
if (hasLongs) if (hasLongs)
{ {
// //
bool hasTrendGuard = hasDecisionBearishTrend; bool hasTrendGuard = false; // hasDecisionBearishTrend;
// //
bool hasConsolidationGuard = bool hasConsolidationGuard =
@@ -1266,24 +797,27 @@ bool DetectX121SMCGuards(
// //
bool hasDecisionPriceZoneGuard = bool hasDecisionPriceZoneGuard =
(hasDecisionPriceZone && false;
isDecisionPriceZoneBullish && // (hasDecisionPriceZone &&
isDecisionPriceZoneValidForVale && // isDecisionPriceZoneBullish &&
isDecisionPriceZoneUpperBreakedUp); // isDecisionPriceZoneValidForVale &&
// isDecisionPriceZoneUpperBreakedUp);
// //
bool hasAnalysePriceZoneGuard = bool hasAnalysePriceZoneGuard =
(hasAnalysePriceZone && false;
isAnalysePriceZoneBullish && // (hasAnalysePriceZone &&
isAnalysePriceZoneValidForVale && // isAnalysePriceZoneBullish &&
isAnalysePriceZoneUpperBreakedUp); // isAnalysePriceZoneValidForVale &&
// isAnalysePriceZoneUpperBreakedUp);
// //
bool hasVerificationPriceZoneGuard = bool hasVerificationPriceZoneGuard =
(hasVerificationPriceZone && false;
isVerificationPriceZoneBullish && // (hasVerificationPriceZone &&
isVerificationPriceZoneValidForVale && // isVerificationPriceZoneBullish &&
isVerificationPriceZoneUpperBreakedUp); // isVerificationPriceZoneValidForVale &&
// isVerificationPriceZoneUpperBreakedUp);
// //
bool hasGuard = bool hasGuard =
@@ -1301,11 +835,11 @@ bool DetectX121SMCGuards(
hasConsolidationGuard hasConsolidationGuard
? consolidationZoneLower ? consolidationZoneLower
: hasDecisionPriceZoneGuard : hasDecisionPriceZoneGuard
? decisionPriceZoneLower ? 0 // decisionPriceZoneLower
: hasAnalysePriceZoneGuard : hasAnalysePriceZoneGuard
? analysePriceZoneLower ? 0 // analysePriceZoneLower
: hasVerificationPriceZoneGuard : hasVerificationPriceZoneGuard
? verificationPriceZoneLower ? 0 // verificationPriceZoneLower
: 0; : 0;
// //
@@ -1378,7 +912,7 @@ bool DetectX121SMCGuards(
if (hasShorts) if (hasShorts)
{ {
// //
bool hasTrendGuard = hasDecisionBullishTrend; bool hasTrendGuard = false; // hasDecisionBullishTrend;
// //
bool hasConsolidationGuard = bool hasConsolidationGuard =
@@ -1388,24 +922,27 @@ bool DetectX121SMCGuards(
// //
bool hasDecisionPriceZoneGuard = bool hasDecisionPriceZoneGuard =
(hasDecisionPriceZone && false;
isDecisionPriceZoneBearish && // (hasDecisionPriceZone &&
isDecisionPriceZoneValidForPeak && // isDecisionPriceZoneBearish &&
isDecisionPriceZoneLowerBreakedDown); // isDecisionPriceZoneValidForPeak &&
// isDecisionPriceZoneLowerBreakedDown);
// //
bool hasAnalysePriceZoneGuard = bool hasAnalysePriceZoneGuard =
(hasAnalysePriceZone && false;
isAnalysePriceZoneBearish && // (hasAnalysePriceZone &&
isAnalysePriceZoneValidForPeak && // isAnalysePriceZoneBearish &&
isAnalysePriceZoneLowerBreakedDown); // isAnalysePriceZoneValidForPeak &&
// isAnalysePriceZoneLowerBreakedDown);
// //
bool hasVerificationPriceZoneGuard = bool hasVerificationPriceZoneGuard =
(hasVerificationPriceZone && false;
isVerificationPriceZoneBearish && // (hasVerificationPriceZone &&
isVerificationPriceZoneValidForPeak && // isVerificationPriceZoneBearish &&
isVerificationPriceZoneLowerBreakedDown); // isVerificationPriceZoneValidForPeak &&
// isVerificationPriceZoneLowerBreakedDown);
// //
bool hasGuard = bool hasGuard =
@@ -1423,11 +960,11 @@ bool DetectX121SMCGuards(
hasConsolidationGuard hasConsolidationGuard
? consolidationZoneUpper ? consolidationZoneUpper
: hasDecisionPriceZoneGuard : hasDecisionPriceZoneGuard
? decisionPriceZoneUpper ? 0 // decisionPriceZoneUpper
: hasAnalysePriceZoneGuard : hasAnalysePriceZoneGuard
? analysePriceZoneUpper ? 0 // analysePriceZoneUpper
: hasVerificationPriceZoneGuard : hasVerificationPriceZoneGuard
? verificationPriceZoneUpper ? 0 // verificationPriceZoneUpper
: 0; : 0;
// //
@@ -1507,18 +1044,22 @@ bool DetectX121SMCGuards(
// //
bool hasAnalyseGuard = bool hasAnalyseGuard =
// //
(hasAnalysePriceZone && false
isAnalysePriceZoneValidForPeak && //
isAnalysePriceZoneUpperRejected) // (hasAnalysePriceZone &&
// isAnalysePriceZoneValidForPeak &&
// isAnalysePriceZoneUpperRejected)
// //
; ;
// //
bool hasVerificationGuard = bool hasVerificationGuard =
// //
(hasVerificationPriceZone && false
isVerificationPriceZoneValidForPeak && //
isVerificationPriceZoneUpperRejected) // (hasVerificationPriceZone &&
// isVerificationPriceZoneValidForPeak &&
// isVerificationPriceZoneUpperRejected)
// //
; ;
@@ -1533,9 +1074,9 @@ bool DetectX121SMCGuards(
// //
double guardTP = double guardTP =
hasAnalyseGuard hasAnalyseGuard
? analysePriceZoneUpper ? 0 // analysePriceZoneUpper
: hasVerificationGuard : hasVerificationGuard
? verificationPriceZoneUpper ? 0 // verificationPriceZoneUpper
: 0; : 0;
// //
@@ -1582,18 +1123,22 @@ bool DetectX121SMCGuards(
// //
bool hasAnalyseGuard = bool hasAnalyseGuard =
// //
(hasAnalysePriceZone && false
isAnalysePriceZoneValidForVale && //
isAnalysePriceZoneLowerRejected) // (hasAnalysePriceZone &&
// isAnalysePriceZoneValidForVale &&
// isAnalysePriceZoneLowerRejected)
// //
; ;
// //
bool hasVerificationGuard = bool hasVerificationGuard =
// //
(hasVerificationPriceZone && false
isVerificationPriceZoneValidForVale && //
isVerificationPriceZoneLowerRejected) // (hasVerificationPriceZone &&
// isVerificationPriceZoneValidForVale &&
// isVerificationPriceZoneLowerRejected)
// //
; ;
@@ -1608,9 +1153,9 @@ bool DetectX121SMCGuards(
// //
double guardTP = double guardTP =
hasAnalyseGuard hasAnalyseGuard
? analysePriceZoneLower ? 0 // analysePriceZoneLower
: hasVerificationGuard : hasVerificationGuard
? verificationPriceZoneLower ? 0 // verificationPriceZoneLower
: 0; : 0;
// //
@@ -1667,10 +1212,10 @@ bool DetectX121SMCGuards(
Clean(ownShortPositions); Clean(ownShortPositions);
// //
x121SMCAnalysePriceZone.Clean(); // x121SMCAnalysePriceZone.Clean();
x121SMCDecisionPriceZone.Clean(); // x121SMCDecisionPriceZone.Clean();
x121SMCConsolidationZone.Clean(); // x121SMCConsolidationZone.Clean();
x121SMCVerificationPriceZone.Clean(); // x121SMCVerificationPriceZone.Clean();
// //
// Release Arrays ... // Release Arrays ...
File diff suppressed because it is too large Load Diff
+4 -578
View File
@@ -54,10 +54,6 @@ struct X121SMCStrategyXSignalConditions
double pivot; double pivot;
double point; double point;
//
XCOrderBlock *bullishOBs[];
XCOrderBlock *bearishOBs[];
// //
// Constructor ... // Constructor ...
X121SMCStrategyXSignalConditions() X121SMCStrategyXSignalConditions()
@@ -180,34 +176,6 @@ struct X121SMCStrategyXSignalConditions
point = 0; 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 ... // 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 ... // 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 = bool isCondition1Bullish =
// //
hasSameCyclesPV && false
isCBarBullishFormed &&
priceInsideOB.IsBullish() &&
//
(decisionXConditions.isBreakedUpPrevSar ||
decisionXConditions.isBreakedUpPrevStr ||
decisionXConditions.isVWapMaxBreakedUp ||
decisionXConditions.isBreakedUpPrevCheMax ||
decisionXConditions.isBreakedUpPrevAtrLower) &&
//
(decisionXConditions.isSarSwitchedToBullish ||
decisionXConditions.isStrSwitchedToBullish ||
decisionXConditions.isCheSwitchedToBullish ||
decisionXConditions.isVWapSwitchedToBullishState ||
decisionXConditions.isVWapSwitchedToBullishOrdered)
// //
; ;
// //
bool isCondition1Bearish = bool isCondition1Bearish =
// //
hasSameCyclesPV && false
isCBarBearishFormed &&
priceInsideOB.IsBearish() &&
//
(decisionXConditions.isBreakedDownPrevSar ||
decisionXConditions.isBreakedDownPrevStr ||
decisionXConditions.isVWapMinBreakedDown ||
decisionXConditions.isBreakedDownPrevCheMin ||
decisionXConditions.isBreakedDownPrevAtrUpper) &&
//
(decisionXConditions.isSarSwitchedToBearish ||
decisionXConditions.isStrSwitchedToBearish ||
decisionXConditions.isCheSwitchedToBearish ||
decisionXConditions.isVWapSwitchedToBearishState ||
decisionXConditions.isVWapSwitchedToBearishOrdered)
// //
; ;
@@ -1243,8 +669,8 @@ bool DetectX121SMCXSignalSetup(
// //
conditions.pivot = conditions.pivot =
isCondition1Bullish isCondition1Bullish
? priceInsideOB.Upper() ? 0 // priceInsideOB.Upper()
: priceInsideOB.Lower(); : 0; // priceInsideOB.Lower();
} }
// //
+303 -434
View File
@@ -26,6 +26,53 @@
#include "../Libraries/x-121.smc.guard.lib.mq5" #include "../Libraries/x-121.smc.guard.lib.mq5"
#include "../Libraries/x-121.smc.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 ... // Definitions ...
struct X121SMCStrategyXOBSSignalConditions struct X121SMCStrategyXOBSSignalConditions
@@ -56,18 +103,7 @@ struct X121SMCStrategyXOBSSignalConditions
// //
// Extwnsion ... // Extwnsion ...
XOBTest obTests[];
//
datetime cOBAt;
XCOrderBlock *cOB;
bool isCOBActivated;
datetime cOBActivatedAt;
//
datetime aOBAt;
XCOrderBlock *aOB;
bool isAOBActivated;
datetime aOBActivatedAt;
// //
// Constructor ... // Constructor ...
@@ -191,16 +227,7 @@ struct X121SMCStrategyXOBSSignalConditions
point = 0; point = 0;
// //
cOB = NULL; Clean(obTests);
cOBAt = NULL;
cOBActivatedAt = NULL;
isCOBActivated = false;
//
aOB = NULL;
aOBAt = NULL;
aOBActivatedAt = NULL;
isAOBActivated = false;
} }
// //
@@ -434,84 +461,6 @@ bool DetectX121SMCXOBSSignalSetup(
// //
// Setup Conditions ... // 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 ... // Detect Bar State ...
@@ -730,350 +679,36 @@ bool DetectX121SMCXOBSSignalSetup(
; ;
// //
// Detect OrderBlocks ... // Detect Order Flow ...
// //
bool hasCOB = // Test Market For Order Flow ...
conditions.cOB != NULL && int obTestsCount = ArraySize(conditions.obTests);
conditions.cOB.IsValid() && bool isOBTested = obTestsCount == 2;
IsValid(conditions.cOBAt); if (!isOBTested)
//
if (!hasCOB)
{ {
// //
int poiEvntsCount = ArraySize(consolidationPoiEvents); XOBTest test;
bool hasEvent = IsValidSize(poiEvntsCount); bool hasTest = ReTestMarket(
if (hasEvent) test,
conditions.obTests,
consolidationState,
analyseState,
decisionState,
visionCycleHelper.mPOIDrawer //
);
if (hasTest)
{ {
// //
bool hasNewBullOB = Contains( AddRef(
X_BULLISH_ORDERBLOCK_DETECTED, test,
consolidationPoiEvents // conditions.obTests);
);
//
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);
}
}
} }
} }
// //
if (hasCOB) // TODO:
{ return false;
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;
}
// //
double upper = 0; 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;
}
//
+4 -752
View File
@@ -29,9 +29,6 @@
// //
#include "../Signals/x-121.smc.x.signal.lib.mq5" #include "../Signals/x-121.smc.x.signal.lib.mq5"
#include "../Signals/x-121.smc.xobs.signal.lib.mq5" #include "../Signals/x-121.smc.xobs.signal.lib.mq5"
#include "../Signals/x-121.smc.xhkpv.signal.lib.mq5"
#include "../Signals/x-121.smc.xobpv.signal.lib.mq5"
#include "../Signals/x-121.smc.xiobpv.signal.lib.mq5"
// //
// Definitions ... // Definitions ...
@@ -47,9 +44,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// Props ... // Props ...
bool useXSignal; bool useXSignal;
bool useXOBSSignal; bool useXOBSSignal;
bool useXHKPVSignal;
bool useXOBPVSignal;
bool useXIOBPVSignal;
// //
// Constructor(s) ... // Constructor(s) ...
@@ -68,15 +62,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// Deconstructur ... // Deconstructur ...
void ~XCX121SMCStrategy() void ~XCX121SMCStrategy()
{ {
//
Destroy(); Destroy();
//
Clean(mXConditionsCollection);
Clean(mXOBSConditionsCollection);
Clean(mXHKPVConditionsCollection);
Clean(mXOBPVConditionsCollection);
Clean(mXIOBPVConditionsCollection);
} }
// //
@@ -117,6 +103,10 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
*/ */
void Destroy() override void Destroy() override
{ {
//
Clean(mXConditionsCollection);
Clean(mXOBSConditionsCollection);
// //
ZeroMemory(mTriggerCycleHelper); ZeroMemory(mTriggerCycleHelper);
ZeroMemory(mDecisionCycleHelper); ZeroMemory(mDecisionCycleHelper);
@@ -212,9 +202,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// //
bool hasXSignal = false; bool hasXSignal = false;
bool hasXOBSSignal = false; bool hasXOBSSignal = false;
bool hasXHKPVSignal = false;
bool hasXOBPVSignal = false;
bool hasXIOBPVSignal = false;
// //
// X Signal ... // X Signal ...
@@ -234,33 +221,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
hasSignal = hasXOBSSignal; hasSignal = hasXOBSSignal;
} }
//
// XHKPV Signal ...
if (useXHKPVSignal && !hasSignal)
{
//
hasXHKPVSignal = DetectXHKPVSignal(conditions);
hasSignal = hasXHKPVSignal;
}
//
// XOBPV Signal ...
if (useXOBPVSignal && !hasSignal)
{
//
hasXOBPVSignal = DetectXOBPVSignal(conditions);
hasSignal = hasXOBPVSignal;
}
//
// XIOBPV Signal ...
if (useXIOBPVSignal && !hasSignal)
{
//
hasXIOBPVSignal = DetectXIOBPVSignal(conditions);
hasSignal = hasXIOBPVSignal;
}
// //
result = hasSignal; result = hasSignal;
if (!result) if (!result)
@@ -450,57 +410,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
); );
} }
//
// XHKPV Guard Detection ...
if (useXHKPVSignal)
{
//
bool hasGuard = DetectX121SMCXHKPVGuards(
guards,
positions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
}
//
// XOBPV Guard Detection ...
if (useXOBPVSignal)
{
//
bool hasGuard = DetectX121SMCXOBPVGuards(
guards,
positions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
}
//
// XIOBPV Guard Detection ...
if (useXIOBPVSignal)
{
//
bool hasGuard = DetectX121SMCXIOBPVGuards(
guards,
positions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
}
// //
count = ArraySize(guards); count = ArraySize(guards);
result = IsValidSize(count); result = IsValidSize(count);
@@ -992,660 +901,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
return result; return result;
} }
//
// XHKPV Signal ...
bool DetectXHKPVSignal(
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_XHKPV;
string providerStr = ToString(provider);
//
// Detect Setup Conditions ...
datetime setupTime = mXHKPVConditions.setupTime;
bool isSetuped = mXHKPVConditions.IsSetuped();
ENUM_X_DIRECTION setupDir = mXHKPVConditions.dir;
if (!isSetuped)
{
//
// Detect Signal Setup ...
isSetuped = DetectX121SMCXHKPVSignalSetup(
symbol,
period,
mXHKPVConditions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
setupDir = mXHKPVConditions.dir;
setupTime = mXHKPVConditions.setupTime;
//
if (isSetuped)
{
//
int items = AddX121SMCXHKPVConditionsIfNotExists(
mXHKPVConditions,
mXHKPVConditionsCollection //
);
//
mXHKPVConditions.Clean();
}
}
//
int conditionsCount = ArraySize(mXHKPVConditionsCollection);
result = IsValidSize(conditionsCount);
if (!result)
{
return result;
}
//
// Looking For Conditions ...
int selectedIndex = 0;
X121SMCStrategyXHKPVSignalConditions mTmpConditions[];
Copy(
mXHKPVConditionsCollection,
mTmpConditions //
);
X121SMCStrategyXHKPVSignalConditions 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 = DetectX121SMCXHKPVSignalTrigger(
mTmpConditions[i],
symbol,
period,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
result = canTrigger;
if (!result)
{
//
bool isISetuped = mTmpConditions[i].IsSetuped();
if (!isISetuped)
{
//
ArrayRemove(
mXHKPVConditionsCollection,
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(
mXHKPVConditionsCollection,
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;
}
//
// XOBPV Signal ...
bool DetectXOBPVSignal(
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_XOBPV;
string providerStr = ToString(provider);
//
// Detect Setup Conditions ...
datetime setupTime = mXOBPVConditions.setupTime;
bool isSetuped = mXOBPVConditions.IsSetuped();
ENUM_X_DIRECTION setupDir = mXOBPVConditions.dir;
if (!isSetuped)
{
//
// Detect Signal Setup ...
isSetuped = DetectX121SMCXOBPVSignalSetup(
symbol,
period,
mXOBPVConditions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
setupDir = mXOBPVConditions.dir;
setupTime = mXOBPVConditions.setupTime;
//
if (isSetuped)
{
//
int items = AddX121SMCXOBPVConditionsIfNotExists(
mXOBPVConditions,
mXOBPVConditionsCollection //
);
//
mXOBPVConditions.Clean();
}
}
//
int conditionsCount = ArraySize(mXOBPVConditionsCollection);
result = IsValidSize(conditionsCount);
if (!result)
{
return result;
}
//
// Looking For Conditions ...
int selectedIndex = 0;
X121SMCStrategyXOBPVSignalConditions mTmpConditions[];
Copy(
mXOBPVConditionsCollection,
mTmpConditions //
);
X121SMCStrategyXOBPVSignalConditions 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 = DetectX121SMCXOBPVSignalTrigger(
mTmpConditions[i],
symbol,
period,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
result = canTrigger;
if (!result)
{
//
bool isISetuped = mTmpConditions[i].IsSetuped();
if (!isISetuped)
{
//
ArrayRemove(
mXOBPVConditionsCollection,
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(
mXOBPVConditionsCollection,
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;
}
//
// XIOBPV Signal ...
bool DetectXIOBPVSignal(
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_XIOBPV;
string providerStr = ToString(provider);
//
// Detect Setup Conditions ...
datetime setupTime = mXIOBPVConditions.setupTime;
bool isSetuped = mXIOBPVConditions.IsSetuped();
ENUM_X_DIRECTION setupDir = mXIOBPVConditions.dir;
if (!isSetuped)
{
//
// Detect Signal Setup ...
isSetuped = DetectX121SMCXIOBPVSignalSetup(
symbol,
period,
mXIOBPVConditions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
setupDir = mXIOBPVConditions.dir;
setupTime = mXIOBPVConditions.setupTime;
//
if (isSetuped)
{
//
int items = AddX121SMCXIOBPVConditionsIfNotExists(
mXIOBPVConditions,
mXIOBPVConditionsCollection //
);
//
mXIOBPVConditions.Clean();
}
}
//
int conditionsCount = ArraySize(mXIOBPVConditionsCollection);
result = IsValidSize(conditionsCount);
if (!result)
{
return result;
}
//
// Looking For Conditions ...
int selectedIndex = 0;
X121SMCStrategyXIOBPVSignalConditions mTmpConditions[];
Copy(
mXIOBPVConditionsCollection,
mTmpConditions //
);
X121SMCStrategyXIOBPVSignalConditions 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 = DetectX121SMCXIOBPVSignalTrigger(
mTmpConditions[i],
symbol,
period,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
result = canTrigger;
if (!result)
{
//
bool isISetuped = mTmpConditions[i].IsSetuped();
if (!isISetuped)
{
//
ArrayRemove(
mXIOBPVConditionsCollection,
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(
mXIOBPVConditionsCollection,
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 ...
private: private:
@@ -1663,9 +918,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// //
useXSignal = false; useXSignal = false;
useXOBSSignal = true; useXOBSSignal = true;
useXHKPVSignal = false;
useXOBPVSignal = false;
useXIOBPVSignal = false;
// //
string symbol = GetSymbol(); string symbol = GetSymbol();