From ff5ef28ead0512e1e8c040dae3fd9bfe489b8312 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Tue, 28 May 2024 12:59:18 +0330 Subject: [PATCH] last ... --- Classes/x-saherelm.x121.provider.class.mq5 | 567 ++++++++++----------- Classes/x-saherelm.x121.xea.class.mq5 | 83 +-- Experts/x-test.x121ea.mq5 | 14 +- Indicators/x-saherelm.xts.mq5 | 6 +- 4 files changed, 345 insertions(+), 325 deletions(-) diff --git a/Classes/x-saherelm.x121.provider.class.mq5 b/Classes/x-saherelm.x121.provider.class.mq5 index 76ab39b3..3dd1263a 100644 --- a/Classes/x-saherelm.x121.provider.class.mq5 +++ b/Classes/x-saherelm.x121.provider.class.mq5 @@ -2917,7 +2917,7 @@ public: // double providedSL = 0; double providedTP = 0; - double providedR2r = 0; + double providedR2r = 2; // // Long ... @@ -3095,8 +3095,8 @@ public: // // TODOO: Remove this ... sl = hasLong - ? GetMaxVales(true) - : GetMinPeaks(true); + ? cMarket.pv.GetLCLL(0) + : cMarket.pv.GetLCHH(0); double risk = MathAbs(entry - sl); double reward = risk * r2r; tp = hasLong @@ -4677,6 +4677,10 @@ private: // ArraySetAsSeries(mBullishScore, true); ArraySetAsSeries(mBearishScore, true); + + // + string scoreMSG = "Scores: \nBullihs: " + ToString(bullishScore) + "\nBearish: " + ToString(bearishScore); + Comment(scoreMSG); } // @@ -7519,6 +7523,38 @@ private: // bool result = false; + // + double bearScore = 0; + double bullScore = 0; + mConditions.GenerateScore( + bullScore, + bearScore // + ); + + // + double bullScoreAVG3 = GetBullishScoreAverage(1, 3); + double bearScoreAVG100 = GetBearishScoreAverage(1, 100); + + // + result = + // + bearScore > bullScoreAVG3 && + ( + // + (bearScore > 100 && bearScore > bullScore && bullScore > (bearScore * 0.7)) + // + || + // + (bearScore < 30 && bullScore > 150) + // + || + // + (bearScore == bearScoreAVG100) + // + ) + // + ; + // return result; } @@ -7550,27 +7586,27 @@ private: // bool result = false; - // // - // bool isCMStrLong = - // // - // mConditions.cMarketConditions.isTrendSwitchedToBullish && - // (mConditions.hMarketConditions.isTrendBullish && - // mConditions.lMarketConditions.isTrendBullish && - // mConditions.mMarketConditions.isTrendBullish && - // mConditions.sMarketConditions.isTrendBullish) - // // - // ; + // + bool isCMStrLong = + // + mConditions.cMarketConditions.isTrendSwitchedToBullish && + (mConditions.hMarketConditions.isTrendBullish && + mConditions.lMarketConditions.isTrendBullish && + mConditions.mMarketConditions.isTrendBullish && + mConditions.sMarketConditions.isTrendBullish) + // + ; - // // - // bool isSMStrLong = - // // - // mConditions.sMarketConditions.isTrendSwitchedToBullish && - // (mConditions.hMarketConditions.isTrendBullish && - // mConditions.lMarketConditions.isTrendBullish && - // mConditions.mMarketConditions.isTrendBullish && - // mConditions.cMarketConditions.isTrendBullish) - // // - // ; + // + bool isSMStrLong = + // + mConditions.sMarketConditions.isTrendSwitchedToBullish && + (mConditions.hMarketConditions.isTrendBullish && + mConditions.lMarketConditions.isTrendBullish && + mConditions.mMarketConditions.isTrendBullish && + mConditions.cMarketConditions.isTrendBullish) + // + ; // bool isMMStrLong = @@ -7611,13 +7647,13 @@ private: // result = // - // isCMStrLong - // // - // || + isCMStrLong // - // isSMStrLong - // // - // || + || + + isSMStrLong + // + || // isMMStrLong // @@ -7631,15 +7667,6 @@ private: // ; - // - // result = result && isScorePassed; - - // - // if (result) - // { - // sl = GetMinVales(); - // } - // return result; } @@ -7658,51 +7685,51 @@ private: // // Current Market ... - // bool isCMCLong = - // // - // ( - // // - // (mConditions.cMarketConditions.isSlowOverVerifier && - // mConditions.cMarketConditions.isFastCrossedOverVerifier) - // // - // || - // // - // (mConditions.cMarketConditions.isFastOverVerifier && - // mConditions.cMarketConditions.isSlowCrossedOverVerifier) - // // - // ) - // // - // && - // // - // (mConditions.cMarketConditions.isCloseOverFast && - // mConditions.cMarketConditions.isCloseOverSlow && - // mConditions.cMarketConditions.isCloseOverVerifier) - // // - // ; + bool isCMCLong = + // + ( + // + (mConditions.cMarketConditions.isSlowOverVerifier && + mConditions.cMarketConditions.isFastCrossedOverVerifier) + // + || + // + (mConditions.cMarketConditions.isFastOverVerifier && + mConditions.cMarketConditions.isSlowCrossedOverVerifier) + // + ) + // + && + // + (mConditions.cMarketConditions.isCloseOverFast && + mConditions.cMarketConditions.isCloseOverSlow && + mConditions.cMarketConditions.isCloseOverVerifier) + // + ; // // Short Market ... - // bool isSMCLong = - // // - // ( - // // - // (mConditions.sMarketConditions.isSlowOverVerifier && - // mConditions.sMarketConditions.isFastCrossedOverVerifier) - // // - // || - // // - // (mConditions.sMarketConditions.isFastOverVerifier && - // mConditions.sMarketConditions.isSlowCrossedOverVerifier) - // // - // ) - // // - // && - // // - // (mConditions.sMarketConditions.isCloseOverFast && - // mConditions.sMarketConditions.isCloseOverSlow && - // mConditions.sMarketConditions.isCloseOverVerifier) - // // - // ; + bool isSMCLong = + // + ( + // + (mConditions.sMarketConditions.isSlowOverVerifier && + mConditions.sMarketConditions.isFastCrossedOverVerifier) + // + || + // + (mConditions.sMarketConditions.isFastOverVerifier && + mConditions.sMarketConditions.isSlowCrossedOverVerifier) + // + ) + // + && + // + (mConditions.sMarketConditions.isCloseOverFast && + mConditions.sMarketConditions.isCloseOverSlow && + mConditions.sMarketConditions.isCloseOverVerifier) + // + ; // // Medium Market ... @@ -7776,19 +7803,17 @@ private: // ; - // - // bool isScorePassed = IsScorePassedForLong(); // result = - // // - // isCMCLong - // // - // || - // // - // isSMCLong - // // - // || + // + isCMCLong + // + || + // + isSMCLong + // + || // isMMCLong // @@ -7802,15 +7827,6 @@ private: // ; - // - // result = result && isScorePassed; - - // // - // if (result) - // { - // sl = GetMinVales(); - // } - // return result; } @@ -7828,26 +7844,26 @@ private: bool result = false; // // - // bool isCCHELong = - // // - // (mConditions.cMarketConditions.isCHESwitchedInStrongLong && - // (mConditions.sMarketConditions.isCHEInStrongLong && - // mConditions.mMarketConditions.isCHEInStrongLong && - // mConditions.lMarketConditions.isCHEInStrongLong && - // mConditions.hMarketConditions.isCHEInStrongLong)) - // // - // ; + bool isCCHELong = + // + (mConditions.cMarketConditions.isCHESwitchedInStrongLong && + (mConditions.sMarketConditions.isCHEInStrongLong && + mConditions.mMarketConditions.isCHEInStrongLong && + mConditions.lMarketConditions.isCHEInStrongLong && + mConditions.hMarketConditions.isCHEInStrongLong)) + // + ; - // // - // bool isSCHELong = - // // - // (mConditions.sMarketConditions.isCHESwitchedInStrongLong && - // (mConditions.cMarketConditions.isCHEInStrongLong && - // mConditions.mMarketConditions.isCHEInStrongLong && - // mConditions.lMarketConditions.isCHEInStrongLong && - // mConditions.hMarketConditions.isCHEInStrongLong)) - // // - // ; + // + bool isSCHELong = + // + (mConditions.sMarketConditions.isCHESwitchedInStrongLong && + (mConditions.cMarketConditions.isCHEInStrongLong && + mConditions.mMarketConditions.isCHEInStrongLong && + mConditions.lMarketConditions.isCHEInStrongLong && + mConditions.hMarketConditions.isCHEInStrongLong)) + // + ; // bool isMCHELong = @@ -7882,19 +7898,16 @@ private: // ; - // - // bool isScorePassed = IsScorePassedForLong(); - // result = - // // - // isCCHELong - // // - // || - // // - // isSCHELong - // // - // || + // + isCCHELong + // + || + // + isSCHELong + // + || // isMCHELong // @@ -7908,15 +7921,6 @@ private: // ; - // - // result = result && isScorePassed; - - // // - // if (result) - // { - // sl = GetMinVales(); - // } - // return result; } @@ -8674,6 +8678,36 @@ private: // bool result = false; + // + double bearScore = 0; + double bullScore = 0; + mConditions.GenerateScore( + bullScore, + bearScore // + ); + + // + double bearScoreAVG3 = GetBearishScoreAverage(1, 3); + double bullScoreAVG100 = GetBullishScoreAverage(1, 100); + + // + result = + // + bearScore > bearScoreAVG3 && + ( + // + (bullScore > 100 && bullScore > bearScore && bearScore > (bullScore * 0.7)) + // + || + // + (bullScore < 30 && bearScore > 150) + // + || + // + (bullScore == bullScoreAVG100) + // + ); + // return result; } @@ -8705,27 +8739,27 @@ private: // bool result = false; - // // - // bool isCMStrShort = - // // - // mConditions.cMarketConditions.isTrendSwitchedToBearish && - // (mConditions.hMarketConditions.isTrendBearish && - // mConditions.lMarketConditions.isTrendBearish && - // mConditions.mMarketConditions.isTrendBearish && - // mConditions.sMarketConditions.isTrendBearish) - // // - // ; + // + bool isCMStrShort = + // + mConditions.cMarketConditions.isTrendSwitchedToBearish && + (mConditions.hMarketConditions.isTrendBearish && + mConditions.lMarketConditions.isTrendBearish && + mConditions.mMarketConditions.isTrendBearish && + mConditions.sMarketConditions.isTrendBearish) + // + ; - // // - // bool isSMStrShort = - // // - // mConditions.sMarketConditions.isTrendSwitchedToBearish && - // (mConditions.hMarketConditions.isTrendBearish && - // mConditions.lMarketConditions.isTrendBearish && - // mConditions.mMarketConditions.isTrendBearish && - // mConditions.cMarketConditions.isTrendBearish) - // // - // ; + // + bool isSMStrShort = + // + mConditions.sMarketConditions.isTrendSwitchedToBearish && + (mConditions.hMarketConditions.isTrendBearish && + mConditions.lMarketConditions.isTrendBearish && + mConditions.mMarketConditions.isTrendBearish && + mConditions.cMarketConditions.isTrendBearish) + // + ; // bool isMMStrShort = @@ -8760,19 +8794,16 @@ private: // ; - // - // bool isScorePassed = IsScorePassedForShort(); - // result = - // // - // isCMStrShort - // // - // || - // // - // isSMStrShort - // // - // || + // + isCMStrShort + // + || + // + isSMStrShort + // + || // isMMStrShort // @@ -8786,15 +8817,6 @@ private: // ; - // - // result = result && isScorePassed; - - // // - // if (result) - // { - // sl = GetMaxPeaks(); - // } - // return result; } @@ -8813,51 +8835,51 @@ private: // // Current Market ... - // bool isCMCShort = - // // - // ( - // // - // (mConditions.cMarketConditions.isSlowUnderVerifier && - // mConditions.cMarketConditions.isFastCrossedUnderVerifier) - // // - // || - // // - // (mConditions.cMarketConditions.isFastUnderVerifier && - // mConditions.cMarketConditions.isSlowCrossedUnderVerifier) - // // - // ) - // // - // && - // // - // (mConditions.cMarketConditions.isCloseUnderFast && - // mConditions.cMarketConditions.isCloseUnderSlow && - // mConditions.cMarketConditions.isCloseUnderVerifier) - // // - // ; + bool isCMCShort = + // + ( + // + (mConditions.cMarketConditions.isSlowUnderVerifier && + mConditions.cMarketConditions.isFastCrossedUnderVerifier) + // + || + // + (mConditions.cMarketConditions.isFastUnderVerifier && + mConditions.cMarketConditions.isSlowCrossedUnderVerifier) + // + ) + // + && + // + (mConditions.cMarketConditions.isCloseUnderFast && + mConditions.cMarketConditions.isCloseUnderSlow && + mConditions.cMarketConditions.isCloseUnderVerifier) + // + ; // // Short Market ... - // bool isSMCShort = - // // - // ( - // // - // (mConditions.sMarketConditions.isSlowUnderVerifier && - // mConditions.sMarketConditions.isFastCrossedUnderVerifier) - // // - // || - // // - // (mConditions.sMarketConditions.isFastUnderVerifier && - // mConditions.sMarketConditions.isSlowCrossedUnderVerifier) - // // - // ) - // // - // && - // // - // (mConditions.sMarketConditions.isCloseUnderFast && - // mConditions.sMarketConditions.isCloseUnderSlow && - // mConditions.sMarketConditions.isCloseUnderVerifier) - // // - // ; + bool isSMCShort = + // + ( + // + (mConditions.sMarketConditions.isSlowUnderVerifier && + mConditions.sMarketConditions.isFastCrossedUnderVerifier) + // + || + // + (mConditions.sMarketConditions.isFastUnderVerifier && + mConditions.sMarketConditions.isSlowCrossedUnderVerifier) + // + ) + // + && + // + (mConditions.sMarketConditions.isCloseUnderFast && + mConditions.sMarketConditions.isCloseUnderSlow && + mConditions.sMarketConditions.isCloseUnderVerifier) + // + ; // // Medium Market ... @@ -8931,19 +8953,16 @@ private: // ; - // - // bool isScorePassed = IsScorePassedForShort(); - // result = - // // - // isCMCShort - // // - // || - // // - // isSMCShort - // // - // || + // + isCMCShort + // + || + // + isSMCShort + // + || // isMMCShort // @@ -8957,15 +8976,6 @@ private: // ; - // // - // result = result && isScorePassed; - - // // - // if (result) - // { - // sl = GetMaxPeaks(); - // } - // return result; } @@ -8982,27 +8992,27 @@ private: // bool result = false; - // // - // bool isCCHEShort = - // // - // (mConditions.cMarketConditions.isCHESwitchedInStrongShort && - // (mConditions.sMarketConditions.isCHEInStrongShort && - // mConditions.mMarketConditions.isCHEInStrongShort && - // mConditions.lMarketConditions.isCHEInStrongShort && - // mConditions.hMarketConditions.isCHEInStrongShort)) - // // - // ; + // + bool isCCHEShort = + // + (mConditions.cMarketConditions.isCHESwitchedInStrongShort && + (mConditions.sMarketConditions.isCHEInStrongShort && + mConditions.mMarketConditions.isCHEInStrongShort && + mConditions.lMarketConditions.isCHEInStrongShort && + mConditions.hMarketConditions.isCHEInStrongShort)) + // + ; - // // - // bool isSCHEShort = - // // - // (mConditions.sMarketConditions.isCHESwitchedInStrongShort && - // (mConditions.cMarketConditions.isCHEInStrongShort && - // mConditions.mMarketConditions.isCHEInStrongShort && - // mConditions.lMarketConditions.isCHEInStrongShort && - // mConditions.hMarketConditions.isCHEInStrongShort)) - // // - // ; + // + bool isSCHEShort = + // + (mConditions.sMarketConditions.isCHESwitchedInStrongShort && + (mConditions.cMarketConditions.isCHEInStrongShort && + mConditions.mMarketConditions.isCHEInStrongShort && + mConditions.lMarketConditions.isCHEInStrongShort && + mConditions.hMarketConditions.isCHEInStrongShort)) + // + ; // bool isMCHEShort = @@ -9037,19 +9047,16 @@ private: // ; - // - // bool isScorePassed = IsScorePassedForShort(); - // result = - // // - // isCCHEShort - // // - // || - // // - // isSCHEShort - // // - // || + // + isCCHEShort + // + || + // + isSCHEShort + // + || // isMCHEShort // @@ -9063,9 +9070,6 @@ private: // ; - // - // result = result && isScorePassed; - // return result; } @@ -9179,8 +9183,7 @@ private: // bool isCSMHKShort = // - (isCSMHKBearish || - isCSMHKSwitchedToBearish) && + (isCSMHKSwitchedToBearish) && isSSMHKBearish && isMSMHKBearish && isLSMHKBearish && @@ -9191,8 +9194,7 @@ private: // bool isSSMHKShort = // - (isSSMHKBearish || - isSSMHKSwitchedToBearish) && + (isSSMHKSwitchedToBearish) && isCSMHKBearish && isMSMHKBearish && isLSMHKBearish && @@ -9203,8 +9205,7 @@ private: // bool isMSMHKShort = // - (isMSMHKBearish || - isMSMHKSwitchedToBearish) && + (isMSMHKSwitchedToBearish) && isSSMHKBearish && isCSMHKBearish && isLSMHKBearish && @@ -9215,8 +9216,7 @@ private: // bool isLSMHKShort = // - (isLSMHKBearish || - isLSMHKSwitchedToBearish) && + (isLSMHKSwitchedToBearish) && isSSMHKBearish && isCSMHKBearish && isMSMHKBearish && @@ -9227,8 +9227,7 @@ private: // bool isHSMHKShort = // - (isHSMHKBearish || - isHSMHKSwitchedToBearish) && + (isHSMHKSwitchedToBearish) && isSSMHKBearish && isCSMHKBearish && isMSMHKBearish && diff --git a/Classes/x-saherelm.x121.xea.class.mq5 b/Classes/x-saherelm.x121.xea.class.mq5 index 0269d3bd..a97f7fb1 100644 --- a/Classes/x-saherelm.x121.xea.class.mq5 +++ b/Classes/x-saherelm.x121.xea.class.mq5 @@ -422,35 +422,43 @@ public: // } // - string mSymbols[]; - XSCPositionHolder *mHolders[]; - int symbolsCount = FilterSymbolBasedPositions( - mSymbols, - mHolders // - ); - - // - for (int i = 0; i < symbolsCount; i++) + int signalsCount = ArraySize(signals); + if (IsValidSize(signalsCount)) { // - string iSymbol = mSymbols[i]; - XSCPositionHolder *iHolder = mHolders[i]; - - // - // We Can Select Multiple Positions for Place EQM Supports ... - - // - // Select Max In Drawdown Position and Protect it ... - XPosition iSelectedPosition; - bool iHasPosition = iHolder.GetMaxInDrawdown(iSelectedPosition); - if (iHasPosition) - { - // - // Try to Protect Max In Drawdown Positions Position ... - PlaceEQMOrders(iSelectedPosition); - } + Print("Cnverts " + ToString(signalsCount) + " Signal using SupRes ..."); } + // // + // string mSymbols[]; + // XSCPositionHolder *mHolders[]; + // int symbolsCount = FilterSymbolBasedPositions( + // mSymbols, + // mHolders // + // ); + + // // + // for (int i = 0; i < symbolsCount; i++) + // { + // // + // string iSymbol = mSymbols[i]; + // XSCPositionHolder *iHolder = mHolders[i]; + + // // + // // We Can Select Multiple Positions for Place EQM Supports ... + + // // + // // Select Max In Drawdown Position and Protect it ... + // XPosition iSelectedPosition; + // bool iHasPosition = iHolder.GetMaxInDrawdown(iSelectedPosition); + // if (iHasPosition) + // { + // // + // // Try to Protect Max In Drawdown Positions Position ... + // PlaceEQMOrders(iSelectedPosition); + // } + // } + // } @@ -722,10 +730,10 @@ public: // TODO: // Make them Configurable ... int maxTrailTPs = 5; - int levelsOnClose = 6; - int riskFreeLevel = 2; + // int levelsOnClose = 6; + int riskFreeLevel = 4; int requiredAgeForTrail = 0; - int requiredDistanceForTrail = 20; + int requiredDistanceForTrail = 10; // int positionsCount = ArraySize(positions); @@ -747,7 +755,9 @@ public: // bool canManageState = // - iPosition.provider != XEQMSupportToken + iPosition.provider != XEQMSupportToken + // && + // iPosition.provider != "WSC" // ; @@ -785,6 +795,7 @@ public: // // Check Position Profit Distance ... + // double reward = MathAbs(iPosition.tp - iPosition.entry); double priceDistanceInPoint = PriceToPoint(iPosition.profit / iPosition.volume, iPosition.symbol); double priceDistance = PointToPrice(priceDistanceInPoint, iPosition.symbol); if (priceDistance < requiredDistanceForTrail) @@ -874,6 +885,10 @@ public: : iPosition.sl // ; + if (riskFreeLevel > 0 && trail.level > riskFreeLevel) + { + appliedSL = slDiff; + } // double sl = @@ -1113,7 +1128,8 @@ public: // // dont Manage NON Signal Provider's signals ... string provider = iSignal.provider; - if (!IsValid(provider)) + bool canIgnore = !IsValid(provider) || provider == "EQM"; + if (canIgnore) { // AddRef( @@ -1161,7 +1177,7 @@ public: // continue; } - else if (positionsCount < 2) + else if (positionsCount < 4) { // // Next Signal in a While of Specific Provider ... @@ -1185,6 +1201,11 @@ public: signals // ); + // // + // if (youngest.profit > 0) + // { + // } + // continue; } diff --git a/Experts/x-test.x121ea.mq5 b/Experts/x-test.x121ea.mq5 index 51acdccc..56f1d3fe 100644 --- a/Experts/x-test.x121ea.mq5 +++ b/Experts/x-test.x121ea.mq5 @@ -31,20 +31,20 @@ // // Inputs ... -long x121EAMagicNumber = 78692110; // Magic Number -int x121EASlippage = 10; // Slippgae -string x121EASymbols = "EURUSDb,USDCHFb,GBPUSDb"; // Symbols +long x121EAMagicNumber = 78692110; // Magic Number +int x121EASlippage = 10; // Slippgae +string x121EASymbols = "EURUSDb"; // Symbols // bool x121EAAllowLong = true; // Allow Long Trades bool x121EAAllowShort = true; // Allow Short Trades int x121EAManageInterval = 0; // Manager Check Intervals Seconds -int x121EAMaxAllowedPositions = 5; // Max Allowed Positions +int x121EAMaxAllowedPositions = 10; // Max Allowed Positions double x121EAMaxAllowedSpread = 0; // Max Allowed Spred for Opening Trades -double x121EAMinProfitPerTrade = 3; // Min Profit Per Trade based On Volume Factor (Hedge) +double x121EAMinProfitPerTrade = 1; // Min Profit Per Trade based On Volume Factor (Hedge) double x121EAMinProfitPerVolumeFactor = 0.01; // Min Volume Factor for Calculating Profit (Hedge) -double x121EAMaxAllowedDrawdownFactor = 0.003; // Max Allowed Drawdown Factor +double x121EAMaxAllowedDrawdownFactor = 0.005; // Max Allowed Drawdown Factor // -double x121EAVolume = 0.01; +double x121EAVolume = 0.05; // // Vars ... diff --git a/Indicators/x-saherelm.xts.mq5 b/Indicators/x-saherelm.xts.mq5 index cbcf7a7e..e4b7e3a5 100644 --- a/Indicators/x-saherelm.xts.mq5 +++ b/Indicators/x-saherelm.xts.mq5 @@ -170,7 +170,7 @@ int OnInit() // DeInitialization ... void OnDeinit(const int reason) { - Comment(""); + // Comment(""); } // @@ -330,8 +330,8 @@ void CalculateBuffers(int bar_index) // // Commenting ... - string comment = GenerateDescriptionComment(); - Comment(comment); + // string comment = GenerateDescriptionComment(); + // Comment(comment); } //