diff --git a/Classes/x-saherelm.x-chart-objects.class.mq5 b/Classes/x-saherelm.x-chart-objects.class.mq5 index 4c1fbeb1..398dd25e 100644 --- a/Classes/x-saherelm.x-chart-objects.class.mq5 +++ b/Classes/x-saherelm.x-chart-objects.class.mq5 @@ -799,6 +799,9 @@ class XCSignalObject : public XCBaseObject return result; } + // + string nameMD5 = ToMD5(name); + // int delay = (PeriodSeconds(signal.period) * 2); datetime time1 = (datetime)((int)signal.time - delay); @@ -806,7 +809,7 @@ class XCSignalObject : public XCBaseObject // // TP ... - string tpName = ToString(X_TP) + "_" + name; + string tpName = ToString(X_TP) + "_" + nameMD5; result = mTPTrend.Create( chart_id, tpName, @@ -823,7 +826,7 @@ class XCSignalObject : public XCBaseObject // // SL ... - string slName = ToString(X_SL) + "_" + name; + string slName = ToString(X_SL) + "_" + nameMD5; result = mSLTrend.Create( chart_id, slName, @@ -842,7 +845,7 @@ class XCSignalObject : public XCBaseObject // // ENTRY ... - string entrName = ToString(X_ENTRY) + "_" + name; + string entrName = ToString(X_ENTRY) + "_" + nameMD5; result = mEntryTrend.Create( chart_id, entrName, diff --git a/Classes/x-saherelm.x-poi.drawer.class.mq5 b/Classes/x-saherelm.x-poi.drawer.class.mq5 index 103484cd..77b51714 100644 --- a/Classes/x-saherelm.x-poi.drawer.class.mq5 +++ b/Classes/x-saherelm.x-poi.drawer.class.mq5 @@ -1738,7 +1738,8 @@ class XCPOIDrawer : public XSCBase */ bool CreateResistanceZone( XOHCL &bar, - XCResistanceZoneObject *&object // + XCResistanceZoneObject *&object, + datetime destTime = NULL // ) { // @@ -1762,7 +1763,10 @@ class XCPOIDrawer : public XSCBase string name = bar.GetTag(ToString(X_POI_RESISTANCE_ZONE)); // - datetime time2 = (datetime)((int)bar.time + (PeriodSeconds(bar.period) * 5)); + datetime time2 = + IsValid(destTime) + ? destTime + : (datetime)((int)bar.time + (PeriodSeconds(bar.period) * 5)); // bool fill = ResistanceZoneFill(); diff --git a/Documents/BKP/121.smc.poi.detector.mq5 b/Documents/BKP/121.smc.poi.detector.mq5 new file mode 100644 index 00000000..2704e058 --- /dev/null +++ b/Documents/BKP/121.smc.poi.detector.mq5 @@ -0,0 +1,1411 @@ + // // 4H ... + // int orderBlocksCount = ArraySize(h4State.bearishOrderBlocks); + // if (IsValidSize(orderBlocksCount)) + // { + // // + // for (int j = 0; j < orderBlocksCount; j++) + // { + // // + // XZone jZone = h4State.bearishOrderBlocks[j]; + + // // + // bool isInside = IsInside( + // jZone, + // iSupplyZone, + // X_ZONE_UPPER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // jZone.to = TimeCurrent(); + + // // + // AddIfNotExists( + // jZone, + // conditions.bearishOrderBlocks // + // ); + // } + // } + // } + // // 15M ... + // orderBlocksCount = ArraySize(m15State.bearishOrderBlocks); + // if (IsValidSize(orderBlocksCount)) + // { + // // + // for (int j = 0; j < orderBlocksCount; j++) + // { + // // + // XZone jZone = m15State.bearishOrderBlocks[j]; + + // // + // bool isInside = IsInside( + // jZone, + // iSupplyZone, + // X_ZONE_UPPER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // jZone.to = TimeCurrent(); + + // // + // AddIfNotExists( + // jZone, + // conditions.bearishOrderBlocks // + // ); + // } + // } + // } + // // 5M ... + // orderBlocksCount = ArraySize(m5State.bearishOrderBlocks); + // if (IsValidSize(orderBlocksCount)) + // { + // // + // for (int j = 0; j < orderBlocksCount; j++) + // { + // // + // XZone jZone = m5State.bearishOrderBlocks[j]; + + // // + // bool isInside = IsInside( + // jZone, + // iSupplyZone, + // X_ZONE_UPPER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // jZone.to = TimeCurrent(); + + // // + // AddIfNotExists( + // jZone, + // conditions.bearishOrderBlocks // + // ); + // } + // } + // } + // // 1M ... + // orderBlocksCount = ArraySize(m1State.bearishOrderBlocks); + // if (IsValidSize(orderBlocksCount)) + // { + // // + // for (int j = 0; j < orderBlocksCount; j++) + // { + // // + // XZone jZone = m1State.bearishOrderBlocks[j]; + + // // + // bool isInside = IsInside( + // jZone, + // iSupplyZone, + // X_ZONE_UPPER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // jZone.to = TimeCurrent(); + + // // + // AddIfNotExists( + // jZone, + // conditions.bearishOrderBlocks // + // ); + // } + // } + // } + + // // 4H ... + // int resistancesCount = ArraySize(h4State.resistanceZones); + // if (IsValidSize(resistancesCount)) + // { + // // + // for (int j = 0; j < resistancesCount; j++) + // { + // // + // XOHCL jBar = h4State.resistanceZones[j]; + + // // + // bool isInside = IsInside( + // jBar, + // iSupplyZone, + // X_ZONE_UPPER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.resistances // + // ); + // } + // } + // } + // // 15M ... + // resistancesCount = ArraySize(m15State.resistanceZones); + // if (IsValidSize(resistancesCount)) + // { + // // + // for (int j = 0; j < resistancesCount; j++) + // { + // // + // XOHCL jBar = m15State.resistanceZones[j]; + + // // + // bool isInside = IsInside( + // jBar, + // iSupplyZone, + // X_ZONE_UPPER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.resistances // + // ); + // } + // } + // } + // // 5M ... + // resistancesCount = ArraySize(m5State.resistanceZones); + // if (IsValidSize(resistancesCount)) + // { + // // + // for (int j = 0; j < resistancesCount; j++) + // { + // // + // XOHCL jBar = m5State.resistanceZones[j]; + + // // + // bool isInside = IsInside( + // jBar, + // iSupplyZone, + // X_ZONE_UPPER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.resistances // + // ); + // } + // } + // } + // // 1M ... + // resistancesCount = ArraySize(m1State.resistanceZones); + // if (IsValidSize(resistancesCount)) + // { + // // + // for (int j = 0; j < resistancesCount; j++) + // { + // // + // XOHCL jBar = m1State.resistanceZones[j]; + + // // + // bool isInside = IsInside( + // jBar, + // iSupplyZone, + // X_ZONE_UPPER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.resistances // + // ); + // } + // } + // } + + // // 4H ... + // int fvgsCount = ArraySize(h4State.bearishFVGs); + // if (IsValidSize(fvgsCount)) + // { + // // + // for (int j = 0; j < fvgsCount; j++) + // { + // // + // XZone jFVG = h4State.bearishFVGs[j]; + + // // + // bool isInside = IsInside( + // jFVG, + // iSupplyZone, + // X_ZONE_UPPER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // jFVG.to = TimeCurrent(); + + // // + // AddIfNotExists( + // jFVG, + // conditions.bearishFVGs // + // ); + // } + // } + // } + // // 15M ... + // fvgsCount = ArraySize(m15State.bearishFVGs); + // if (IsValidSize(fvgsCount)) + // { + // // + // for (int j = 0; j < fvgsCount; j++) + // { + // // + // XZone jFVG = m15State.bearishFVGs[j]; + + // // + // bool isInside = IsInside( + // jFVG, + // iSupplyZone, + // X_ZONE_UPPER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // jFVG.to = TimeCurrent(); + + // // + // AddIfNotExists( + // jFVG, + // conditions.bearishFVGs // + // ); + // } + // } + // } + // // 5M ... + // fvgsCount = ArraySize(m5State.bearishFVGs); + // if (IsValidSize(fvgsCount)) + // { + // // + // for (int j = 0; j < fvgsCount; j++) + // { + // // + // XZone jFVG = m5State.bearishFVGs[j]; + + // // + // bool isInside = IsInside( + // jFVG, + // iSupplyZone, + // X_ZONE_UPPER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // jFVG.to = TimeCurrent(); + + // // + // AddIfNotExists( + // jFVG, + // conditions.bearishFVGs // + // ); + // } + // } + // } + // // 1M ... + // fvgsCount = ArraySize(m1State.bearishFVGs); + // if (IsValidSize(fvgsCount)) + // { + // // + // for (int j = 0; j < fvgsCount; j++) + // { + // // + // XZone jFVG = m1State.bearishFVGs[j]; + + // // + // bool isInside = IsInside( + // jFVG, + // iSupplyZone, + // X_ZONE_UPPER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // jFVG.to = TimeCurrent(); + + // // + // AddIfNotExists( + // jFVG, + // conditions.bearishFVGs // + // ); + // } + // } + // } + + // // 4H ... + // int swingsCount = ArraySize(h4State.swingHighs); + // if (IsValidSize(swingsCount)) + // { + // // + // for (int j = 0; j < swingsCount; j++) + // { + // // + // XOHCL jBar = h4State.swingHighs[j]; + + // // + // bool isInside = IsInside( + // jBar, + // iSupplyZone, + // X_ZONE_UPPER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.swingHighs // + // ); + // } + // } + // } + // // 15M ... + // swingsCount = ArraySize(m15State.swingHighs); + // if (IsValidSize(swingsCount)) + // { + // // + // for (int j = 0; j < swingsCount; j++) + // { + // // + // XOHCL jBar = m15State.swingHighs[j]; + + // // + // bool isInside = IsInside( + // jBar, + // iSupplyZone, + // X_ZONE_UPPER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.swingHighs // + // ); + // } + // } + // } + // // 5M ... + // swingsCount = ArraySize(m5State.swingHighs); + // if (IsValidSize(swingsCount)) + // { + // // + // for (int j = 0; j < swingsCount; j++) + // { + // // + // XOHCL jBar = m5State.swingHighs[j]; + + // // + // bool isInside = IsInside( + // jBar, + // iSupplyZone, + // X_ZONE_UPPER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.swingHighs // + // ); + // } + // } + // } + // // 1M ... + // swingsCount = ArraySize(m1State.swingHighs); + // if (IsValidSize(swingsCount)) + // { + // // + // for (int j = 0; j < swingsCount; j++) + // { + // // + // XOHCL jBar = m1State.swingHighs[j]; + + // // + // bool isInside = IsInside( + // jBar, + // iSupplyZone, + // X_ZONE_UPPER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.swingHighs // + // ); + // } + // } + // } + + + // // 4H ... + // int momentumBarsCount = ArraySize(h4State.momentumBars); + // if (IsValidSize(momentumBarsCount)) + // { + // // + // for (int j = 0; j < momentumBarsCount; j++) + // { + // // + // XOHCL jBar = h4State.momentumBars[j]; + + // // + // bool isInside = + // jBar.IsBearish() && + // jBar.time > iSupplyZone.from && + // IsInside( + // jBar, + // iSupplyZone, + // X_ZONE_UPPER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.bearishMomentumBars // + // ); + // } + // } + // } + // // 15M ... + // momentumBarsCount = ArraySize(m15State.momentumBars); + // if (IsValidSize(momentumBarsCount)) + // { + // // + // for (int j = 0; j < momentumBarsCount; j++) + // { + // // + // XOHCL jBar = m15State.momentumBars[j]; + + // // + // bool isInside = + // jBar.IsBearish() && + // jBar.time > iSupplyZone.from && + // IsInside( + // jBar, + // iSupplyZone, + // X_ZONE_UPPER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.bearishMomentumBars // + // ); + // } + // } + // } + // // 5M ... + // momentumBarsCount = ArraySize(m5State.momentumBars); + // if (IsValidSize(momentumBarsCount)) + // { + // // + // for (int j = 0; j < momentumBarsCount; j++) + // { + // // + // XOHCL jBar = m5State.momentumBars[j]; + + // // + // bool isInside = + // jBar.IsBearish() && + // jBar.time > iSupplyZone.from && + // IsInside( + // jBar, + // iSupplyZone, + // X_ZONE_UPPER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.bearishMomentumBars // + // ); + // } + // } + // } + // // 1M ... + // momentumBarsCount = ArraySize(m1State.momentumBars); + // if (IsValidSize(momentumBarsCount)) + // { + // // + // for (int j = 0; j < momentumBarsCount; j++) + // { + // // + // XOHCL jBar = m1State.momentumBars[j]; + + // // + // bool isInside = + // jBar.IsBearish() && + // jBar.time > iSupplyZone.from && + // IsInside( + // jBar, + // iSupplyZone, + // X_ZONE_UPPER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.bearishMomentumBars // + // ); + // } + // } + // } + + // // 4H ... + // int rejectionBarsCount = ArraySize(h4State.rejectionBars); + // if (IsValidSize(rejectionBarsCount)) + // { + // // + // for (int j = 0; j < rejectionBarsCount; j++) + // { + // // + // XOHCL jBar = h4State.rejectionBars[j]; + + // // + // bool isInside = + // jBar.GetLowShadow() < jBar.GetHighShadow() && + // jBar.time > iSupplyZone.from && + // IsInside( + // jBar, + // iSupplyZone, + // X_ZONE_UPPER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.bearishRejectionBars // + // ); + // } + // } + // } + // // 15M ... + // rejectionBarsCount = ArraySize(m15State.rejectionBars); + // if (IsValidSize(rejectionBarsCount)) + // { + // // + // for (int j = 0; j < rejectionBarsCount; j++) + // { + // // + // XOHCL jBar = m15State.rejectionBars[j]; + + // // + // bool isInside = + // jBar.GetLowShadow() < jBar.GetHighShadow() && + // jBar.time > iSupplyZone.from && + // IsInside( + // jBar, + // iSupplyZone, + // X_ZONE_UPPER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.bearishRejectionBars // + // ); + // } + // } + // } + // // 5M ... + // rejectionBarsCount = ArraySize(m5State.rejectionBars); + // if (IsValidSize(rejectionBarsCount)) + // { + // // + // for (int j = 0; j < rejectionBarsCount; j++) + // { + // // + // XOHCL jBar = m5State.rejectionBars[j]; + + // // + // bool isInside = + // jBar.GetLowShadow() < jBar.GetHighShadow() && + // jBar.time > iSupplyZone.from && + // IsInside( + // jBar, + // iSupplyZone, + // X_ZONE_UPPER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.bearishRejectionBars // + // ); + // } + // } + // } + // // 1M ... + // rejectionBarsCount = ArraySize(m1State.rejectionBars); + // if (IsValidSize(rejectionBarsCount)) + // { + // // + // for (int j = 0; j < rejectionBarsCount; j++) + // { + // // + // XOHCL jBar = m1State.rejectionBars[j]; + + // // + // bool isInside = + // jBar.GetLowShadow() < jBar.GetHighShadow() && + // jBar.time > iSupplyZone.from && + // IsInside( + // jBar, + // iSupplyZone, + // X_ZONE_UPPER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.bearishRejectionBars // + // ); + // } + // } + // } + + + // // 4H ... + // int orderBlocksCount = ArraySize(h4State.bullishOrderBlocks); + // if (IsValidSize(orderBlocksCount)) + // { + // // + // for (int j = 0; j < orderBlocksCount; j++) + // { + // // + // XZone jZone = h4State.bullishOrderBlocks[j]; + + // // + // bool isInside = IsInside( + // jZone, + // iDemandZone, + // X_ZONE_LOWER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // jZone.to = TimeCurrent(); + + // // + // AddIfNotExists( + // jZone, + // conditions.bullishOrderBlocks // + // ); + // } + // } + // } + // // 15M ... + // orderBlocksCount = ArraySize(m15State.bullishOrderBlocks); + // if (IsValidSize(orderBlocksCount)) + // { + // // + // for (int j = 0; j < orderBlocksCount; j++) + // { + // // + // XZone jZone = m15State.bullishOrderBlocks[j]; + + // // + // bool isInside = IsInside( + // jZone, + // iDemandZone, + // X_ZONE_LOWER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // jZone.to = TimeCurrent(); + + // // + // AddIfNotExists( + // jZone, + // conditions.bullishOrderBlocks // + // ); + // } + // } + // } + // // 5M ... + // orderBlocksCount = ArraySize(m5State.bullishOrderBlocks); + // if (IsValidSize(orderBlocksCount)) + // { + // // + // for (int j = 0; j < orderBlocksCount; j++) + // { + // // + // XZone jZone = m5State.bullishOrderBlocks[j]; + + // // + // bool isInside = IsInside( + // jZone, + // iDemandZone, + // X_ZONE_LOWER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // jZone.to = TimeCurrent(); + + // // + // AddIfNotExists( + // jZone, + // conditions.bullishOrderBlocks // + // ); + // } + // } + // } + // // 1M ... + // orderBlocksCount = ArraySize(m1State.bullishOrderBlocks); + // if (IsValidSize(orderBlocksCount)) + // { + // // + // for (int j = 0; j < orderBlocksCount; j++) + // { + // // + // XZone jZone = m1State.bullishOrderBlocks[j]; + + // // + // bool isInside = IsInside( + // jZone, + // iDemandZone, + // X_ZONE_LOWER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // jZone.to = TimeCurrent(); + + // // + // AddIfNotExists( + // jZone, + // conditions.bullishOrderBlocks // + // ); + // } + // } + // } + + + // // 4H ... + // int supportsCount = ArraySize(h4State.supportZones); + // if (IsValidSize(supportsCount)) + // { + // // + // for (int j = 0; j < supportsCount; j++) + // { + // // + // XOHCL jBar = h4State.supportZones[j]; + + // // + // bool isInside = IsInside( + // jBar, + // iDemandZone, + // X_ZONE_LOWER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.supports // + // ); + // } + // } + // } + // // 15M ... + // supportsCount = ArraySize(m15State.supportZones); + // if (IsValidSize(supportsCount)) + // { + // // + // for (int j = 0; j < supportsCount; j++) + // { + // // + // XOHCL jBar = m15State.supportZones[j]; + + // // + // bool isInside = IsInside( + // jBar, + // iDemandZone, + // X_ZONE_LOWER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.supports // + // ); + // } + // } + // } + // // 5M ... + // supportsCount = ArraySize(m5State.supportZones); + // if (IsValidSize(supportsCount)) + // { + // // + // for (int j = 0; j < supportsCount; j++) + // { + // // + // XOHCL jBar = m5State.supportZones[j]; + + // // + // bool isInside = IsInside( + // jBar, + // iDemandZone, + // X_ZONE_LOWER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.supports // + // ); + // } + // } + // } + // // 1M ... + // supportsCount = ArraySize(m1State.supportZones); + // if (IsValidSize(supportsCount)) + // { + // // + // for (int j = 0; j < supportsCount; j++) + // { + // // + // XOHCL jBar = m1State.supportZones[j]; + + // // + // bool isInside = IsInside( + // jBar, + // iDemandZone, + // X_ZONE_LOWER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.supports // + // ); + // } + // } + // } + + + // // 4H ... + // int fvgsCount = ArraySize(h4State.bullishFVGs); + // if (IsValidSize(fvgsCount)) + // { + // // + // for (int j = 0; j < fvgsCount; j++) + // { + // // + // XZone jFVG = h4State.bullishFVGs[j]; + + // // + // bool isInside = IsInside( + // jFVG, + // iDemandZone, + // X_ZONE_LOWER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // jFVG.to = TimeCurrent(); + + // // + // AddIfNotExists( + // jFVG, + // conditions.bullishFVGs // + // ); + // } + // } + // } + // // 15M ... + // fvgsCount = ArraySize(m15State.bullishFVGs); + // if (IsValidSize(fvgsCount)) + // { + // // + // for (int j = 0; j < fvgsCount; j++) + // { + // // + // XZone jFVG = m15State.bullishFVGs[j]; + + // // + // bool isInside = IsInside( + // jFVG, + // iDemandZone, + // X_ZONE_LOWER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // jFVG.to = TimeCurrent(); + + // // + // AddIfNotExists( + // jFVG, + // conditions.bullishFVGs // + // ); + // } + // } + // } + // // 5M ... + // fvgsCount = ArraySize(m5State.bullishFVGs); + // if (IsValidSize(fvgsCount)) + // { + // // + // for (int j = 0; j < fvgsCount; j++) + // { + // // + // XZone jFVG = m5State.bullishFVGs[j]; + + // // + // bool isInside = IsInside( + // jFVG, + // iDemandZone, + // X_ZONE_LOWER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // jFVG.to = TimeCurrent(); + + // // + // AddIfNotExists( + // jFVG, + // conditions.bullishFVGs // + // ); + // } + // } + // } + // // 1M ... + // fvgsCount = ArraySize(m1State.bullishFVGs); + // if (IsValidSize(fvgsCount)) + // { + // // + // for (int j = 0; j < fvgsCount; j++) + // { + // // + // XZone jFVG = m1State.bullishFVGs[j]; + + // // + // bool isInside = IsInside( + // jFVG, + // iDemandZone, + // X_ZONE_LOWER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // jFVG.to = TimeCurrent(); + + // // + // AddIfNotExists( + // jFVG, + // conditions.bullishFVGs // + // ); + // } + // } + // } + + + // // 4H ... + // int swingsCount = ArraySize(h4State.swingLows); + // if (IsValidSize(swingsCount)) + // { + // // + // for (int j = 0; j < swingsCount; j++) + // { + // // + // XOHCL jBar = h4State.swingLows[j]; + + // // + // bool isInside = IsInside( + // jBar, + // iDemandZone, + // X_ZONE_LOWER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.swingLows // + // ); + // } + // } + // } + // // 15M ... + // swingsCount = ArraySize(m15State.swingLows); + // if (IsValidSize(swingsCount)) + // { + // // + // for (int j = 0; j < swingsCount; j++) + // { + // // + // XOHCL jBar = m15State.swingLows[j]; + + // // + // bool isInside = IsInside( + // jBar, + // iDemandZone, + // X_ZONE_LOWER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.swingLows // + // ); + // } + // } + // } + // // 5M ... + // swingsCount = ArraySize(m5State.swingLows); + // if (IsValidSize(swingsCount)) + // { + // // + // for (int j = 0; j < swingsCount; j++) + // { + // // + // XOHCL jBar = m5State.swingLows[j]; + + // // + // bool isInside = IsInside( + // jBar, + // iDemandZone, + // X_ZONE_LOWER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.swingLows // + // ); + // } + // } + // } + // // 1M ... + // swingsCount = ArraySize(m1State.swingLows); + // if (IsValidSize(swingsCount)) + // { + // // + // for (int j = 0; j < swingsCount; j++) + // { + // // + // XOHCL jBar = m1State.swingLows[j]; + + // // + // bool isInside = IsInside( + // jBar, + // iDemandZone, + // X_ZONE_LOWER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.swingLows // + // ); + // } + // } + // } + + + + // // 4H ... + // int momentumBarsCount = ArraySize(h4State.momentumBars); + // if (IsValidSize(momentumBarsCount)) + // { + // // + // for (int j = 0; j < momentumBarsCount; j++) + // { + // // + // XOHCL jBar = h4State.momentumBars[j]; + + // // + // bool isInside = + // jBar.IsBullish() && + // jBar.time > iDemandZone.from && + // IsInside( + // jBar, + // iDemandZone, + // X_ZONE_LOWER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.bullishMomentumBars // + // ); + // } + // } + // } + // // 15M ... + // momentumBarsCount = ArraySize(m15State.momentumBars); + // if (IsValidSize(momentumBarsCount)) + // { + // // + // for (int j = 0; j < momentumBarsCount; j++) + // { + // // + // XOHCL jBar = m15State.momentumBars[j]; + + // // + // bool isInside = + // jBar.IsBullish() && + // jBar.time > iDemandZone.from && + // IsInside( + // jBar, + // iDemandZone, + // X_ZONE_LOWER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.bullishMomentumBars // + // ); + // } + // } + // } + // // 5M ... + // momentumBarsCount = ArraySize(m5State.momentumBars); + // if (IsValidSize(momentumBarsCount)) + // { + // // + // for (int j = 0; j < momentumBarsCount; j++) + // { + // // + // XOHCL jBar = m5State.momentumBars[j]; + + // // + // bool isInside = + // jBar.IsBullish() && + // jBar.time > iDemandZone.from && + // IsInside( + // jBar, + // iDemandZone, + // X_ZONE_LOWER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.bullishMomentumBars // + // ); + // } + // } + // } + // // 1M ... + // momentumBarsCount = ArraySize(m1State.momentumBars); + // if (IsValidSize(momentumBarsCount)) + // { + // // + // for (int j = 0; j < momentumBarsCount; j++) + // { + // // + // XOHCL jBar = m1State.momentumBars[j]; + + // // + // bool isInside = + // jBar.IsBullish() && + // jBar.time > iDemandZone.from && + // IsInside( + // jBar, + // iDemandZone, + // X_ZONE_LOWER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.bullishMomentumBars // + // ); + // } + // } + // } + + + // // 4H ... + // int rejectionBarsCount = ArraySize(h4State.rejectionBars); + // if (IsValidSize(rejectionBarsCount)) + // { + // // + // for (int j = 0; j < rejectionBarsCount; j++) + // { + // // + // XOHCL jBar = h4State.rejectionBars[j]; + + // // + // bool isInside = + // jBar.GetLowShadow() > jBar.GetHighShadow() && + // jBar.time > iDemandZone.from && + // IsInside( + // jBar, + // iDemandZone, + // X_ZONE_LOWER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.bullishRejectionBars // + // ); + // } + // } + // } + // // 15M ... + // rejectionBarsCount = ArraySize(m15State.rejectionBars); + // if (IsValidSize(rejectionBarsCount)) + // { + // // + // for (int j = 0; j < rejectionBarsCount; j++) + // { + // // + // XOHCL jBar = m15State.rejectionBars[j]; + + // // + // bool isInside = + // jBar.GetLowShadow() > jBar.GetHighShadow() && + // jBar.time > iDemandZone.from && + // IsInside( + // jBar, + // iDemandZone, + // X_ZONE_LOWER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.bullishRejectionBars // + // ); + // } + // } + // } + // // 5M ... + // rejectionBarsCount = ArraySize(m5State.rejectionBars); + // if (IsValidSize(rejectionBarsCount)) + // { + // // + // for (int j = 0; j < rejectionBarsCount; j++) + // { + // // + // XOHCL jBar = m5State.rejectionBars[j]; + + // // + // bool isInside = + // jBar.GetLowShadow() > jBar.GetHighShadow() && + // jBar.time > iDemandZone.from && + // IsInside( + // jBar, + // iDemandZone, + // X_ZONE_LOWER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.bullishRejectionBars // + // ); + // } + // } + // } + // // 1M ... + // rejectionBarsCount = ArraySize(m1State.rejectionBars); + // if (IsValidSize(rejectionBarsCount)) + // { + // // + // for (int j = 0; j < rejectionBarsCount; j++) + // { + // // + // XOHCL jBar = m1State.rejectionBars[j]; + + // // + // bool isInside = + // jBar.GetLowShadow() > jBar.GetHighShadow() && + // jBar.time > iDemandZone.from && + // IsInside( + // jBar, + // iDemandZone, + // X_ZONE_LOWER_EDGE, + // true // + // ); + // if (isInside) + // { + // // + // AddIfNotExists( + // jBar, + // conditions.bullishRejectionBars // + // ); + // } + // } + // } diff --git a/Experts/x-saherelm.x-121.smc.ea.mq5 b/Experts/x-saherelm.x-121.smc.ea.mq5 index 6c7685a7..869c8cea 100644 --- a/Experts/x-saherelm.x-121.smc.ea.mq5 +++ b/Experts/x-saherelm.x-121.smc.ea.mq5 @@ -276,6 +276,13 @@ void OnSignalRecieved( { // // TODO: Implement this ... + + // + ENUM_X_SIGNAL_EXECUTION_RESULT state; + eaTrader.ExecuteSignal( + signal, + state // + ); } // @@ -446,6 +453,9 @@ bool InitEA() _Period // ); + // + iX121SMCStrategy.AddXSignalEventHandler(OnSignalRecieved); + // ConfigureStrategy(iX121SMCStrategy); RegisterStrategy(iX121SMCStrategy); @@ -508,6 +518,9 @@ bool InitEA() _Period // ); + // + iX121SMCStrategy.AddXSignalEventHandler(OnSignalRecieved); + // // Register Strategy ... ConfigureStrategy(iX121SMCStrategy); diff --git a/Libraries/x-saherelm.common.lib.mq5 b/Libraries/x-saherelm.common.lib.mq5 index b91ce672..2bfb7208 100644 --- a/Libraries/x-saherelm.common.lib.mq5 +++ b/Libraries/x-saherelm.common.lib.mq5 @@ -538,39 +538,40 @@ struct XOHCL time = iTime( mSymbol, mPeriod, - barIndex - // + barIndex // ); // open = iOpen( mSymbol, mPeriod, - barIndex - // + barIndex // ); + open = NormalizePrice(open, mSymbol); // close = iClose( mSymbol, mPeriod, - barIndex - // + barIndex // ); + close = NormalizePrice(close, mSymbol); // high = iHigh( mSymbol, mPeriod, - barIndex); + barIndex // + ); + high = NormalizePrice(high, mSymbol); // low = iLow( mSymbol, mPeriod, - barIndex - // + barIndex // ); + low = NormalizePrice(low, mSymbol); // bool result = IsValid(); diff --git a/Libraries/x-saherelm.x-poi.lib.mq5 b/Libraries/x-saherelm.x-poi.lib.mq5 index 9f617936..0421af76 100644 --- a/Libraries/x-saherelm.x-poi.lib.mq5 +++ b/Libraries/x-saherelm.x-poi.lib.mq5 @@ -436,6 +436,45 @@ struct XZone return result; } + // + double GetRange() + { + // + double result = 0; + + // + if (!IsValid()) + { + return result; + } + + // + result = upper - lower; + + // + return result; + } + + // + double GetMiddle() + { + // + double result = 0; + + // + double range = GetRange(); + if (range <= 0) + { + return result; + } + + // + result = lower + (range / 2); + + // + return result; + } + // string GetTag() { @@ -1730,11 +1769,12 @@ bool IsInside( double upper = edge == X_ZONE_UPPER_EDGE ? source.high - : source.GetDown(); + : source.GetUp(); double lower = edge == X_ZONE_UPPER_EDGE - ? source.GetUp() + ? source.GetDown() : source.low; + result = iSource.Init( upper, lower, @@ -1759,9 +1799,328 @@ bool IsInside( return result; } +/** + * Check a Zone is Between to other Zones ... + * + * @param source: XZone instance ... + * @param upper: XZone instance ... + * @param lower: XZone instance ... + * + * @return ( bool ) + */ +bool IsBetween( + XZone &source, + XZone &upper, + XZone &lower // +) +{ + // + bool result = false; + + // + result = source.IsValid(); + if (!result) + { + return result; + } + + // + bool isUpperValid = upper.IsValid(); + bool isLowerValid = lower.IsValid(); + + // + result = isUpperValid || + isLowerValid; + if (!result) + { + return result; + } + + // + if (isUpperValid) + { + // + result = source.upper < upper.lower; + if (!result) + { + return result; + } + } + + // + if (isLowerValid) + { + // + result = source.lower > lower.upper; + if (!result) + { + return result; + } + } + + // + return result; +} +bool IsBetween( + XOHCL &source, + XZone &upper, + XZone &lower // +) +{ + // + bool result = false; + + // + result = source.IsValid(); + if (!result) + { + return result; + } + + // + bool isUpperValid = upper.IsValid(); + bool isLowerValid = lower.IsValid(); + + // + result = isUpperValid || + isLowerValid; + if (!result) + { + return result; + } + + // + if (isUpperValid) + { + // + result = source.high < upper.lower; + if (!result) + { + return result; + } + } + + // + if (isLowerValid) + { + // + result = source.low > lower.upper; + if (!result) + { + return result; + } + } + + // + return result; +} + // // State Extensions ... +/** + * Normalize and Combine States ... + * + * @param dest: XPOIState instance ...ّ + * @param states: XPOIState instance ...ّ + */ +void CombineStates( + XPOIState &dest, + XPOIState &states[] // +) +{ + // + dest.Clean(); + + // + int count = ArraySize(states); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + XPOIState iState = states[i]; + + // + dest.symbol = iState.symbol; + dest.period = + !IsValid(dest.period) || + PeriodSeconds(dest.period) < PeriodSeconds(iState.period) + ? iState.period + : dest.period; + dest.reportedAt = + !IsValid(dest.reportedAt) || + dest.reportedAt > iState.reportedAt + ? iState.reportedAt + : dest.reportedAt; + + // + // Demand ... + int iCount = ArraySize(iState.demandZones); + if (IsValidSize(iCount)) + { + // + Copy( + iState.demandZones, + dest.demandZones, + false // + ); + } + + // + // Supply ... + iCount = ArraySize(iState.supplyZones); + if (IsValidSize(iCount)) + { + // + Copy( + iState.supplyZones, + dest.supplyZones, + false // + ); + } + + // + // Order Blocks ... + + // + iCount = ArraySize(iState.bullishOrderBlocks); + if (IsValidSize(iCount)) + { + // + Copy( + iState.bullishOrderBlocks, + dest.bullishOrderBlocks, + false // + ); + } + + // + iCount = ArraySize(iState.bearishOrderBlocks); + if (IsValidSize(iCount)) + { + // + Copy( + iState.bearishOrderBlocks, + dest.bearishOrderBlocks, + false // + ); + } + + // + // Fair Value Gaps ... + + // + iCount = ArraySize(iState.bullishFVGs); + if (IsValidSize(iCount)) + { + // + Copy( + iState.bullishFVGs, + dest.bullishFVGs, + false // + ); + } + + // + iCount = ArraySize(iState.bearishFVGs); + if (IsValidSize(iCount)) + { + // + Copy( + iState.bearishFVGs, + dest.bearishFVGs, + false // + ); + } + + // + // Supports ... + iCount = ArraySize(iState.supportZones); + if (IsValidSize(iCount)) + { + // + Copy( + iState.supportZones, + dest.supportZones, + false // + ); + } + + // + // Resistances ... + iCount = ArraySize(iState.resistanceZones); + if (IsValidSize(iCount)) + { + // + Copy( + iState.resistanceZones, + dest.resistanceZones, + false // + ); + } + + // + // Swings ... + + // + // Swing Highs ... + iCount = ArraySize(iState.swingHighs); + if (IsValidSize(iCount)) + { + // + Copy( + iState.swingHighs, + dest.swingHighs, + false // + ); + } + + // + // Swing Lows ... + iCount = ArraySize(iState.swingLows); + if (IsValidSize(iCount)) + { + // + Copy( + iState.swingLows, + dest.swingLows, + false // + ); + } + + // + // Momentum Bars ... + iCount = ArraySize(iState.momentumBars); + if (IsValidSize(iCount)) + { + // + Copy( + iState.momentumBars, + dest.momentumBars, + false // + ); + } + + // + // Rejection Bars ... + iCount = ArraySize(iState.rejectionBars); + if (IsValidSize(iCount)) + { + // + Copy( + iState.rejectionBars, + dest.rejectionBars, + false // + ); + } + } +} + /** * Check State has Bullish Trend or not ... * diff --git a/X121SMCEA/Handler/x-saherelm.x121.smc.trade.handler.mq5 b/X121SMCEA/Handler/x-saherelm.x121.smc.trade.handler.mq5 new file mode 100644 index 00000000..8d763b8d --- /dev/null +++ b/X121SMCEA/Handler/x-saherelm.x121.smc.trade.handler.mq5 @@ -0,0 +1 @@ +// Complete this ... \ No newline at end of file diff --git a/X121SMCEA/Libraries/x-121.smc.lib.mq5 b/X121SMCEA/Libraries/x-121.smc.lib.mq5 index 09e60860..3b7b40b3 100644 --- a/X121SMCEA/Libraries/x-121.smc.lib.mq5 +++ b/X121SMCEA/Libraries/x-121.smc.lib.mq5 @@ -121,6 +121,34 @@ struct X121SMCStrategyConditions Clean(bullishRejectionBars); } + void CleanDemand() + { + // + demandZone.Clean(); + + // + Clean(supports); + Clean(swingLows); + Clean(bullishFVGs); + Clean(bullishOrderBlocks); + Clean(bullishMomentumBars); + Clean(bullishRejectionBars); + } + + void CleanSupply() + { + // + supplyZone.Clean(); + + // + Clean(swingHighs); + Clean(resistances); + Clean(bearishFVGs); + Clean(bearishOrderBlocks); + Clean(bearishMomentumBars); + Clean(bearishRejectionBars); + } + // // Validate ... bool IsValid() @@ -263,6 +291,63 @@ struct X121SMCStrategyConditions // }; +// +// Market Structure Models ... +struct X121SMCMarketStructure +{ + // + XZone demandZone; + XZone supplyZone; + + // + XZone demandZones[]; + XZone supplyZones[]; + + // + XZone bearishOrderBlocks[]; + XZone bearishFVGs[]; + + // + XOHCL swingHighs[]; + XOHCL resistances[]; + XOHCL bearishMomentumBars[]; + XOHCL bearishRejectionBars[]; + + // + XZone bullishOrderBlocks[]; + XZone bullishFVGs[]; + + // + XOHCL supports[]; + XOHCL swingLows[]; + XOHCL bullishMomentumBars[]; + XOHCL bullishRejectionBars[]; + + // + void Clean() + { + // + demandZone.Clean(); + supplyZone.Clean(); + + // + Clean(supports); + Clean(swingLows); + Clean(swingHighs); + Clean(demandZones); + Clean(supplyZones); + Clean(bearishFVGs); + Clean(resistances); + Clean(bullishFVGs); + Clean(bearishOrderBlocks); + Clean(bullishOrderBlocks); + Clean(bearishMomentumBars); + Clean(bearishRejectionBars); + Clean(bullishMomentumBars); + Clean(bullishRejectionBars); + } +}; + // // On Signal Event Handler ... typedef void (*TOnX121SMCSignal)( diff --git a/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 b/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 index d6d114a3..9b4753c7 100644 Binary files a/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 and b/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 differ