diff --git a/Classes/x-saherelm.x-poi.drawer.class.mq5 b/Classes/x-saherelm.x-poi.drawer.class.mq5 index 4a5872a0..ec793199 100644 --- a/Classes/x-saherelm.x-poi.drawer.class.mq5 +++ b/Classes/x-saherelm.x-poi.drawer.class.mq5 @@ -1286,33 +1286,42 @@ class XCPOIDrawer : public XCBase SubWindowIdentification(0); // - SwingLowWidth(3); + int arrowWidth = 1; + + // SwingLowArrow(108); SwingLowColor(clrAqua); + SwingLowWidth(arrowWidth); // - SwingHighWidth(3); SwingHighArrow(108); + SwingHighWidth(arrowWidth); SwingHighColor(clrMagenta); // - BullishMomentumBarWidth(3); + arrowWidth++; + + // BullishMomentumBarArrow(225); + BullishMomentumBarWidth(arrowWidth); BullishMomentumBarColor(clrAqua); // - BearishMomentumBarWidth(3); BearishMomentumBarArrow(226); + BearishMomentumBarWidth(arrowWidth); BearishMomentumBarColor(clrMagenta); // - BullishRejectionBarWidth(3); + arrowWidth++; + + // BullishRejectionBarArrow(217); + BullishRejectionBarWidth(arrowWidth); BullishRejectionBarColor(clrAqua); // - BearishRejectionBarWidth(3); BearishRejectionBarArrow(218); + BearishRejectionBarWidth(arrowWidth); BearishRejectionBarColor(clrMagenta); // @@ -2273,8 +2282,8 @@ class XCPOIDrawer : public XCBase bool CreateTicksZone( XCTicksZone &zone, - XCTicksZoneObject *&object - ) { + XCTicksZoneObject *&object) + { // bool result = false; diff --git a/X121SMCEA/Libraries/x-121.smc.lib.mq5 b/X121SMCEA/Libraries/x-121.smc.lib.mq5 index 14cade19..4a2b71ce 100644 --- a/X121SMCEA/Libraries/x-121.smc.lib.mq5 +++ b/X121SMCEA/Libraries/x-121.smc.lib.mq5 @@ -31,6 +31,8 @@ const string X121SMCStrategyToken = "X121SMC"; +// +// Model Signalling Conditions ... struct X121SMCStrategyConditions { // @@ -40,53 +42,95 @@ struct X121SMCStrategyConditions // // D1 ... + + // XPOIState d1State; ENUM_X_DIRECTION d1MarketDirection; XCSupportZone *d1SupportZones[]; XCResistanceZone *d1ResistanceZones[]; + // + XCSwing *d1SwingHigh; + XCSwing *d1SwingLow; + // // H4 ... + + // XPOIState h4State; ENUM_X_DIRECTION h4MarketDirection; XCSupportZone *h4SupportZones[]; XCResistanceZone *h4ResistanceZones[]; + // + XCSwing *h4SwingHigh; + XCSwing *h4SwingLow; + // // H2 ... + + // XPOIState h2State; ENUM_X_DIRECTION h2MarketDirection; XCSupportZone *h2SupportZones[]; XCResistanceZone *h2ResistanceZones[]; + // + XCSwing *h2SwingHigh; + XCSwing *h2SwingLow; + // // H1 ... + + // XPOIState h1State; ENUM_X_DIRECTION h1MarketDirection; XCSupportZone *h1SupportZones[]; XCResistanceZone *h1ResistanceZones[]; + // + XCSwing *h1SwingHigh; + XCSwing *h1SwingLow; + // // M15 ... + + // XPOIState m15State; ENUM_X_DIRECTION m15MarketDirection; XCSupportZone *m15SupportZones[]; XCResistanceZone *m15ResistanceZones[]; + // + XCSwing *m15SwingHigh; + XCSwing *m15SwingLow; + // // M5 ... + + // XPOIState m5State; ENUM_X_DIRECTION m5MarketDirection; XCSupportZone *m5SupportZones[]; XCResistanceZone *m5ResistanceZones[]; + // + XCSwing *m5SwingHigh; + XCSwing *m5SwingLow; + // // M1 ... + + // XPOIState m1State; ENUM_X_DIRECTION m1MarketDirection; XCSupportZone *m1SupportZones[]; XCResistanceZone *m1ResistanceZones[]; + // + XCSwing *m1SwingHigh; + XCSwing *m1SwingLow; + // void X121SMCStrategyConditions() { @@ -108,52 +152,94 @@ struct X121SMCStrategyConditions // // D1 ... + + // d1State.Clean(); d1MarketDirection = X_DIRECTION_NONE; Clean(d1SupportZones); Clean(d1ResistanceZones); + // + d1SwingHigh = NULL; + d1SwingLow = NULL; + // // H4 ... + + // h4State.Clean(); h4MarketDirection = X_DIRECTION_NONE; Clean(h4SupportZones); Clean(h4ResistanceZones); + // + h4SwingHigh = NULL; + h4SwingLow = NULL; + // // H2 ... + + // h2State.Clean(); h2MarketDirection = X_DIRECTION_NONE; Clean(h2SupportZones); Clean(h2ResistanceZones); + // + h2SwingHigh = NULL; + h2SwingLow = NULL; + // // H1 ... + + // h1State.Clean(); h1MarketDirection = X_DIRECTION_NONE; Clean(h1SupportZones); Clean(h1ResistanceZones); + // + h1SwingHigh = NULL; + h1SwingLow = NULL; + // // M15 ... + + // m15State.Clean(); m15MarketDirection = X_DIRECTION_NONE; Clean(m15SupportZones); Clean(m15ResistanceZones); + // + m15SwingHigh = NULL; + m15SwingLow = NULL; + // // M5 ... + + // m5State.Clean(); m5MarketDirection = X_DIRECTION_NONE; Clean(m5SupportZones); Clean(m5ResistanceZones); + // + m5SwingHigh = NULL; + m5SwingLow = NULL; + // // M1 ... + + // m1State.Clean(); m1MarketDirection = X_DIRECTION_NONE; Clean(m1SupportZones); Clean(m1ResistanceZones); + + // + m1SwingHigh = NULL; + m1SwingLow = NULL; } /** @@ -268,6 +354,9 @@ struct X121SMCStrategyConditions return result; } + // + // Reporter Functions ... + /** * Generate Provided Scores ... * diff --git a/X121SMCEA/Strategy/x-121.smc.test.strategy.class.mq5 b/X121SMCEA/Strategy/x-121.smc.test.strategy.class.mq5 index d3096dd5..9b67a041 100644 --- a/X121SMCEA/Strategy/x-121.smc.test.strategy.class.mq5 +++ b/X121SMCEA/Strategy/x-121.smc.test.strategy.class.mq5 @@ -176,8 +176,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy // // Try to Implement SMC Based Conditions ... - ENUM_X_DIRECTION dir = X_DIRECTION_NONE; - result = DetectConditions(dir); + result = DetectConditions(); if (!result) { return result; @@ -316,7 +315,12 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy // // Actions ... - bool DetectConditions(ENUM_X_DIRECTION &dir) + /** + * Detect and Parse Market Conditions ... + * + * @return ( bool ) + */ + bool DetectConditions() { // bool result = false; @@ -327,9 +331,6 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy mConditions.period = GetPeriod(); mConditions.time = TimeCurrent(); - // - dir = X_DIRECTION_NONE; - // // Detect Market Structures ... @@ -338,6 +339,8 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy mConditions.d1State = _1DState; result = DetectMarketStructure( mConditions.d1MarketDirection, + mConditions.d1SupportZones, + mConditions.d1ResistanceZones, _1DState // ); if (!result) @@ -346,14 +349,14 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy mConditions.Clean(); return result; } - bool is1DBullish = IsBullish(mConditions.d1MarketDirection); - bool is1DBearish = IsBearish(mConditions.d1MarketDirection); // // 4H ... mConditions.h4State = _4HState; result = DetectMarketStructure( mConditions.h4MarketDirection, + mConditions.h4SupportZones, + mConditions.h4ResistanceZones, _4HState // ); if (!result) @@ -362,14 +365,14 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy mConditions.Clean(); return result; } - bool is4HBullish = IsBullish(mConditions.h4MarketDirection); - bool is4HBearish = IsBearish(mConditions.h4MarketDirection); // // 2H ... mConditions.h2State = _2HState; result = DetectMarketStructure( mConditions.h2MarketDirection, + mConditions.h2SupportZones, + mConditions.h2ResistanceZones, _2HState // ); if (!result) @@ -378,14 +381,14 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy mConditions.Clean(); return result; } - bool is2HBullish = IsBullish(mConditions.h2MarketDirection); - bool is2HBearish = IsBearish(mConditions.h2MarketDirection); // // 1H ... mConditions.h1State = _1HState; result = DetectMarketStructure( mConditions.h1MarketDirection, + mConditions.h1SupportZones, + mConditions.h1ResistanceZones, _1HState // ); if (!result) @@ -394,14 +397,14 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy mConditions.Clean(); return result; } - bool is1HBullish = IsBullish(mConditions.h1MarketDirection); - bool is1HBearish = IsBearish(mConditions.h1MarketDirection); // // 15M ... mConditions.m15State = _15MState; result = DetectMarketStructure( mConditions.m15MarketDirection, + mConditions.m15SupportZones, + mConditions.m15ResistanceZones, _15MState // ); if (!result) @@ -410,14 +413,14 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy mConditions.Clean(); return result; } - bool is15MBullish = IsBullish(mConditions.m15MarketDirection); - bool is15MBearish = IsBearish(mConditions.m15MarketDirection); // // 5M ... mConditions.m5State = _5MState; result = DetectMarketStructure( mConditions.m5MarketDirection, + mConditions.m5SupportZones, + mConditions.m5ResistanceZones, _5MState // ); if (!result) @@ -426,14 +429,14 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy mConditions.Clean(); return result; } - bool is5MBullish = IsBullish(mConditions.m5MarketDirection); - bool is5MBearish = IsBearish(mConditions.m5MarketDirection); // // 1M ... mConditions.m1State = _1MState; result = DetectMarketStructure( mConditions.m1MarketDirection, + mConditions.m1SupportZones, + mConditions.m1ResistanceZones, _1MState // ); if (!result) @@ -442,10 +445,9 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy mConditions.Clean(); return result; } - bool is1MBullish = IsBullish(mConditions.m1MarketDirection); - bool is1MBearish = IsBearish(mConditions.m1MarketDirection); // + // 1H-15M-5M ... ENUM_X_DIRECTION marketStructure = X_DIRECTION_NONE; result = mConditions.HasMarketStructure(marketStructure); if (!result) @@ -456,7 +458,339 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy } // - DrawState(_5MState); + // Detect Swing High and Swing Low ... + // 1H-15M-5M ... + int count = 0; + + // + // 1H ... + + // + XCSwing *h1SwingLows[]; + XCSwing *h1SwingHighs[]; + XCSupportZone *h1SupportZone = NULL; + XCResistanceZone *h1ResistanceZone = NULL; + + // + count = ArraySize(mConditions.h1SupportZones); + if (IsValidSize(count)) + { + // + for (int i = 0; i < count; i++) + { + // + XCSupportZone *item = mConditions.h1SupportZones[i]; + + // + bool canSelect = + h1SupportZone == NULL || + h1SupportZone.Lower() < item.Lower(); + if (canSelect) + { + h1SupportZone = item; + } + } + } + if (h1SupportZone != NULL) + { + // + // Detect Swings ... + count = ArraySize(mConditions.h1State.swingLows); + if (IsValidSize(count)) + { + // + double upper = h1SupportZone.Upper(); + double lower = h1SupportZone.Lower(); + + // + for (int i = 0; i < count; i++) + { + // + XCSwing *item = mConditions.h1State.swingLows[i]; + + // + XOHCL iBar; + bool isFilled = item.FillBar(iBar); + if (!isFilled) + { + continue; + } + + // + bool canSelect = (iBar.high <= upper && + iBar.low >= lower) || + (iBar.high >= upper && + iBar.low <= lower); + if (canSelect) + { + // + Add( + item, + h1SwingLows // + ); + + // + // Draw ... + XCSwingLowObject *iObj; + bool isCreated = mPOIDrawer.CreateSwingLow( + item, + iObj // + ); + if (isCreated) + { + AddObjectIfNotExists(iObj); + } + } + } + } + + // + // Draw ... + XCSupportZoneObject *iObj; + bool isCreated = mPOIDrawer.CreateSupportZone( + h1SupportZone, + iObj // + ); + if (isCreated) + { + AddObjectIfNotExists(iObj); + } + } + + // + count = ArraySize(mConditions.h1ResistanceZones); + if (IsValidSize(count)) + { + // + for (int i = 0; i < count; i++) + { + // + XCResistanceZone *item = mConditions.h1ResistanceZones[i]; + + // + bool canSelect = + h1ResistanceZone == NULL || + h1ResistanceZone.Upper() > item.Upper(); + if (canSelect) + { + h1ResistanceZone = item; + } + } + } + if (h1ResistanceZone != NULL) + { + // + // Detect Swings ... + count = ArraySize(mConditions.h1State.swingHighs); + if (IsValidSize(count)) + { + // + double upper = h1ResistanceZone.Upper(); + double lower = h1ResistanceZone.Lower(); + + // + for (int i = 0; i < count; i++) + { + // + XCSwing *item = mConditions.h1State.swingHighs[i]; + + // + XOHCL iBar; + bool isFilled = item.FillBar(iBar); + if (!isFilled) + { + continue; + } + + // + bool canSelect = (iBar.high <= upper && + iBar.low >= lower) || + (iBar.high >= upper && + iBar.low <= lower); + if (canSelect) + { + // + Add( + item, + h1SwingHighs // + ); + + // + // Draw ... + XCSwingHighObject *iObj; + bool isCreated = mPOIDrawer.CreateSwingHigh( + item, + iObj // + ); + if (isCreated) + { + AddObjectIfNotExists(iObj); + } + } + } + } + + // + // Draw ... + XCResistanceZoneObject *iObj; + bool isCreated = mPOIDrawer.CreateResistanceZone( + h1ResistanceZone, + iObj // + ); + if (isCreated) + { + AddObjectIfNotExists(iObj); + } + } + + // + // 15M ... + + // + XCSupportZone *m15SupportZone = NULL; + count = ArraySize(mConditions.m15SupportZones); + if (IsValidSize(count)) + { + // + for (int i = 0; i < count; i++) + { + // + XCSupportZone *item = mConditions.m15SupportZones[i]; + + // + bool canSelect = + m15SupportZone == NULL || + m15SupportZone.Lower() < item.Lower(); + if (canSelect) + { + m15SupportZone = item; + } + } + } + if (m15SupportZone != NULL) + { + // + XCSupportZoneObject *iObj; + bool isCreated = mPOIDrawer.CreateSupportZone( + m15SupportZone, + iObj // + ); + if (isCreated) + { + AddObjectIfNotExists(iObj); + } + } + + // + XCResistanceZone *m15ResistanceZone = NULL; + count = ArraySize(mConditions.m15ResistanceZones); + if (IsValidSize(count)) + { + // + for (int i = 0; i < count; i++) + { + // + XCResistanceZone *item = mConditions.m15ResistanceZones[i]; + + // + bool canSelect = + m15ResistanceZone == NULL || + m15ResistanceZone.Upper() > item.Upper(); + if (canSelect) + { + m15ResistanceZone = item; + } + } + } + if (m15ResistanceZone != NULL) + { + // + XCResistanceZoneObject *iObj; + bool isCreated = mPOIDrawer.CreateResistanceZone( + m15ResistanceZone, + iObj // + ); + if (isCreated) + { + AddObjectIfNotExists(iObj); + } + } + + // + // 5M ... + + // + XCSupportZone *m5SupportZone = NULL; + count = ArraySize(mConditions.m5SupportZones); + if (IsValidSize(count)) + { + // + for (int i = 0; i < count; i++) + { + // + XCSupportZone *item = mConditions.m5SupportZones[i]; + + // + bool canSelect = + m5SupportZone == NULL || + m5SupportZone.Lower() < item.Lower(); + if (canSelect) + { + m5SupportZone = item; + } + } + } + if (m5SupportZone != NULL) + { + // + XCSupportZoneObject *iObj; + bool isCreated = mPOIDrawer.CreateSupportZone( + m5SupportZone, + iObj // + ); + if (isCreated) + { + AddObjectIfNotExists(iObj); + } + } + + // + XCResistanceZone *m5ResistanceZone = NULL; + count = ArraySize(mConditions.m5ResistanceZones); + if (IsValidSize(count)) + { + // + for (int i = 0; i < count; i++) + { + // + XCResistanceZone *item = mConditions.m5ResistanceZones[i]; + + // + bool canSelect = + m5ResistanceZone == NULL || + m5ResistanceZone.Upper() > item.Upper(); + if (canSelect) + { + m5ResistanceZone = item; + } + } + } + if (m5ResistanceZone != NULL) + { + // + XCResistanceZoneObject *iObj; + bool isCreated = mPOIDrawer.CreateResistanceZone( + m5ResistanceZone, + iObj // + ); + if (isCreated) + { + AddObjectIfNotExists(iObj); + } + } + + // + // DrawState(_5MState); // return result; @@ -472,6 +806,8 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy */ bool DetectMarketStructure( ENUM_X_DIRECTION &dir, + XCSupportZone *&supportZones[], + XCResistanceZone *&resistanceZones[], XPOIState &state // ) { @@ -483,8 +819,8 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy // // Filter Untouched Supports ... + Clean(supportZones); int untouchedSupportsCount = 0; - XCSupportZone *untouchedSupportZones[]; count = ArraySize(state.supportZones); if (IsValidSize(count)) { @@ -539,13 +875,13 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy // Add( item, - untouchedSupportZones // + supportZones // ); } } // - untouchedSupportsCount = ArraySize(untouchedSupportZones); + untouchedSupportsCount = ArraySize(supportZones); if (IsValidSize(untouchedSupportsCount)) { // @@ -553,7 +889,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy // for (int i = 0; i < untouchedSupportsCount; i++) // { // // - // XCSupportZone *item = untouchedSupportZones[i]; + // XCSupportZone *item = supportZones[i]; // // // XCSupportZoneObject *iObj; @@ -571,8 +907,8 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy // // Filter Untouched Resistances ... + Clean(resistanceZones); int untouchedResistancesCount = 0; - XCResistanceZone *untouchedResistanceZones[]; count = ArraySize(state.resistanceZones); if (IsValidSize(count)) { @@ -627,13 +963,13 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy // Add( item, - untouchedResistanceZones // + resistanceZones // ); } } // - untouchedResistancesCount = ArraySize(untouchedResistanceZones); + untouchedResistancesCount = ArraySize(resistanceZones); if (IsValidSize(untouchedResistancesCount)) { // @@ -641,7 +977,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy // for (int i = 0; i < untouchedResistancesCount; i++) // { // // - // XCResistanceZone *item = untouchedResistanceZones[i]; + // XCResistanceZone *item = resistanceZones[i]; // // // XCResistanceZoneObject *iObj;