From cc57a5eca856bbb86d5e848a953b954c9fe2bea3 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Thu, 31 Oct 2024 22:36:11 +0330 Subject: [PATCH] last ... --- Libraries/x-saherelm.x-poi.lib.mq5 | 123 +++++++++++++++++- .../Strategy/x-121.smc.strategy.class.mq5 | Bin 107056 -> 134108 bytes 2 files changed, 119 insertions(+), 4 deletions(-) diff --git a/Libraries/x-saherelm.x-poi.lib.mq5 b/Libraries/x-saherelm.x-poi.lib.mq5 index 828b596f..9f617936 100644 --- a/Libraries/x-saherelm.x-poi.lib.mq5 +++ b/Libraries/x-saherelm.x-poi.lib.mq5 @@ -118,6 +118,12 @@ enum ENUM_XSESSION X_FRANKFORT, }; +enum ENUM_X_ZONE_EDGE +{ + X_ZONE_UPPER_EDGE, + X_ZONE_LOWER_EDGE +}; + // // Represent a Session Working Time ... struct XSession @@ -1472,7 +1478,6 @@ bool AddIfNotExists( bool result = false; // - int count = ArraySize(dest); result = source.IsValid(); if (!result) { @@ -1482,7 +1487,7 @@ bool AddIfNotExists( // int idx = FindIndex(source, dest); bool isExists = IsValidIndex(idx); - if (isExists) + if (!isExists) { // AddRef( @@ -1618,7 +1623,6 @@ bool AddIfNotExists( bool result = false; // - int count = ArraySize(dest); result = source.IsValid(); if (!result) { @@ -1628,7 +1632,7 @@ bool AddIfNotExists( // int idx = FindIndex(source, dest); bool isExists = IsValidIndex(idx); - if (isExists) + if (!isExists) { // AddRef( @@ -1644,6 +1648,117 @@ bool AddIfNotExists( return result; } +// + +/** + * Check if a Zone inside another one ... + * + * @param source: XZone instance ... + * @param dest: XZone instance ... + * @param edge: ENUM_X_ZONE_EDGE member, define inside edge of zone ... + * @param forceInside: Boolean, if set true means all edges of source must be inside dest ... + * + * @return ( bool ) + */ +bool IsInside( + XZone &source, + XZone &dest, + ENUM_X_ZONE_EDGE edge, + bool forceInside = true // +) +{ + // + bool result = false; + + // + result = source.IsValid() && + dest.IsValid(); + if (!result) + { + return result; + } + + // + bool isEdgePassed = + // + edge == X_ZONE_UPPER_EDGE + ? source.upper <= dest.upper + : source.lower >= dest.lower + // + ; + + // + bool isForcePassed = + // + forceInside + ? edge == X_ZONE_UPPER_EDGE + ? source.lower >= dest.lower + : source.upper <= dest.upper + : edge == X_ZONE_UPPER_EDGE + ? true + : true + // + ; + + // + result = isEdgePassed && + isForcePassed; + + // + return result; +} +bool IsInside( + XOHCL &source, + XZone &dest, + ENUM_X_ZONE_EDGE edge, + bool forceInside = true // +) +{ + // + bool result = false; + + // + result = source.IsValid() && + dest.IsValid(); + if (!result) + { + return result; + } + + // + XZone iSource; + double upper = + edge == X_ZONE_UPPER_EDGE + ? source.high + : source.GetDown(); + double lower = + edge == X_ZONE_UPPER_EDGE + ? source.GetUp() + : source.low; + result = iSource.Init( + upper, + lower, + "XOHCL", + source.time, + TimeCurrent() // + ); + if (!result) + { + return result; + } + + // + result = IsInside( + iSource, + dest, + edge, + forceInside // + ); + + // + return result; +} + // // State Extensions ... diff --git a/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 b/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 index e213b48b2a571e84c84787c552b63ec481d06bb4..d6d114a3b9af393b4c21dd1e7874595c9784df4c 100644 GIT binary patch delta 4268 zcmdT|eN0nV6u-x@`mD{{gF$U7V~@&6w-D%%6@rX0GC*;0%$Z4yZkVZwn$0>fG5%rP z;>@xzLwXF?AR(Or2DPh|hw|wcQR0Xh^ABBTjMo9WrgKBTvbzc*H3Nn*0Qu?qia zl(E#2=I*iJ>P8nH+MbLa$)Guoj+wA=z6nDwXYvvwJ((1jTd5J1p!FJK}5&dsvo7iUlb0XxU!*ArqVkp47r;}y7TAPvX9wrp~M0^F!fS9DKZg~re{~M zEi`lo*;mH)&`i5nEq+y)j#Vvccrqt}BB;D31!N3)%~*7@3mxYz4Kie6UZsu1r1URu z3i`bn=xR&C=3ZF~d9MTR?a(XwsC&MHPl{FUm0}}ejOrOtqDEPU^~#fAlvZ>y4`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