From 465ead38c9b0226275c0025721d20833f2ed2f12 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Wed, 5 Jun 2024 13:55:52 +0330 Subject: [PATCH] last works ... --- Classes/x-saherelm.x121.provider.class.mq5 | 69 ++++++++++++++++++++-- Classes/x-saherelm.x121.xea.class.mq5 | 21 ++++--- Classes/x-saherelm.x121.xmcycle.class.mq5 | 7 +++ Experts/x-test.x121ea.mq5 | 9 ++- 4 files changed, 88 insertions(+), 18 deletions(-) diff --git a/Classes/x-saherelm.x121.provider.class.mq5 b/Classes/x-saherelm.x121.provider.class.mq5 index 08264fcc..213f0b07 100644 --- a/Classes/x-saherelm.x121.provider.class.mq5 +++ b/Classes/x-saherelm.x121.provider.class.mq5 @@ -1341,6 +1341,22 @@ struct X121ProviderDescriptor barIndex // ); + // + // Retrieve All Scores ... + double bullishScore = 0; + double bearishScore = 0; + this.conditions.GenerateScore( + bullishScore, + bearishScore // + ); + + // + // Generate Conditions Summary and Comment it on Chart ... + string conditionsStr = this.conditions.GenerateSummary( + true // OnlySummary + ); + Comment("\n", conditionsStr); + // // Verifiers ... int longVerifiers = 0; @@ -1701,11 +1717,20 @@ struct X121ProviderDescriptor return result; } + // + bool isScorePassed = hasLong + ? bullishScore > bearishScore * 2 + : bearishScore > bullishScore * 2; + // result = - hasLong - ? longVerifiers > 1 - : shortVerifiers > 1; + // + isScorePassed && + (hasLong + ? longVerifiers > 1 + : shortVerifiers > 1) + // + ; if (!result) { return result; @@ -1739,7 +1764,8 @@ struct X121ProviderDescriptor slPrice, tpPrice // ); - if (mSL == 0 && mTP == 0) { + if (mSL == 0 && mTP == 0) + { Print("Zero TP/SL ..."); } @@ -1770,13 +1796,44 @@ struct X121ProviderDescriptor // // Check for Guards ... - bool HasGuard(XGuard &guards[]) + int HasGuard(XGuard &guards[]) { + // + int result = 0; + // Clean(guards); // - bool result = IsValidSize(guards); + int signallersCount = CountSignallers(); + if (!IsValidSize(signallersCount)) + { + return result; + } + + // + // Loop through Signallers ... + for (int i = 0; i < signallersCount; i++) + { + // + XGuard iGuards[]; + int iGuardsCount = this.signallers[i] + .HasGuard(iGuards); + if (!IsValidSize(iGuardsCount)) + { + continue; + } + + // + Copy( + iGuards, + guards, + false // + ); + } + + // + result = ArraySize(guards); // return result; diff --git a/Classes/x-saherelm.x121.xea.class.mq5 b/Classes/x-saherelm.x121.xea.class.mq5 index 935678c1..2a3e0b91 100644 --- a/Classes/x-saherelm.x121.xea.class.mq5 +++ b/Classes/x-saherelm.x121.xea.class.mq5 @@ -173,6 +173,7 @@ public: } // + // Loop Through Descriptors for Collecting Guards ... for (int i = 0; i < descriptorsCount; i++) { // @@ -180,16 +181,18 @@ public: // XGuard iGuards[]; - bool iHasGuard = iDescriptor.HasGuard(iGuards); - if (iHasGuard) + int iGuardsCount = iDescriptor.HasGuard(iGuards); + if (!IsValidSize(iGuardsCount)) { - // - Copy( - iGuards, - guards, - false // - ); + continue; } + + // + Copy( + iGuards, + guards, + false // + ); } // @@ -558,7 +561,7 @@ public: // // Check Signaller Enable Hedge or not and Handle it if enabled ... - if (mDescriptors[i].signallers[j].AllowHedge()) + if (positionsCount > 1 && mDescriptors[i].signallers[j].AllowHedge()) { // // Check Profits Enough for Hedge or not ... diff --git a/Classes/x-saherelm.x121.xmcycle.class.mq5 b/Classes/x-saherelm.x121.xmcycle.class.mq5 index bfc3ada8..913af253 100644 --- a/Classes/x-saherelm.x121.xmcycle.class.mq5 +++ b/Classes/x-saherelm.x121.xmcycle.class.mq5 @@ -2864,6 +2864,13 @@ public: return false; } + // + // Check For Guards ... + virtual int HasGuard(XGuard &guards[]) + { + return 0; + } + // // Protected ... protected: diff --git a/Experts/x-test.x121ea.mq5 b/Experts/x-test.x121ea.mq5 index bf870f22..0e89fe72 100644 --- a/Experts/x-test.x121ea.mq5 +++ b/Experts/x-test.x121ea.mq5 @@ -248,6 +248,9 @@ bool InitialEA() x110Signaller.Default(); x110Signaller.allowLong = x121EAAllowLong; x110Signaller.allowShort = x121EAAllowShort; + x110Signaller.minRequiredProfitPerTrade = 1.5; + x110Signaller.openNextPositionOnProfit = false; + x110Signaller.delayBetweenTwoSameTypeSignals = 6; // iDescriptor.signallers[0] = x786Signaller; @@ -1014,9 +1017,9 @@ void ApplyPreDefineConfigurations(X121ProviderDescriptor &iDescriptor) iDescriptor.inputs.mcInputs.showVerifierMa = isX110; // - iDescriptor.inputs.ichInputs.showKumo = isX110; - iDescriptor.inputs.ichInputs.showKijunSen = isX110; - iDescriptor.inputs.ichInputs.showTenkanSen = isX110; + iDescriptor.inputs.ichInputs.showKumo = true; // isX110; + iDescriptor.inputs.ichInputs.showKijunSen = true; // isX110; + iDescriptor.inputs.ichInputs.showTenkanSen = true; // isX110; iDescriptor.inputs.ichInputs.showSenkouSpanA = isX110; iDescriptor.inputs.ichInputs.showSenkouSpanB = isX110;