From d7b179a1366e83940cdf3cf4bb4c6a384c83fa89 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Mon, 20 May 2024 12:27:23 +0330 Subject: [PATCH] refactore some inpust and also start implementing Scoring mechanism ... --- Classes/x-saherelm.x5.provider.class.mq5 | 2039 ++++++++++++++++++---- Classes/x-saherelm.xprovider.class.mq5 | 9 +- Experts/x-test.x5ea.mq5 | 14 + Libraries/x-saherelm.common.lib.mq5 | 31 + 4 files changed, 1737 insertions(+), 356 deletions(-) diff --git a/Classes/x-saherelm.x5.provider.class.mq5 b/Classes/x-saherelm.x5.provider.class.mq5 index 70c5d3a5..a47d9651 100644 --- a/Classes/x-saherelm.x5.provider.class.mq5 +++ b/Classes/x-saherelm.x5.provider.class.mq5 @@ -744,17 +744,772 @@ public: // // Generate Score ... virtual void GenerateScore( - double &bullishScore, // Bullish Score - double &bearishScore, // Bearish Score - const double multiplier = 1 // Score Multiplier + double &bullishScore, // Bullish Score + double &bearishScore, // Bearish Score + double multiplier = 1 // Score Multiplier ) { + // + bullishScore = 0; + bearishScore = 0; + + // + // Normalize Multiplier ... + if (multiplier <= 0) + { + multiplier = 1; + } + + // + double bullScore = 0; + double bearScore = 0; + + // + // Calculate Scores ... + + // + // XTM ... + + // + if (isXTMPeak) + { + // + bullScore--; + bearScore++; + } + + // + if (isXTMVale) + { + // + bullScore++; + bearScore--; + } + + // + if (isXTMBullish) + { + bullScore++; + } + + // + if (isXTMBearish) + { + bearScore++; + } + + // + if (isXTMNeutural) + { + } + + // + if (isXTMEndBullish) + { + bearScore++; + } + + // + if (isXTMEndBearish) + { + bullScore++; + } + + // + if (isXTMStartBullish) + { + bullScore++; + } + + // + if (isXTMStartBearish) + { + bearScore++; + } + + // + if (isXTMEndBullishByNeutural) + { + bearScore++; + } + + // + if (isXTMEndBearishByNeutural) + { + bullScore++; + } + + // + if (isXTMStartBullishAfterNeutural) + { + bullScore++; + } + + // + if (isXTMStartBearishAfterNeutural) + { + bearScore++; + } + + // + // XAMA ... + + // + if (isXAMAPeak) + { + // + bullScore--; + bearScore++; + } + + // + if (isXAMAVale) + { + // + bullScore++; + bearScore--; + } + + // + if (isXAMABullish) + { + bullScore++; + } + + // + if (isXAMABearish) + { + bearScore++; + } + + // + if (isXAMANeutural) + { + } + + // + if (isXAMAEndBullish) + { + bearScore++; + } + + // + if (isXAMAEndBearish) + { + bullScore++; + } + + // + if (isXAMAStartBullish) + { + bullScore++; + } + + // + if (isXAMAStartBearish) + { + bearScore++; + } + + // + if (isXAMAEndBullishByNeutural) + { + bearScore++; + } + + // + if (isXAMAEndBearishByNeutural) + { + bullScore++; + } + + // + if (isXAMAStartBullishAfterNeutural) + { + bullScore++; + } + + // + if (isXAMAStartBearishAfterNeutural) + { + bearScore++; + } + + // + // XLH ... + + // + if (isXLHHHIncreased) + { + } + + // + if (isXLHHHDecreased) + { + } + + // + if (isXLHLLIncreased) + { + } + + // + if (isXLHLLDecreased) + { + } + + // + if (isXLHLowAttachedLL) + { + } + + // + if (isXLHHighAttachedHH) + { + } + + // + if (isXLHHHSameInLength) + { + } + + // + if (isXLHLLSameInLength) + { + } + + // + if (isXLHPriceOverSignal) + { + } + + // + if (isXLHPriceUnderSignal) + { + } + + // + if (isXLHPriceInSignalRange) + { + } + + // + if (isXLHPriceCrossedOverSignal) + { + } + + // + if (isXLHPriceCrossedUnderSignal) + { + } + + // + // XTD ... + + // + if (isXTDSignalPeak) + { + // + bullScore--; + bearScore++; + } + + // + if (isXTDSignalVale) + { + // + bullScore++; + bearScore--; + } + + // + if (isXTDBullishPeak) + { + // + bullScore--; + bearScore++; + } + + // + if (isXTDBullishVale) + { + // + bullScore++; + bearScore--; + } + + // + if (isXTDBearishPeak) + { + // + bullScore++; + bearScore--; + } + + // + if (isXTDBearishVale) + { + // + bullScore--; + bearScore++; + } + + // + if (isXTDBullOverBear) + { + } + + // + if (isXTDBullUnderBear) + { + } + + // + if (isXTDSignalOverBear) + { + } + + // + if (isXTDSignalUnderBear) + { + } + + // + if (isXTDBullCrossedOverBear) + { + } + + // + if (isXTDBullCrossedUnderBear) + { + } + + // + if (isXTDSignalCrossedOverBear) + { + } + + // + if (isXTDSignalCrossedUnderBear) + { + } + + // + // XFI ... + + // + if (isXFIPeak) + { + // + bullScore--; + bearScore++; + } + + // + if (isXFIVale) + { + // + bullScore++; + bearScore--; + } + + // + if (isXFICrossedOverZero) + { + } + + // + if (isXFIOverZero) + { + } + + // + if (isXFICrossedUnderZero) + { + } + + // + if (isXFIUnderZero) + { + } + + // + // XTS ... + + // + if (isXTSAllSame) + { + } + + // + if (isXTSCurrentMin) + { + } + + // + if (isXTSCurrentMax) + { + } + + // + if (isXTSCurrentOverFarest) + { + } + + // + if (isXTSCurrentOverNearest) + { + } + + // + if (isXTSCurrentOverMediest) + { + } + + // + if (isXTSCurrentUnderFarest) + { + } + + // + if (isXTSCurrentUnderNearest) + { + } + + // + if (isXTSCurrentUnderMediest) + { + } + + // + if (isXTSCurrentCrossedOverFarest) + { + } + + // + if (isXTSCurrentCrossedOverNearest) + { + } + + // + if (isXTSCurrentCrossedOverMediest) + { + } + + // + if (isXTSCurrentCrossedUnderFarest) + { + } + + // + if (isXTSCurrentCrossedUnderNearest) + { + } + + // + if (isXTSCurrentCrossedUnderMediest) + { + } + + // + // XSI ... + + // + if (isXRSIPeak) + { + // + bullScore--; + bearScore++; + } + + // + if (isXRSIVale) + { + // + bullScore++; + bearScore--; + } + + // + if (isXRSICrossedOverLongExit) + { + } + + // + if (isXRSICrossedOverLongEntry) + { + } + + // + if (isXRSICrossedUnderShortExit) + { + } + + // + if (isXRSICrossedUnderShortEntry) + { + } + + // + // XOBD ... + + // + if (isXOBDSwingLow) + { + } + + // + if (isXOBDSwingHigh) + { + } + + // + // XCHLH ... + + // + if (isXCHLHSameHHs) + { + } + + // + if (isXCHLHSameLLs) + { + } + + // + if (isXCHLHSCMCHHSame) + { + } + + // + if (isXCHLHSCMCLLSame) + { + } + + // + if (isXCHLHSCLCHHSame) + { + } + + // + if (isXCHLHSCLCLLSame) + { + } + + // + if (isXCHLHMCLCHHSame) + { + } + + // + if (isXCHLHMCLCLLSame) + { + } + + // + if (isXCHLHMCOnTopOfLC) + { + } + + // + if (isXCHLHMCInBottomOfLC) + { + } + + // + // XCHMA ... + + // + if (isXCHMASCOverMax) + { + } + + // + if (isXCHMASCOverMin) + { + } + + // + if (isXCHMASCUnderMax) + { + } + + // + if (isXCHMASCUnderMin) + { + } + + // + if (isXCHMASCCrossedOverMax) + { + } + + // + if (isXCHMASCCrossedUnderMax) + { + } + + // + if (isXCHMASCCrossedOverMin) + { + } + + // + if (isXCHMASCCrossedUnderMin) + { + } + + // + if (isXCHMASCPeak) + { + // + bullScore--; + bearScore++; + } + + // + if (isXCHMASCVale) + { + // + bullScore++; + bearScore--; + } + + // + if (isXCHMASCTrendsUp) + { + } + + // + if (isXCHMASCTrendsDown) + { + } + + // + if (isXCHMASCFastOverSlow) + { + } + + // + if (isXCHMASCFastUnderSlow) + { + } + + // + if (isXCHMASCFastCrossedOverSlow) + { + } + + // + if (isXCHMASCFastCrossedUnderSlow) + { + } + + // + if (isXCHMAMCPeak) + { + // + bullScore--; + bearScore++; + } + + // + if (isXCHMAMCVale) + { + // + bullScore++; + bearScore--; + } + + // + if (isXCHMAMCTrendsUp) + { + } + + // + if (isXCHMAMCTrendsDown) + { + } + + // + if (isXCHMAMCFastOverSlow) + { + } + + // + if (isXCHMAMCFastUnderSlow) + { + } + + // + if (isXCHMAMCFastCrossedOverSlow) + { + } + + // + if (isXCHMAMCFastCrossedUnderSlow) + { + } + + // + if (isXCHMALCPeak) + { + // + bullScore--; + bearScore++; + } + + // + if (isXCHMALCVale) + { + // + bullScore++; + bearScore--; + } + + // + if (isXCHMALCTrendsUp) + { + } + + // + if (isXCHMALCTrendsDown) + { + } + + // + if (isXCHMALCFastOverSlow) + { + } + + // + if (isXCHMALCFastUnderSlow) + { + } + + // + if (isXCHMALCFastCrossedOverSlow) + { + } + + // + if (isXCHMALCFastCrossedUnderSlow) + { + } + + // + // Prepare Final Result ... + + // + bullishScore = bullScore * multiplier; + bearishScore = bearScore * multiplier; } // // Generate Summary ... virtual string GenerateSummary( - const double multiplier = 1, // Score Multiplier + const bool onlySummary = false, // Only Generate Conditions Summary + double multiplier = 1, // Score Multiplier const string separator = "\n", // Separator const bool ignoreFalseConditions = true // Ignore False Conditions ) @@ -762,15 +1517,31 @@ public: // string result = NULL; + // + double bullScore = 0; + double bearScore = 0; + GenerateScore( + bullScore, + bearScore, + multiplier // + ); + // // Common ... string commonStr = // "Commons: " + separator + - "-----------------------------" + + "-----------------------------" + separator + "Time: " + ToString(TimeCurrent()) + separator + + "-----------" + separator + + "Scores: " + separator + + "-----------" + separator + + "Bullish: " + ToString(bullScore) + separator + + "Bearish: " + ToString(bearScore) + separator + + "-----------------------------" + separator + // // TODO: Add Scores Later ... + separator + "" // ; @@ -784,6 +1555,7 @@ public: "" // ; + obdStr = SetLabel("XOBD: ", obdStr, separator); // // ToString("", , ignoreFalseConditions) + @@ -801,6 +1573,7 @@ public: "" // ; + fiStr = SetLabel("XFI: ", fiStr, separator); // // XRSI ... @@ -815,6 +1588,7 @@ public: "" // ; + rsiStr = SetLabel("XRSI: ", rsiStr, separator); // // XTM ... @@ -833,10 +1607,10 @@ public: ToString("isXTMEndBearishByNeutural", isXTMEndBearishByNeutural, ignoreFalseConditions) + ToString("isXTMStartBullishAfterNeutural", isXTMStartBullishAfterNeutural, ignoreFalseConditions) + ToString("isXTMStartBearishAfterNeutural", isXTMStartBearishAfterNeutural, ignoreFalseConditions) + - "" // ; + tmStr = SetLabel("XTM: ", tmStr, separator); // // XAMA ... @@ -858,6 +1632,7 @@ public: "" // ; + amaStr = SetLabel("XAMA: ", amaStr, separator); // // XLH ... @@ -879,6 +1654,7 @@ public: "" // ; + lhStr = SetLabel("XLH: ", lhStr, separator); // // XTD ... @@ -901,6 +1677,7 @@ public: "" // ; + tdStr = SetLabel("XTD: ", tdStr, separator); // // XTS ... @@ -924,6 +1701,7 @@ public: "" // ; + tsStr = SetLabel("XTS: ", tsStr, separator); // // XCHLH ... @@ -942,6 +1720,7 @@ public: "" // ; + chlhStr = SetLabel("XCHLH: ", chlhStr, separator); // // XCHMA ... @@ -982,24 +1761,28 @@ public: "" // ; + chmaStr = SetLabel("XCHMA: ", chmaStr, separator); // // Generating Full Result by Combining parts ... result = // "[" + GetToken() + "]" + separator + - "----------------------" + separator + + "-----------------------------" + separator + commonStr + - obdStr + - fiStr + - rsiStr + - tmStr + - amaStr + - lhStr + - tdStr + - tsStr + - chlhStr + - chmaStr + + (onlySummary + ? "" + : obdStr + + fiStr + + rsiStr + + tmStr + + amaStr + + lhStr + + tdStr + + tsStr + + chlhStr + + chmaStr // + ) + "" // ; @@ -1010,6 +1793,10 @@ public: // // For Data Collector ... + string GetToken() + { + return GetToken(this); + } bool IsModelValid() { return false; @@ -1366,6 +2153,26 @@ public: } } + // + void SetSignalProviderStates( + ENUM_X5_SIGNAL_PROVIDERS &providers[], // Collection of Providers ... + bool state // Which state is going to set ... + ) + { + // + int providersCount = ArraySize(providers); + if (providersCount <= 0) + { + return; + } + + // + for (int i = 0; i < providersCount; i++) + { + SetSignalProviderState(providers[i], state); + } + } + // virtual string GetTag() { @@ -1656,6 +2463,7 @@ public: bool result = false; // + // Validate Enable Process ... result = !CanIgnoreProcess(); if (!result) { @@ -1663,177 +2471,42 @@ public: } // - // Retrieve Market Conditions ... - GetMarketConditions(mConditions, barIndex); + // Validate Enable Type of Signalling ... + result = mIsLongEnable || mIsShortEnable; + if (!result) + { + return result; + } // // Now we Have to Pass the Conditions to Each Signal Provider // for Retrieving Signals Based On them ... + // + // Reading Market Conditions ... + GetMarketConditions(mConditions, barIndex); + + // + int signalPusher = 0; + bool hasLong = false; + bool hasShort = false; + string provider = ""; + // // Long ... if (mIsLongEnable) { // - XSignal lSignal; + signalPusher = 0; // - int signalPusher = 0; - - // - bool hasXSPSignal = false; - bool hasXTDSignal = false; - bool hasXTAMSignal = false; - bool hasXSISignal = false; - bool hasXTSFISignal = false; - bool hasXOBDLHSignal = false; - bool hasXCHMACCSignal = false; - bool hasXCHMAMNSignal = false; - bool hasXCHMAMXSignal = false; - - // - // XPS ... - if (mIsXSPSignalProviderEnable) - { - // - hasXSPSignal = XSPHasSLongignal( - mConditions // - ); - - // - if (hasXSPSignal) - { - signalPusher++; - } - } - - // - // XTD ... - if (mIsXTDSignalProviderEnable) - { - // - hasXTDSignal = XTDHasSLongignal( - mConditions // - ); - - // - if (hasXTDSignal) - { - signalPusher++; - } - } - - // - // XTAM ... - if (mIsXTAMSignalProviderEnable) - { - // - hasXTAMSignal = XTAMHasSLongignal( - mConditions // - ); - - // - if (hasXTAMSignal) - { - signalPusher++; - } - } - - // - // XSI ... - if (mIsXSISignalProviderEnable) - { - // - hasXSISignal = XSIHasSLongignal( - mConditions // - ); - - // - if (hasXSISignal) - { - signalPusher++; - } - } - - // - // XTSFI ... - if (mIsXTSFISignalProviderEnable) - { - // - hasXTSFISignal = XTSFIHasSLongignal( - mConditions // - ); - - // - if (hasXTSFISignal) - { - signalPusher++; - } - } - - // - // XOBDLH ... - if (mIsXOBDLHSignalProviderEnable) - { - // - hasXOBDLHSignal = XOBDLHHasSLongignal( - mConditions // - ); - - // - if (hasXOBDLHSignal) - { - signalPusher++; - } - } - - // - // XCHMACC ... - if (mIsXCHMACCSignalProviderEnable) - { - // - hasXCHMACCSignal = XCHMACCHasSLongignal( - mConditions // - ); - - // - if (hasXCHMACCSignal) - { - signalPusher++; - } - } - - // - // XCHMAMN ... - if (mIsXCHMAMNSignalProviderEnable) - { - // - hasXCHMAMNSignal = XCHMAMNHasSLongignal( - mConditions // - ); - - // - if (hasXCHMAMNSignal) - { - signalPusher++; - } - } - - // - // XCHMAMX ... - if (mIsXCHMAMXSignalProviderEnable) - { - // - hasXCHMAMXSignal = XCHMAMXHasSLongignal( - mConditions // - ); - - // - if (hasXCHMAMXSignal) - { - signalPusher++; - } - } + hasLong = HasSpecificSignal( + barIndex, + POSITION_TYPE_BUY, + provider, + signalPusher, + mConditions // + ); } // @@ -1841,172 +2514,33 @@ public: if (mIsShortEnable) { // - XSignal sSignal; + signalPusher = 0; // - int signalPusher = 0; - - // - bool hasXSPSignal = false; - bool hasXTDSignal = false; - bool hasXTAMSignal = false; - bool hasXSISignal = false; - bool hasXTSFISignal = false; - bool hasXOBDLHSignal = false; - bool hasXCHMACCSignal = false; - bool hasXCHMAMNSignal = false; - bool hasXCHMAMXSignal = false; - - // - // XPS ... - if (mIsXSPSignalProviderEnable) - { - // - hasXSPSignal = XSPHasSShortignal( - mConditions // - ); - - // - if (hasXSPSignal) - { - signalPusher++; - } - } - - // - // XTD ... - if (mIsXTDSignalProviderEnable) - { - // - hasXTDSignal = XTDHasSShortignal( - mConditions // - ); - - // - if (hasXTDSignal) - { - signalPusher++; - } - } - - // - // XTAM ... - if (mIsXTAMSignalProviderEnable) - { - // - hasXTAMSignal = XTAMHasSShortignal( - mConditions // - ); - - // - if (hasXTAMSignal) - { - signalPusher++; - } - } - - // - // XSI ... - if (mIsXSISignalProviderEnable) - { - // - hasXSISignal = XSIHasSShortignal( - mConditions // - ); - - // - if (hasXSISignal) - { - signalPusher++; - } - } - - // - // XTSFI ... - if (mIsXTSFISignalProviderEnable) - { - // - hasXTSFISignal = XTSFIHasSShortignal( - mConditions // - ); - - // - if (hasXTSFISignal) - { - signalPusher++; - } - } - - // - // XOBDLH ... - if (mIsXOBDLHSignalProviderEnable) - { - // - hasXOBDLHSignal = XOBDLHHasSShortignal( - mConditions // - ); - - // - if (hasXOBDLHSignal) - { - signalPusher++; - } - } - - // - // XCHMACC ... - if (mIsXCHMACCSignalProviderEnable) - { - // - hasXCHMACCSignal = XCHMACCHasSShortignal( - mConditions // - ); - - // - if (hasXCHMACCSignal) - { - signalPusher++; - } - } - - // - // XCHMAMN ... - if (mIsXCHMAMNSignalProviderEnable) - { - // - hasXCHMAMNSignal = XCHMAMNHasSShortignal( - mConditions // - ); - - // - if (hasXCHMAMNSignal) - { - signalPusher++; - } - } - - // - // XCHMAMX ... - if (mIsXCHMAMXSignalProviderEnable) - { - // - hasXCHMAMXSignal = XCHMAMXHasSShortignal( - mConditions // - ); - - // - if (hasXCHMAMXSignal) - { - signalPusher++; - } - } + hasShort = HasSpecificSignal( + barIndex, + POSITION_TYPE_SELL, + provider, + signalPusher, + mConditions // + ); } + // + result = hasLong || hasShort; + if (!result) + { + return result; + } + + // + // Prepare Signal ... + // if (result) { // - string mConditionsStr = mConditions.GenerateSummary(); + string mConditionsStr = mConditions.GenerateSummary(true); mConditionsCollector.Add(mConditionsStr); Print("Conditions: " + "\n" + mConditionsStr); } @@ -3554,7 +4088,10 @@ private: // // XSP ... - bool XSPHasSLongignal( + + // + // Common Conditions ... + bool XSPHasLongSignal( X5MarketConditions &mConditions // ) { @@ -3565,9 +4102,33 @@ private: return result; } + // + // Symbol and Type Specific Conditions ... + bool XSPHasSpecifiedLongSignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + // Check Common Signal Conditions ... + result = XSPHasLongSignal(mConditions); + if (!result) + { + return result; + } + + // + return result; + } + // // XSP ... - bool XSPHasSShortignal( + + // + // Common Conditions ... + bool XSPHasShortSignal( X5MarketConditions &mConditions // ) { @@ -3578,9 +4139,33 @@ private: return result; } + // + // Symbol and Type Specific Conditions ... + bool XSPHasSpecifiedShortSignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + // Check Common Signal Conditions ... + result = XSPHasShortSignal(mConditions); + if (!result) + { + return result; + } + + // + return result; + } + // // XTD ... - bool XTDHasSLongignal( + + // + // Common Conditions ... + bool XTDHasLongSignal( X5MarketConditions &mConditions // ) { @@ -3616,9 +4201,33 @@ private: return result; } + // + // Symbol and Type Specific Conditions ... + bool XTDHasSpecifiedLongSignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + // Check Common Signal Conditions ... + result = XTDHasLongSignal(mConditions); + if (!result) + { + return result; + } + + // + return result; + } + // // XTD ... - bool XTDHasSShortignal( + + // + // Common Conditions ... + bool XTDHasShortSignal( X5MarketConditions &mConditions // ) { @@ -3654,9 +4263,33 @@ private: return result; } + // + // Symbol and Type Specific Conditions ... + bool XTDHasSpecifiedShortSignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + // Check Common Signal Conditions ... + result = XTDHasShortSignal(mConditions); + if (!result) + { + return result; + } + + // + return result; + } + // // XTAM ... - bool XTAMHasSLongignal( + + // + // Common Conditions ... + bool XTAMHasLongSignal( X5MarketConditions &mConditions // ) { @@ -3698,9 +4331,33 @@ private: return result; } + // + // Symbol and Type Specific Conditions ... + bool XTAMHasSpecifiedLongSignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + // Check Common Signal Conditions ... + result = XTAMHasLongSignal(mConditions); + if (!result) + { + return result; + } + + // + return result; + } + // // XTAM ... - bool XTAMHasSShortignal( + + // + // Common Conditions ... + bool XTAMHasShortSignal( X5MarketConditions &mConditions // ) { @@ -3742,9 +4399,33 @@ private: return result; } + // + // Symbol and Type Specific Conditions ... + bool XTAMHasSpecifiedShortSignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + // Check Common Signal Conditions ... + result = XTAMHasShortSignal(mConditions); + if (!result) + { + return result; + } + + // + return result; + } + // // XSI ... - bool XSIHasSLongignal( + + // + // Common Conditions ... + bool XSIHasLongSignal( X5MarketConditions &mConditions // ) { @@ -3790,9 +4471,33 @@ private: return result; } + // + // Symbol and Type Specific Conditions ... + bool XSIHasSpecifiedLongSignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + // Check Common Signal Conditions ... + result = XSIHasLongSignal(mConditions); + if (!result) + { + return result; + } + + // + return result; + } + // // XSI ... - bool XSIHasSShortignal( + + // + // Common Conditions ... + bool XSIHasShortSignal( X5MarketConditions &mConditions // ) { @@ -3838,9 +4543,33 @@ private: return result; } + // + // Symbol and Type Specific Conditions ... + bool XSIHasSpecifiedShortSignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + // Check Common Signal Conditions ... + result = XSIHasShortSignal(mConditions); + if (!result) + { + return result; + } + + // + return result; + } + // // XTSFI ... - bool XTSFIHasSLongignal( + + // + // Common Conditions ... + bool XTSFIHasLongSignal( X5MarketConditions &mConditions // ) { @@ -3893,9 +4622,33 @@ private: return result; } + // + // Symbol and Type Specific Conditions ... + bool XTSFIHasSpecifiedLongSignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + // Check Common Signal Conditions ... + result = XTSFIHasLongSignal(mConditions); + if (!result) + { + return result; + } + + // + return result; + } + // // XTSFI ... - bool XTSFIHasSShortignal( + + // + // Common Conditions ... + bool XTSFIHasShortSignal( X5MarketConditions &mConditions // ) { @@ -3948,9 +4701,33 @@ private: return result; } + // + // Symbol and Type Specific Conditions ... + bool XTSFIHasSpecifiedShortSignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + // Check Common Signal Conditions ... + result = XTSFIHasShortSignal(mConditions); + if (!result) + { + return result; + } + + // + return result; + } + // // XOBDLH ... - bool XOBDLHHasSLongignal( + + // + // Common Conditions ... + bool XOBDLHHasLongSignal( X5MarketConditions &mConditions // ) { @@ -4004,9 +4781,33 @@ private: return result; } + // + // Symbol and Type Specific Conditions ... + bool XOBDLHHasSpecifiedLongSignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + // Check Common Signal Conditions ... + result = XOBDLHHasLongSignal(mConditions); + if (!result) + { + return result; + } + + // + return result; + } + // // XOBDLH ... - bool XOBDLHHasSShortignal( + + // + // Common Conditions ... + bool XOBDLHHasShortSignal( X5MarketConditions &mConditions // ) { @@ -4060,9 +4861,33 @@ private: return result; } + // + // Symbol and Type Specific Conditions ... + bool XOBDLHHasSpecifiedShortSignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + // Check Common Signal Conditions ... + result = XOBDLHHasShortSignal(mConditions); + if (!result) + { + return result; + } + + // + return result; + } + // // XCHMACC ... - bool XCHMACCHasSLongignal( + + // + // Common Conditions ... + bool XCHMACCHasLongSignal( X5MarketConditions &mConditions // ) { @@ -4112,9 +4937,33 @@ private: return result; } + // + // Symbol and Type Specific Conditions ... + bool XCHMACCHasSpecifiedLongSignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + // Check Common Signal Conditions ... + result = XCHMACCHasLongSignal(mConditions); + if (!result) + { + return result; + } + + // + return result; + } + // // XCHMACC ... - bool XCHMACCHasSShortignal( + + // + // Common Conditions ... + bool XCHMACCHasShortSignal( X5MarketConditions &mConditions // ) { @@ -4164,9 +5013,33 @@ private: return result; } + // + // Symbol and Type Specific Conditions ... + bool XCHMACCHasSpecifiedShortSignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + // Check Common Signal Conditions ... + result = XCHMACCHasShortSignal(mConditions); + if (!result) + { + return result; + } + + // + return result; + } + // // XCHMAMN ... - bool XCHMAMNHasSLongignal( + + // + // Common Conditions ... + bool XCHMAMNHasLongSignal( X5MarketConditions &mConditions // ) { @@ -4225,9 +5098,33 @@ private: return result; } + // + // Symbol and Type Specific Conditions ... + bool XCHMAMNHasSpecifiedLongSignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + // Check Common Signal Conditions ... + result = XCHMAMNHasLongSignal(mConditions); + if (!result) + { + return result; + } + + // + return result; + } + // // XCHMAMN ... - bool XCHMAMNHasSShortignal( + + // + // Common Conditions ... + bool XCHMAMNHasShortSignal( X5MarketConditions &mConditions // ) { @@ -4285,9 +5182,33 @@ private: return result; } + // + // Symbol and Type Specific Conditions ... + bool XCHMAMNHasSpecifiedShortSignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + // Check Common Signal Conditions ... + result = XCHMAMNHasShortSignal(mConditions); + if (!result) + { + return result; + } + + // + return result; + } + // // XCHMAMX ... - bool XCHMAMXHasSLongignal( + + // + // Common Conditions ... + bool XCHMAMXHasLongSignal( X5MarketConditions &mConditions // ) { @@ -4348,9 +5269,30 @@ private: return result; } + // + // Symbol and Type Specific Conditions ... + bool XCHMAMXHasSpecifiedLongSignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + // Check Common Signal Conditions ... + result = XCHMAMXHasLongSignal(mConditions); + if (!result) + { + return result; + } + + // + return result; + } + // // XCHMAMX ... - bool XCHMAMXHasSShortignal( + bool XCHMAMXHasShortSignal( X5MarketConditions &mConditions // ) { @@ -4408,6 +5350,399 @@ private: // return result; } + + // + // Symbol and Type Specific Conditions ... + bool XCHMAMXHasSpecifiedShortSignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + // Check Common Signal Conditions ... + result = XCHMAMXHasShortSignal(mConditions); + if (!result) + { + return result; + } + + // + return result; + } + + // + // Signal Conditions Filtering ... + + // + // Here we have to Implement all Signals Conditional Filtering ... + // this Filtering works based on Symbol and Period .... + // this means each signaller (Provider) has their own implementation based on + // Specific Period/Symbol parir ... + + // + // Detect Signal ... + bool HasSpecificSignal( + int barIndex, // Specified Bar Index ... + ENUM_POSITION_TYPE mType, // Specific Signal Type ... + string &provider, // Signal Provider ... + int &signalPusher, // Number Of Same Time Signals ... + X5MarketConditions &mConditions // Specified Market Conition ... + ) + { + // + bool result = false; + + // + // Validate Signal Type is Enables ... + bool isLong = IsLong(mType); + result = + (isLong && mIsLongEnable) || + (!isLong && mIsShortEnable); + if (!result) + { + return result; + } + + // + // Now we have to Filter based on Enabled Signal Providers ... + + // + // Long ... + if (isLong && mIsLongEnable) + { + // + XSignal lSignal; + + // + signalPusher = 0; + + // + bool hasXSPSignal = false; + bool hasXTDSignal = false; + bool hasXTAMSignal = false; + bool hasXSISignal = false; + bool hasXTSFISignal = false; + bool hasXOBDLHSignal = false; + bool hasXCHMACCSignal = false; + bool hasXCHMAMNSignal = false; + bool hasXCHMAMXSignal = false; + + // + // XPS ... + if (mIsXSPSignalProviderEnable) + { + // + hasXSPSignal = XSPHasSpecifiedLongSignal( + mConditions // + ); + + // + if (hasXSPSignal) + { + signalPusher++; + } + } + + // + // XTD ... + if (mIsXTDSignalProviderEnable) + { + // + hasXTDSignal = XTDHasSpecifiedLongSignal( + mConditions // + ); + + // + if (hasXTDSignal) + { + signalPusher++; + } + } + + // + // XTAM ... + if (mIsXTAMSignalProviderEnable) + { + // + hasXTAMSignal = XTAMHasSpecifiedLongSignal( + mConditions // + ); + + // + if (hasXTAMSignal) + { + signalPusher++; + } + } + + // + // XSI ... + if (mIsXSISignalProviderEnable) + { + // + hasXSISignal = XSIHasSpecifiedLongSignal( + mConditions // + ); + + // + if (hasXSISignal) + { + signalPusher++; + } + } + + // + // XTSFI ... + if (mIsXTSFISignalProviderEnable) + { + // + hasXTSFISignal = XTSFIHasSpecifiedLongSignal( + mConditions // + ); + + // + if (hasXTSFISignal) + { + signalPusher++; + } + } + + // + // XOBDLH ... + if (mIsXOBDLHSignalProviderEnable) + { + // + hasXOBDLHSignal = XOBDLHHasSpecifiedLongSignal( + mConditions // + ); + + // + if (hasXOBDLHSignal) + { + signalPusher++; + } + } + + // + // XCHMACC ... + if (mIsXCHMACCSignalProviderEnable) + { + // + hasXCHMACCSignal = XCHMACCHasSpecifiedLongSignal( + mConditions // + ); + + // + if (hasXCHMACCSignal) + { + signalPusher++; + } + } + + // + // XCHMAMN ... + if (mIsXCHMAMNSignalProviderEnable) + { + // + hasXCHMAMNSignal = XCHMAMNHasSpecifiedLongSignal( + mConditions // + ); + + // + if (hasXCHMAMNSignal) + { + signalPusher++; + } + } + + // + // XCHMAMX ... + if (mIsXCHMAMXSignalProviderEnable) + { + // + hasXCHMAMXSignal = XCHMAMXHasSpecifiedLongSignal( + mConditions // + ); + + // + if (hasXCHMAMXSignal) + { + signalPusher++; + } + } + } + + // + // Short ... + if (!isLong && mIsShortEnable) + { + // + XSignal sSignal; + + // + signalPusher = 0; + + // + bool hasXSPSignal = false; + bool hasXTDSignal = false; + bool hasXTAMSignal = false; + bool hasXSISignal = false; + bool hasXTSFISignal = false; + bool hasXOBDLHSignal = false; + bool hasXCHMACCSignal = false; + bool hasXCHMAMNSignal = false; + bool hasXCHMAMXSignal = false; + + // + // XPS ... + if (mIsXSPSignalProviderEnable) + { + // + hasXSPSignal = XSPHasSpecifiedShortSignal( + mConditions // + ); + + // + if (hasXSPSignal) + { + signalPusher++; + } + } + + // + // XTD ... + if (mIsXTDSignalProviderEnable) + { + // + hasXTDSignal = XTDHasSpecifiedShortSignal( + mConditions // + ); + + // + if (hasXTDSignal) + { + signalPusher++; + } + } + + // + // XTAM ... + if (mIsXTAMSignalProviderEnable) + { + // + hasXTAMSignal = XTAMHasSpecifiedShortSignal( + mConditions // + ); + + // + if (hasXTAMSignal) + { + signalPusher++; + } + } + + // + // XSI ... + if (mIsXSISignalProviderEnable) + { + // + hasXSISignal = XSIHasSpecifiedShortSignal( + mConditions // + ); + + // + if (hasXSISignal) + { + signalPusher++; + } + } + + // + // XTSFI ... + if (mIsXTSFISignalProviderEnable) + { + // + hasXTSFISignal = XTSFIHasSpecifiedShortSignal( + mConditions // + ); + + // + if (hasXTSFISignal) + { + signalPusher++; + } + } + + // + // XOBDLH ... + if (mIsXOBDLHSignalProviderEnable) + { + // + hasXOBDLHSignal = XOBDLHHasSpecifiedShortSignal( + mConditions // + ); + + // + if (hasXOBDLHSignal) + { + signalPusher++; + } + } + + // + // XCHMACC ... + if (mIsXCHMACCSignalProviderEnable) + { + // + hasXCHMACCSignal = XCHMACCHasSpecifiedShortSignal( + mConditions // + ); + + // + if (hasXCHMACCSignal) + { + signalPusher++; + } + } + + // + // XCHMAMN ... + if (mIsXCHMAMNSignalProviderEnable) + { + // + hasXCHMAMNSignal = XCHMAMNHasSpecifiedShortSignal( + mConditions // + ); + + // + if (hasXCHMAMNSignal) + { + signalPusher++; + } + } + + // + // XCHMAMX ... + if (mIsXCHMAMXSignalProviderEnable) + { + // + hasXCHMAMXSignal = XCHMAMXHasSpecifiedShortSignal( + mConditions // + ); + + // + if (hasXCHMAMXSignal) + { + signalPusher++; + } + } + } + + // + return result; + } }; // diff --git a/Classes/x-saherelm.xprovider.class.mq5 b/Classes/x-saherelm.xprovider.class.mq5 index a4bca13a..717c9328 100644 --- a/Classes/x-saherelm.xprovider.class.mq5 +++ b/Classes/x-saherelm.xprovider.class.mq5 @@ -72,15 +72,16 @@ public: // // Generate Score ... virtual void GenerateScore( - double &bullishScore, // Bullish Score - double &bearishScore, // Bearish Score - const double multiplier = 1 // Score Multiplier + double &bullishScore, // Bullish Score + double &bearishScore, // Bearish Score + double multiplier = 1 // Score Multiplier ); // // Generate Summary ... virtual string GenerateSummary( - const double multiplier = 1, // Score Multiplier + const bool onlySummary = false, // Only Generate Conditions Summary + double multiplier = 1, // Score Multiplier const string separator = "\n", // Separator const bool ignoreFalseConditions = true // Ignore False Conditions ); diff --git a/Experts/x-test.x5ea.mq5 b/Experts/x-test.x5ea.mq5 index de7019ed..f8e02cbf 100644 --- a/Experts/x-test.x5ea.mq5 +++ b/Experts/x-test.x5ea.mq5 @@ -101,6 +101,20 @@ int OnInit() return INIT_PARAMETERS_INCORRECT; } + // + // Enable Required Signallers and Types ... + x5Provider.SetSignalTypeState( + POSITION_TYPE_BUY, + true); + x5Provider.SetSignalTypeState( + POSITION_TYPE_SELL, + true); + + // + ENUM_X5_SIGNAL_PROVIDERS providers[]; + GetAllX5SignalProviders(providers); + x5Provider.SetSignalProviderStates(providers, true); + // // Init Succeed ... return INIT_SUCCEEDED; diff --git a/Libraries/x-saherelm.common.lib.mq5 b/Libraries/x-saherelm.common.lib.mq5 index 18ede460..99c0b2d0 100644 --- a/Libraries/x-saherelm.common.lib.mq5 +++ b/Libraries/x-saherelm.common.lib.mq5 @@ -4864,6 +4864,37 @@ string ToString( return result; } +// +string SetLabel( + string mLabel, // Provided Label ... + string value, // Source Value ... + string separator = "\n", // Line Separator + bool addTopEmptyLine = true // Add Empty Line On top +) +{ + // + string result = value; + + // + if (StringLen(mLabel) <= 0) + { + return result; + } + + // + result = (StringLen(value) > 0) + ? (addTopEmptyLine ? separator : "") + + mLabel + + separator + + "-----------------------------" + + separator + + value + : value; + + // + return result; +} + // // Converts a Buffer to String Representation ... template