From 851389f96b1644ef1d8b20a825f58ab5d57a0329 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Mon, 20 May 2024 14:10:29 +0330 Subject: [PATCH] everything is ready for start signal filtering ... --- Classes/x-saherelm.x5.provider.class.mq5 | 1453 ++++++++++++++++++++++ Libraries/x-saherelm.common.lib.mq5 | 103 ++ 2 files changed, 1556 insertions(+) diff --git a/Classes/x-saherelm.x5.provider.class.mq5 b/Classes/x-saherelm.x5.provider.class.mq5 index 23890583..081808e6 100644 --- a/Classes/x-saherelm.x5.provider.class.mq5 +++ b/Classes/x-saherelm.x5.provider.class.mq5 @@ -4359,6 +4359,68 @@ private: return result; } + // + // Validate Symbol ... + result = IsValidSymbolPeriod(); + if (!result) + { + return result; + } + + // + // Now We Can Filter Conditions based on Each Supported Symbol + // since we are in Correct Period ... + // NOTE: since base Common Conditions Checked Before, + // there is no need to double check them ... + + // + bool isEURUSD = IsEURUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDJPY = IsUSDJPY(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDCHF = IsUSDCHF(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isXAUUSD = IsXAUUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + // return result; } @@ -4396,6 +4458,68 @@ private: return result; } + // + // Validate Symbol ... + result = IsValidSymbolPeriod(); + if (!result) + { + return result; + } + + // + // Now We Can Filter Conditions based on Each Supported Symbol + // since we are in Correct Period ... + // NOTE: since base Common Conditions Checked Before, + // there is no need to double check them ... + + // + bool isEURUSD = IsEURUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDJPY = IsUSDJPY(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDCHF = IsUSDCHF(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isXAUUSD = IsXAUUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + // return result; } @@ -4458,6 +4582,68 @@ private: return result; } + // + // Validate Symbol ... + result = IsValidSymbolPeriod(); + if (!result) + { + return result; + } + + // + // Now We Can Filter Conditions based on Each Supported Symbol + // since we are in Correct Period ... + // NOTE: since base Common Conditions Checked Before, + // there is no need to double check them ... + + // + bool isEURUSD = IsEURUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDJPY = IsUSDJPY(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDCHF = IsUSDCHF(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isXAUUSD = IsXAUUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + // return result; } @@ -4520,6 +4706,68 @@ private: return result; } + // + // Validate Symbol ... + result = IsValidSymbolPeriod(); + if (!result) + { + return result; + } + + // + // Now We Can Filter Conditions based on Each Supported Symbol + // since we are in Correct Period ... + // NOTE: since base Common Conditions Checked Before, + // there is no need to double check them ... + + // + bool isEURUSD = IsEURUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDJPY = IsUSDJPY(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDCHF = IsUSDCHF(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isXAUUSD = IsXAUUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + // return result; } @@ -4588,6 +4836,68 @@ private: return result; } + // + // Validate Symbol ... + result = IsValidSymbolPeriod(); + if (!result) + { + return result; + } + + // + // Now We Can Filter Conditions based on Each Supported Symbol + // since we are in Correct Period ... + // NOTE: since base Common Conditions Checked Before, + // there is no need to double check them ... + + // + bool isEURUSD = IsEURUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDJPY = IsUSDJPY(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDCHF = IsUSDCHF(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isXAUUSD = IsXAUUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + // return result; } @@ -4656,6 +4966,68 @@ private: return result; } + // + // Validate Symbol ... + result = IsValidSymbolPeriod(); + if (!result) + { + return result; + } + + // + // Now We Can Filter Conditions based on Each Supported Symbol + // since we are in Correct Period ... + // NOTE: since base Common Conditions Checked Before, + // there is no need to double check them ... + + // + bool isEURUSD = IsEURUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDJPY = IsUSDJPY(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDCHF = IsUSDCHF(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isXAUUSD = IsXAUUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + // return result; } @@ -4728,6 +5100,68 @@ private: return result; } + // + // Validate Symbol ... + result = IsValidSymbolPeriod(); + if (!result) + { + return result; + } + + // + // Now We Can Filter Conditions based on Each Supported Symbol + // since we are in Correct Period ... + // NOTE: since base Common Conditions Checked Before, + // there is no need to double check them ... + + // + bool isEURUSD = IsEURUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDJPY = IsUSDJPY(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDCHF = IsUSDCHF(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isXAUUSD = IsXAUUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + // return result; } @@ -4800,6 +5234,68 @@ private: return result; } + // + // Validate Symbol ... + result = IsValidSymbolPeriod(); + if (!result) + { + return result; + } + + // + // Now We Can Filter Conditions based on Each Supported Symbol + // since we are in Correct Period ... + // NOTE: since base Common Conditions Checked Before, + // there is no need to double check them ... + + // + bool isEURUSD = IsEURUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDJPY = IsUSDJPY(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDCHF = IsUSDCHF(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isXAUUSD = IsXAUUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + // return result; } @@ -4879,6 +5375,68 @@ private: return result; } + // + // Validate Symbol ... + result = IsValidSymbolPeriod(); + if (!result) + { + return result; + } + + // + // Now We Can Filter Conditions based on Each Supported Symbol + // since we are in Correct Period ... + // NOTE: since base Common Conditions Checked Before, + // there is no need to double check them ... + + // + bool isEURUSD = IsEURUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDJPY = IsUSDJPY(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDCHF = IsUSDCHF(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isXAUUSD = IsXAUUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + // return result; } @@ -4958,6 +5516,68 @@ private: return result; } + // + // Validate Symbol ... + result = IsValidSymbolPeriod(); + if (!result) + { + return result; + } + + // + // Now We Can Filter Conditions based on Each Supported Symbol + // since we are in Correct Period ... + // NOTE: since base Common Conditions Checked Before, + // there is no need to double check them ... + + // + bool isEURUSD = IsEURUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDJPY = IsUSDJPY(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDCHF = IsUSDCHF(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isXAUUSD = IsXAUUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + // return result; } @@ -5038,6 +5658,68 @@ private: return result; } + // + // Validate Symbol ... + result = IsValidSymbolPeriod(); + if (!result) + { + return result; + } + + // + // Now We Can Filter Conditions based on Each Supported Symbol + // since we are in Correct Period ... + // NOTE: since base Common Conditions Checked Before, + // there is no need to double check them ... + + // + bool isEURUSD = IsEURUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDJPY = IsUSDJPY(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDCHF = IsUSDCHF(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isXAUUSD = IsXAUUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + // return result; } @@ -5118,6 +5800,68 @@ private: return result; } + // + // Validate Symbol ... + result = IsValidSymbolPeriod(); + if (!result) + { + return result; + } + + // + // Now We Can Filter Conditions based on Each Supported Symbol + // since we are in Correct Period ... + // NOTE: since base Common Conditions Checked Before, + // there is no need to double check them ... + + // + bool isEURUSD = IsEURUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDJPY = IsUSDJPY(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDCHF = IsUSDCHF(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isXAUUSD = IsXAUUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + // return result; } @@ -5194,6 +5938,68 @@ private: return result; } + // + // Validate Symbol ... + result = IsValidSymbolPeriod(); + if (!result) + { + return result; + } + + // + // Now We Can Filter Conditions based on Each Supported Symbol + // since we are in Correct Period ... + // NOTE: since base Common Conditions Checked Before, + // there is no need to double check them ... + + // + bool isEURUSD = IsEURUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDJPY = IsUSDJPY(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDCHF = IsUSDCHF(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isXAUUSD = IsXAUUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + // return result; } @@ -5270,6 +6076,68 @@ private: return result; } + // + // Validate Symbol ... + result = IsValidSymbolPeriod(); + if (!result) + { + return result; + } + + // + // Now We Can Filter Conditions based on Each Supported Symbol + // since we are in Correct Period ... + // NOTE: since base Common Conditions Checked Before, + // there is no need to double check them ... + + // + bool isEURUSD = IsEURUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDJPY = IsUSDJPY(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDCHF = IsUSDCHF(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isXAUUSD = IsXAUUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + // return result; } @@ -5355,6 +6223,68 @@ private: return result; } + // + // Validate Symbol ... + result = IsValidSymbolPeriod(); + if (!result) + { + return result; + } + + // + // Now We Can Filter Conditions based on Each Supported Symbol + // since we are in Correct Period ... + // NOTE: since base Common Conditions Checked Before, + // there is no need to double check them ... + + // + bool isEURUSD = IsEURUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDJPY = IsUSDJPY(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDCHF = IsUSDCHF(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isXAUUSD = IsXAUUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + // return result; } @@ -5439,6 +6369,68 @@ private: return result; } + // + // Validate Symbol ... + result = IsValidSymbolPeriod(); + if (!result) + { + return result; + } + + // + // Now We Can Filter Conditions based on Each Supported Symbol + // since we are in Correct Period ... + // NOTE: since base Common Conditions Checked Before, + // there is no need to double check them ... + + // + bool isEURUSD = IsEURUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDJPY = IsUSDJPY(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDCHF = IsUSDCHF(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isXAUUSD = IsXAUUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + // return result; } @@ -5526,6 +6518,68 @@ private: return result; } + // + // Validate Symbol ... + result = IsValidSymbolPeriod(); + if (!result) + { + return result; + } + + // + // Now We Can Filter Conditions based on Each Supported Symbol + // since we are in Correct Period ... + // NOTE: since base Common Conditions Checked Before, + // there is no need to double check them ... + + // + bool isEURUSD = IsEURUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDJPY = IsUSDJPY(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDCHF = IsUSDCHF(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isXAUUSD = IsXAUUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + // return result; } @@ -5608,6 +6662,68 @@ private: return result; } + // + // Validate Symbol ... + result = IsValidSymbolPeriod(); + if (!result) + { + return result; + } + + // + // Now We Can Filter Conditions based on Each Supported Symbol + // since we are in Correct Period ... + // NOTE: since base Common Conditions Checked Before, + // there is no need to double check them ... + + // + bool isEURUSD = IsEURUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDJPY = IsUSDJPY(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isUSDCHF = IsUSDCHF(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + + // + bool isXAUUSD = IsXAUUSD(); + if (isEURUSD) + { + // + result = + // + false + // + ; + } + // return result; } @@ -5621,6 +6737,145 @@ private: // this means each signaller (Provider) has their own implementation based on // Specific Period/Symbol parir ... + // + bool IsEURUSD() + { + // + string symbolIdentifiers[] = { + "EUR", + "USD" // + }; + + // + bool result = Contains( + symbolIdentifiers, + GetSymbol() // + ); + + // + return result; + } + + // + bool IsUSDJPY() + { + // + string symbolIdentifiers[] = { + "USD", + "JPY" // + }; + + // + bool result = Contains( + symbolIdentifiers, + GetSymbol() // + ); + + // + return result; + } + + // + bool IsUSDCHF() + { + // + string symbolIdentifiers[] = { + "USD", + "CHF" // + }; + + // + bool result = Contains( + symbolIdentifiers, + GetSymbol() // + ); + + // + return result; + } + + // + bool IsXAUUSD() + { + // + string symbolIdentifiers[] = { + "XAU", + "USD" // + }; + + // + bool result = Contains( + symbolIdentifiers, + GetSymbol() // + ); + + // + return result; + } + + // + bool IsValidSymbol() + { + // + bool isEURUSD = IsEURUSD(); + bool isUSDJPY = IsUSDJPY(); + bool isUSDCHF = IsUSDCHF(); + bool isXAUUSD = IsXAUUSD(); + + // + bool result = + // + isEURUSD + // + || + // + isUSDJPY + // + || + // + isUSDCHF + // + || + // + isXAUUSD + // + ; + + // + return result; + } + + // + bool IsValidPeriod() + { + // + ENUM_TIMEFRAMES period = GetPeriod(); + + // + bool result = period == PERIOD_M5; + + // + return result; + } + + // + bool IsValidSymbolPeriod() + { + // + bool result = + // + IsValidSymbol() + // + && + // + IsValidPeriod() + // + ; + + // + return result; + } + // // Detect Signal ... bool HasSpecificSignal( @@ -5681,6 +6936,12 @@ private: // if (hasXSPSignal) { + // + if (!IsValid(provider)) { + provider = ToString(XSP); + } + + // signalPusher++; } } @@ -5697,6 +6958,12 @@ private: // if (hasXTDSignal) { + // + if (!IsValid(provider)) { + provider = ToString(XTD); + } + + // signalPusher++; } } @@ -5713,6 +6980,12 @@ private: // if (hasXTAMSignal) { + // + if (!IsValid(provider)) { + provider = ToString(XTAM); + } + + // signalPusher++; } } @@ -5729,6 +7002,12 @@ private: // if (hasXSISignal) { + // + if (!IsValid(provider)) { + provider = ToString(XSI); + } + + // signalPusher++; } } @@ -5745,6 +7024,12 @@ private: // if (hasXTSFISignal) { + // + if (!IsValid(provider)) { + provider = ToString(XTSFI); + } + + // signalPusher++; } } @@ -5761,6 +7046,12 @@ private: // if (hasXOBDLHSignal) { + // + if (!IsValid(provider)) { + provider = ToString(XOBDLH); + } + + // signalPusher++; } } @@ -5777,6 +7068,12 @@ private: // if (hasXCHMACCSignal) { + // + if (!IsValid(provider)) { + provider = ToString(XCHMACC); + } + + // signalPusher++; } } @@ -5793,6 +7090,12 @@ private: // if (hasXCHMAMNSignal) { + // + if (!IsValid(provider)) { + provider = ToString(XCHMAMN); + } + + // signalPusher++; } } @@ -5809,9 +7112,60 @@ private: // if (hasXCHMAMXSignal) { + // + if (!IsValid(provider)) { + provider = ToString(XCHMAMX); + } + + // signalPusher++; } } + + // + result = + // + hasXSPSignal + // + || + // + hasXTDSignal + // + || + // + hasXTAMSignal + // + || + // + hasXSISignal + // + || + // + hasXTSFISignal + // + || + // + hasXOBDLHSignal + // + || + // + hasXCHMACCSignal + // + || + // + hasXCHMAMNSignal + // + || + // + hasXCHMAMXSignal + // + ; + + // + if (result) + { + return result; + } } // @@ -5847,6 +7201,12 @@ private: // if (hasXSPSignal) { + // + if (!IsValid(provider)) { + provider = ToString(XSP); + } + + // signalPusher++; } } @@ -5863,6 +7223,12 @@ private: // if (hasXTDSignal) { + // + if (!IsValid(provider)) { + provider = ToString(XTD); + } + + // signalPusher++; } } @@ -5879,6 +7245,12 @@ private: // if (hasXTAMSignal) { + // + if (!IsValid(provider)) { + provider = ToString(XTAM); + } + + // signalPusher++; } } @@ -5895,6 +7267,12 @@ private: // if (hasXSISignal) { + // + if (!IsValid(provider)) { + provider = ToString(XSI); + } + + // signalPusher++; } } @@ -5911,6 +7289,12 @@ private: // if (hasXTSFISignal) { + // + if (!IsValid(provider)) { + provider = ToString(XTSFI); + } + + // signalPusher++; } } @@ -5927,6 +7311,12 @@ private: // if (hasXOBDLHSignal) { + // + if (!IsValid(provider)) { + provider = ToString(XOBDLH); + } + + // signalPusher++; } } @@ -5943,6 +7333,12 @@ private: // if (hasXCHMACCSignal) { + // + if (!IsValid(provider)) { + provider = ToString(XCHMACC); + } + + // signalPusher++; } } @@ -5959,6 +7355,12 @@ private: // if (hasXCHMAMNSignal) { + // + if (!IsValid(provider)) { + provider = ToString(XCHMAMN); + } + + // signalPusher++; } } @@ -5975,9 +7377,60 @@ private: // if (hasXCHMAMXSignal) { + // + if (!IsValid(provider)) { + provider = ToString(XCHMAMX); + } + + // signalPusher++; } } + + // + result = + // + hasXSPSignal + // + || + // + hasXTDSignal + // + || + // + hasXTAMSignal + // + || + // + hasXSISignal + // + || + // + hasXTSFISignal + // + || + // + hasXOBDLHSignal + // + || + // + hasXCHMACCSignal + // + || + // + hasXCHMAMNSignal + // + || + // + hasXCHMAMXSignal + // + ; + + // + if (result) + { + return result; + } } // diff --git a/Libraries/x-saherelm.common.lib.mq5 b/Libraries/x-saherelm.common.lib.mq5 index 99c0b2d0..049965af 100644 --- a/Libraries/x-saherelm.common.lib.mq5 +++ b/Libraries/x-saherelm.common.lib.mq5 @@ -4810,6 +4810,109 @@ int GetBars( // // String ... +// +// Search a Content Contains Specific String or not ... +bool Contains( + string mQuery, // Search String + string mContent, // Search Content + bool ignoreCase = true // Ignore Case +) +{ + // + bool result = false; + + // + // Validate Query ... + result = IsValid(mQuery); + if (!result) + { + return result; + } + + // + // Validate Content ... + result = IsValid(mContent); + if (!result) + { + return result; + } + + // + // Normalize Inputs ... + string query = mQuery; + string content = mContent; + if (ignoreCase) + { + // + StringToLower(query); + StringToLower(content); + } + + // + int queryIdx = StringFind( + content, + query); + + // + result = queryIdx >= 0; + + // + return result; +} + +// +bool Contains( + string &mQueries[], // Search Strings + string mContent, // Search Content + bool ignoreCase = true // Ignore Case +) +{ + // + bool result = false; + + // + // Validate Queries ... + int queriesCount = ArraySize(mQueries); + result = queriesCount > 0; + if (!result) { + return result; + } + + // + // Validate Content ... + result = IsValid(mContent); + if (!result) { + return result; + } + + // + int containsCount = 0; + for (int i = 0; i < queriesCount; i++) { + // + bool isContains = Contains( + mQueries[i], + mContent, + ignoreCase + ); + + // + if (!isContains) { + // + result = false; + break; + } + + // + containsCount++; + } + + // + result = containsCount == queriesCount; + + // + return result; +} + // // Convert From String ... template