From 3a7f2850afc8ca37aa0087115c33e50f75c0afac Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Sun, 19 May 2024 22:51:07 +0330 Subject: [PATCH] last ... --- Classes/x-saherelm.x5.provider.class.mq5 | 1874 ++++++++++++++++++++++ 1 file changed, 1874 insertions(+) diff --git a/Classes/x-saherelm.x5.provider.class.mq5 b/Classes/x-saherelm.x5.provider.class.mq5 index 6fbe8ccb..376babad 100644 --- a/Classes/x-saherelm.x5.provider.class.mq5 +++ b/Classes/x-saherelm.x5.provider.class.mq5 @@ -44,8 +44,11 @@ // Definitions ... // +// Signallers ... enum ENUM_X5_SIGNAL_PROVIDERS { + // + NONE, // // XSP Expert Support Mechanism ... XSP, @@ -1281,6 +1284,88 @@ public: // // Functions ... + // + // Set Default Position's Type ... + // Enable / Disable Long (Buy), Short (Sell) ... + void SetSignalTypeState( + ENUM_POSITION_TYPE type, // Which types are Signals be Targetted + bool state // Which State is going to Set + ) + { + // + if (IsLong(type)) + { + mIsLongEnable = state; + } + else + { + mIsShortEnable = state; + } + } + + // + // Set Signal Providers ... + void SetSignalProviderState( + ENUM_X5_SIGNAL_PROVIDERS provider, // Provider State + bool state // Which state is going to set ... + ) + { + // + if (provider == NONE) + { + return; + } + + // + switch (provider) + { + // + case XSP: + mIsXSPSignalProviderEnable = state; + break; + + // + case XTD: + mIsXTDSignalProviderEnable = state; + break; + + // + case XTAM: + mIsXTAMSignalProviderEnable = state; + break; + + // + case XSI: + mIsXSISignalProviderEnable = state; + break; + + // + case XTSFI: + mIsXTSFISignalProviderEnable = state; + break; + + // + case XOBDLH: + mIsXOBDLHSignalProviderEnable = state; + break; + + // + case XCHMACC: + mIsXCHMACCSignalProviderEnable = state; + break; + + // + case XCHMAMN: + mIsXCHMAMNSignalProviderEnable = state; + break; + + // + case XCHMAMX: + mIsXCHMAMXSignalProviderEnable = state; + break; + } + } + // virtual string GetTag() { @@ -1578,8 +1663,345 @@ public: } // + // Retrieve Market Conditions ... GetMarketConditions(mConditions, barIndex); + // + // Now we Have to Pass the Conditions to Each Signal Provider + // for Retrieving Signals Based On them ... + + // + // Long ... + if (mIsLongEnable) + { + // + XSignal lSignal; + + // + 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++; + } + } + } + + // + // Short ... + if (mIsShortEnable) + { + // + XSignal sSignal; + + // + 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++; + } + } + } + // if (result) { @@ -1615,6 +2037,9 @@ private: // // Tools ... + // + // Calculations ... + // // Calculate Conditions ... void CalculateConditions(X5MarketConditions &mConditions) @@ -2521,4 +2946,1453 @@ private: mConditions.isXCHMALCFastUnderSlow && !isXCHMALCFastUnderSlowPrev; } + + // + // Signallers ... + + // + bool mIsLongEnable; + bool mIsShortEnable; + + // + bool mIsXSPSignalProviderEnable; + bool mIsXTDSignalProviderEnable; + bool mIsXTAMSignalProviderEnable; + bool mIsXSISignalProviderEnable; + bool mIsXTSFISignalProviderEnable; + bool mIsXOBDLHSignalProviderEnable; + bool mIsXCHMACCSignalProviderEnable; + bool mIsXCHMAMNSignalProviderEnable; + bool mIsXCHMAMXSignalProviderEnable; + + // + // Check Market Conditions is Ready for Long Signals or not ... + bool IsReadyForLong( + X5MarketConditions &mConditions, // Market Conditions ... + bool checkXCHMAMin = true, // Force Check XCHMA Min State + bool checkXCHMAMax = true, // Force Check XCHMA Max State + bool checkXCHMACycles = true, // Force Check XCHMA Cycles State + bool checkXCHMAPeaks = true, // Force Check XCHMA Peaks State + bool checkXCHMATrendPowers = true, // Force Check XCHMA Trend Powers + bool checkXOBD = true, // Force Check XOBD State + bool checkXTS = true // Force Check XTS State + ) + { + // + bool result = true; + + // + if (checkXCHMAMin) + { + // + result = + // + // XCHMA MIN ... + !( + // + (mConditions.isXCHMASCOverMin || + mConditions.isXCHMASCCrossedOverMin) && + (mConditions.isXCHMASCUnderMin || + mConditions.isXCHMASCCrossedUnderMin) + // + ); + } + + // + if (checkXCHMAMax && result) + { + // + result = + // + // XCHMA MAX ... + !( + // + (mConditions.isXCHMASCOverMax || + mConditions.isXCHMASCCrossedOverMax) && + (mConditions.isXCHMASCUnderMax || + mConditions.isXCHMASCCrossedUnderMax) + // + ) + // + ; + } + + // + if (checkXCHMACycles && result) + { + // + result = + // + // Check XCHMA Trend Bullish ... + ( + // + // All Cycles Bullish ... + ( + // + // SC ... + (mConditions.isXCHMASCFastOverSlow || + mConditions.isXCHMASCFastCrossedOverSlow) + // + && + // + // MC ... + (mConditions.isXCHMAMCFastOverSlow || + mConditions.isXCHMAMCFastCrossedOverSlow) + // + && + // + // LC ... + (mConditions.isXCHMALCFastOverSlow || + mConditions.isXCHMALCFastCrossedOverSlow) + // + ) + // + || + // + // Two Cycle Fully Bullish ... + ( + // + // SC and MC ... + ( + // + // SC ... + (mConditions.isXCHMASCFastOverSlow || + mConditions.isXCHMASCFastCrossedOverSlow) + // + && + // + // MC ... + (mConditions.isXCHMAMCFastOverSlow || + mConditions.isXCHMAMCFastCrossedOverSlow) + // + ) + // + || + // + // SC and LC ... + ( + // + // SC ... + (mConditions.isXCHMASCFastOverSlow || + mConditions.isXCHMASCFastCrossedOverSlow) + // + && + // + // LC ... + (mConditions.isXCHMALCFastOverSlow || + mConditions.isXCHMALCFastCrossedOverSlow) + // + ) + // + || + // + // MC and LC ... + ( + // + // MC ... + (mConditions.isXCHMAMCFastOverSlow || + mConditions.isXCHMAMCFastCrossedOverSlow) + // + && + // + // LC ... + (mConditions.isXCHMALCFastOverSlow || + mConditions.isXCHMALCFastCrossedOverSlow) + // + ) + // + ) + // + ) + // + ; + } + + // + if (checkXCHMAPeaks && result) + { + // + result = + // + // XCHMA Check Peaks ... + !( + // + // All Cycles Peak ... + (mConditions.isXCHMASCPeak && + mConditions.isXCHMAMCPeak && + mConditions.isXCHMALCPeak) + // + || + // + ( + // + // SC MC ... + (mConditions.isXCHMASCPeak && + mConditions.isXCHMAMCPeak) + // + || + // + // SC LC ... + (mConditions.isXCHMASCPeak && + mConditions.isXCHMALCPeak) + // + || + // + // MC LC ... + (mConditions.isXCHMAMCPeak && + mConditions.isXCHMALCPeak) + // + ) + // + ) + // + ; + } + + // + if (checkXCHMATrendPowers && result) + { + // + result = + // + // XCHMA Check Trends Power ... + !( + // + // All Trends Down ... + (mConditions.isXCHMASCTrendsDown && + mConditions.isXCHMAMCTrendsDown && + mConditions.isXCHMALCTrendsDown) + // + || + // + // Twisted pairs ... + ( + // + (mConditions.isXCHMASCTrendsDown && + mConditions.isXCHMAMCTrendsDown) + // + || + // + (mConditions.isXCHMASCTrendsDown && + mConditions.isXCHMALCTrendsDown) + // + || + // + (mConditions.isXCHMAMCTrendsDown && + mConditions.isXCHMALCTrendsDown) + // + ) + // + ) + // + ; + } + + // + if (checkXOBD && result) + { + // + result = + // + // XOBD Check Swings ... + !mConditions.isXOBDSwingLow + // + ; + } + + // + if (checkXTS && result) + { + result = + // + // XTS Check ... + !( + // + mConditions.isXTSCurrentMin && + // + ( + // + // All Under ... + ( + (mConditions.isXTSCurrentUnderNearest || + mConditions.isXTSCurrentCrossedUnderNearest) && + (mConditions.isXTSCurrentUnderMediest || + mConditions.isXTSCurrentCrossedUnderMediest) && + (mConditions.isXTSCurrentUnderFarest || + mConditions.isXTSCurrentCrossedUnderFarest)) + // + || + // + // Pairs ... + ( + // + ((mConditions.isXTSCurrentUnderNearest || + mConditions.isXTSCurrentCrossedUnderNearest) && + (mConditions.isXTSCurrentUnderMediest || + mConditions.isXTSCurrentCrossedUnderMediest)) + // + || + // + ((mConditions.isXTSCurrentUnderNearest || + mConditions.isXTSCurrentCrossedUnderNearest) && + (mConditions.isXTSCurrentUnderFarest || + mConditions.isXTSCurrentCrossedUnderFarest)) + // + || + // + ((mConditions.isXTSCurrentUnderMediest || + mConditions.isXTSCurrentCrossedUnderMediest) && + (mConditions.isXTSCurrentUnderFarest || + mConditions.isXTSCurrentCrossedUnderFarest)) + // + ) + // + ) + // + ) + // + ; + } + + // + return result; + } + + // + // Check Market Conditions is Ready for Short Signals or not ... + bool IsReadyForShort( + X5MarketConditions &mConditions, // Market Conditions ... + bool checkXCHMAMin = true, // Force Check XCHMA Min State + bool checkXCHMAMax = true, // Force Check XCHMA Max State + bool checkXCHMACycles = true, // Force Check XCHMA Cycles State + bool checkXCHMAVales = true, // Force Check XCHMA Vales State + bool checkXCHMATrendPowers = true, // Force Check XCHMA Trend Powers + bool checkXOBD = true, // Force Check XOBD State + bool checkXTS = true // Force Check XTS State + ) + { + // + bool result = true; + + // + if (checkXCHMAMin) + { + // + result = + // + // XCHMA MIN ... + !( + // + (mConditions.isXCHMASCOverMin || + mConditions.isXCHMASCCrossedOverMin) && + (mConditions.isXCHMASCUnderMin || + mConditions.isXCHMASCCrossedUnderMin) + // + ); + } + + // + if (checkXCHMAMax && result) + { + // + result = + // + // XCHMA MAX ... + !( + // + (mConditions.isXCHMASCOverMax || + mConditions.isXCHMASCCrossedOverMax) && + (mConditions.isXCHMASCUnderMax || + mConditions.isXCHMASCCrossedUnderMax) + // + ) + // + ; + } + + // + if (checkXCHMACycles && result) + { + // + result = + // + // Check XCHMA Trend Bullish ... + ( + // + // All Cycles Bullish ... + ( + // + // SC ... + (mConditions.isXCHMASCFastUnderSlow || + mConditions.isXCHMASCFastCrossedUnderSlow) + // + && + // + // MC ... + (mConditions.isXCHMAMCFastUnderSlow || + mConditions.isXCHMAMCFastCrossedUnderSlow) + // + && + // + // LC ... + (mConditions.isXCHMALCFastUnderSlow || + mConditions.isXCHMALCFastCrossedUnderSlow) + // + ) + // + || + // + // Two Cycle Fully Bullish ... + ( + // + // SC and MC ... + ( + // + // SC ... + (mConditions.isXCHMASCFastUnderSlow || + mConditions.isXCHMASCFastCrossedOverSlow) + // + && + // + // MC ... + (mConditions.isXCHMAMCFastUnderSlow || + mConditions.isXCHMAMCFastCrossedOverSlow) + // + ) + // + || + // + // SC and LC ... + ( + // + // SC ... + (mConditions.isXCHMASCFastUnderSlow || + mConditions.isXCHMASCFastCrossedUnderSlow) + // + && + // + // LC ... + (mConditions.isXCHMALCFastUnderSlow || + mConditions.isXCHMALCFastCrossedUnderSlow) + // + ) + // + || + // + // MC and LC ... + ( + // + // MC ... + (mConditions.isXCHMAMCFastUnderSlow || + mConditions.isXCHMAMCFastCrossedOverSlow) + // + && + // + // LC ... + (mConditions.isXCHMALCFastUnderSlow || + mConditions.isXCHMALCFastCrossedOverSlow) + // + ) + // + ) + // + ) + // + ; + } + + // + if (checkXCHMAVales && result) + { + // + result = + // + // XCHMA Check Vales ... + !( + // + // All Cycles Vale ... + (mConditions.isXCHMASCVale && + mConditions.isXCHMAMCVale && + mConditions.isXCHMALCVale) + // + || + // + ( + // + // SC MC ... + (mConditions.isXCHMASCVale && + mConditions.isXCHMAMCVale) + // + || + // + // SC LC ... + (mConditions.isXCHMASCVale && + mConditions.isXCHMALCVale) + // + || + // + // MC LC ... + (mConditions.isXCHMAMCVale && + mConditions.isXCHMALCVale) + // + ) + // + ) + // + ; + } + + // + if (checkXCHMATrendPowers && result) + { + // + result = + // + // XCHMA Check Trends Power ... + !( + // + // All Trends Down ... + (mConditions.isXCHMASCTrendsDown && + mConditions.isXCHMAMCTrendsDown && + mConditions.isXCHMALCTrendsDown) + // + || + // + // Twisted pairs ... + ( + // + (mConditions.isXCHMASCTrendsDown && + mConditions.isXCHMAMCTrendsDown) + // + || + // + (mConditions.isXCHMASCTrendsDown && + mConditions.isXCHMALCTrendsDown) + // + || + // + (mConditions.isXCHMAMCTrendsDown && + mConditions.isXCHMALCTrendsDown) + // + ) + // + ) + // + ; + } + + // + if (checkXOBD && result) + { + // + result = + // + // XOBD Check Swings ... + !mConditions.isXOBDSwingHigh + // + ; + } + + // + if (checkXTS && result) + { + // + result = + // + // XTS Check ... + !( + // + mConditions.isXTSCurrentMax && + // + ( + // + // All Over ... + ( + (mConditions.isXTSCurrentOverNearest || + mConditions.isXTSCurrentCrossedOverNearest) && + (mConditions.isXTSCurrentOverMediest || + mConditions.isXTSCurrentCrossedOverMediest) && + (mConditions.isXTSCurrentOverFarest || + mConditions.isXTSCurrentCrossedOverFarest)) + // + || + // + // Pairs ... + ( + // + ((mConditions.isXTSCurrentOverNearest || + mConditions.isXTSCurrentCrossedOverNearest) && + (mConditions.isXTSCurrentOverMediest || + mConditions.isXTSCurrentCrossedOverMediest)) + // + || + // + ((mConditions.isXTSCurrentOverNearest || + mConditions.isXTSCurrentCrossedOverNearest) && + (mConditions.isXTSCurrentOverFarest || + mConditions.isXTSCurrentCrossedOverFarest)) + // + || + // + ((mConditions.isXTSCurrentOverMediest || + mConditions.isXTSCurrentCrossedOverMediest) && + (mConditions.isXTSCurrentOverFarest || + mConditions.isXTSCurrentCrossedOverFarest)) + // + ) + // + ) + // + ) + // + ; + } + + // + return result; + } + + // + // XSP ... + bool XSPHasSLongignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + return result; + } + + // + // XSP ... + bool XSPHasSShortignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + return result; + } + + // + // XTD ... + bool XTDHasSLongignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + // each Strategy must has a Base Conditions, which they are usually common combinations + // of Market Properties that must be happens to lookup for signals ... + ( + // + mConditions.isXTDSignalCrossedOverBear + // + ) + // + && + // + // Next Step is combine sorts of Conditions which make our choice + // so Exact in Market ... + ( + // + IsReadyForLong(mConditions) + // + ) + // + ; + + // + return result; + } + + // + // XTD ... + bool XTDHasSShortignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + // each Strategy must has a Base Conditions, which they are usually common combinations + // of Market Properties that must be happens to lookup for signals ... + ( + // + mConditions.isXTDSignalCrossedUnderBear + // + ) + // + && + // + // Next Step is combine sorts of Conditions which make our choice + // so Exact in Market ... + ( + // + IsReadyForShort(mConditions) + // + ) + // + ; + + // + return result; + } + + // + // XTAM ... + bool XTAMHasSLongignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + // each Strategy must has a Base Conditions, which they are usually common combinations + // of Market Properties that must be happens to lookup for signals ... + ( + // + (mConditions.amas[1] > mConditions.tms[1] && + mConditions.amas[2] > mConditions.tms[2]) + // + && + // + !(mConditions.amas[2] > mConditions.tms[2] && + mConditions.amas[3] > mConditions.tms[3]) + // + ) + // + && + // + // Next Step is combine sorts of Conditions which make our choice + // so Exact in Market ... + ( + // + IsReadyForLong(mConditions) + // + ) + // + ; + + // + return result; + } + + // + // XTAM ... + bool XTAMHasSShortignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + // each Strategy must has a Base Conditions, which they are usually common combinations + // of Market Properties that must be happens to lookup for signals ... + ( + // + (mConditions.amas[1] < mConditions.amas[1] && + mConditions.amas[2] < mConditions.amas[2]) + // + && + // + !(mConditions.amas[2] < mConditions.amas[2] && + mConditions.amas[3] < mConditions.amas[3]) + // + ) + // + && + // + // Next Step is combine sorts of Conditions which make our choice + // so Exact in Market ... + ( + // + IsReadyForShort(mConditions) + // + ) + // + ; + + // + return result; + } + + // + // XSI ... + bool XSIHasSLongignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + // each Strategy must has a Base Conditions, which they are usually common combinations + // of Market Properties that must be happens to lookup for signals ... + ( + // + mConditions.isXRSICrossedOverLongEntry && + mConditions.rsis[3] < mInputs.rsiInputs.longEntryValue + // + ) + // + && + // + // Next Step is combine sorts of Conditions which make our choice + // so Exact in Market ... + ( + // + IsReadyForLong( + mConditions, + true, // XCHMA Min + true, // XCHMA Max + true, // XCHMA Cycles + true, // XCHMA Peaks + false, // XCHMA Trend Powers + true, // XOBD + true // XTS + ) + // + ) + // + ; + + // + return result; + } + + // + // XSI ... + bool XSIHasSShortignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + // each Strategy must has a Base Conditions, which they are usually common combinations + // of Market Properties that must be happens to lookup for signals ... + ( + // + mConditions.isXRSICrossedUnderShortEntry && + mConditions.rsis[3] > mInputs.rsiInputs.shortEntryValue + // + ) + // + && + // + // Next Step is combine sorts of Conditions which make our choice + // so Exact in Market ... + ( + // + IsReadyForShort( + mConditions, + true, // XCHMA Min + true, // XCHMA Max + true, // XCHMA Cycles + true, // XCHMA Peaks + false, // XCHMA Trend Powers + true, // XOBD + true // XTS + ) + // + ) + // + ; + + // + return result; + } + + // + // XTSFI ... + bool XTSFIHasSLongignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + double tsValues[] = { + mConditions.tsCurrents[1], + mConditions.tsNearests[1], + mConditions.tsMediests[1], + mConditions.tsFarests[1], + }; + + // + double tsMin = GetMin(tsValues); + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + // each Strategy must has a Base Conditions, which they are usually common combinations + // of Market Properties that must be happens to lookup for signals ... + ( + // + tsMin == mConditions.tsFarests[1] && + (mConditions.isXTSCurrentOverFarest || + mConditions.isXTSCurrentCrossedOverFarest) && + (mConditions.tsCurrents[1] < mConditions.tsNearests[1] || + mConditions.tsCurrents[1] < mConditions.tsMediests[1]) && + !(mConditions.isXTSCurrentUnderNearest || + mConditions.isXTSCurrentCrossedUnderNearest) + // + ) + // + && + // + // Next Step is combine sorts of Conditions which make our choice + // so Exact in Market ... + ( + // + IsReadyForLong(mConditions) + // + ) + // + ; + + // + return result; + } + + // + // XTSFI ... + bool XTSFIHasSShortignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + double tsValues[] = { + mConditions.tsCurrents[1], + mConditions.tsNearests[1], + mConditions.tsMediests[1], + mConditions.tsFarests[1], + }; + + // + double tsMax = GetMax(tsValues); + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + // each Strategy must has a Base Conditions, which they are usually common combinations + // of Market Properties that must be happens to lookup for signals ... + ( + // + tsMax == mConditions.tsFarests[1] && + (mConditions.isXTSCurrentUnderFarest || + mConditions.isXTSCurrentCrossedUnderFarest) && + (mConditions.tsCurrents[1] > mConditions.tsNearests[1] || + mConditions.tsCurrents[1] > mConditions.tsMediests[1]) && + !(mConditions.isXTSCurrentOverNearest || + mConditions.isXTSCurrentCrossedOverNearest) + // + ) + // + && + // + // Next Step is combine sorts of Conditions which make our choice + // so Exact in Market ... + ( + // + IsReadyForShort(mConditions) + // + ) + // + ; + + // + return result; + } + + // + // XOBDLH ... + bool XOBDLHHasSLongignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + X5MarketConditions mConditions2; + GetMarketConditions( + mConditions, + 2 // + ); + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + // each Strategy must has a Base Conditions, which they are usually common combinations + // of Market Properties that must be happens to lookup for signals ... + ( + // + mConditions2.isXOBDSwingLow && + mConditions2.isXLHLowAttachedLL && + mConditions.lhLls[1] >= mConditions.lhLls[2] + // + ) + // + && + // + // Next Step is combine sorts of Conditions which make our choice + // so Exact in Market ... + ( + // + IsReadyForLong( + mConditions, + true, // XCHMA Min + true, // XCHMA Max + false, // XCHMA Cycles + false, // XCHMA Peaks + false, // XCHMA Trend Powers + false, // XOBD + false // XTS + ) + // + ) + // + ; + + // + return result; + } + + // + // XOBDLH ... + bool XOBDLHHasSShortignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + X5MarketConditions mConditions2; + GetMarketConditions( + mConditions, + 2 // + ); + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + // each Strategy must has a Base Conditions, which they are usually common combinations + // of Market Properties that must be happens to lookup for signals ... + ( + // + mConditions2.isXOBDSwingHigh && + mConditions2.isXLHHighAttachedHH && + mConditions.lhHhs[1] <= mConditions.lhHhs[2] + // + ) + // + && + // + // Next Step is combine sorts of Conditions which make our choice + // so Exact in Market ... + ( + // + IsReadyForShort( + mConditions, + true, // XCHMA Min + true, // XCHMA Max + false, // XCHMA Cycles + false, // XCHMA Peaks + false, // XCHMA Trend Powers + false, // XOBD + false // XTS + ) + // + ) + // + ; + + // + return result; + } + + // + // XCHMACC ... + bool XCHMACCHasSLongignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + // each Strategy must has a Base Conditions, which they are usually common combinations + // of Market Properties that must be happens to lookup for signals ... + ( + // + mConditions.chmaScFasts[1] > mConditions.chmaScSlows[1] && + mConditions.chmaMcFasts[1] > mConditions.chmaMcSlows[1] && + mConditions.chmaLcFasts[1] > mConditions.chmaLcSlows[1] && + // + mConditions.chmaScFasts[2] > mConditions.chmaScSlows[2] && + mConditions.chmaMcFasts[2] > mConditions.chmaMcSlows[2] && + mConditions.chmaLcFasts[2] > mConditions.chmaLcSlows[2] && + // + !( + // + mConditions.chmaScFasts[3] > mConditions.chmaScSlows[3] && + mConditions.chmaMcFasts[3] > mConditions.chmaMcSlows[3] && + mConditions.chmaLcFasts[3] > mConditions.chmaLcSlows[3] + // + ) + // + ) + // + && + // + // Next Step is combine sorts of Conditions which make our choice + // so Exact in Market ... + ( + // + IsReadyForLong(mConditions) + // + ) + // + ; + + // + return result; + } + + // + // XCHMACC ... + bool XCHMACCHasSShortignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + // each Strategy must has a Base Conditions, which they are usually common combinations + // of Market Properties that must be happens to lookup for signals ... + ( + // + mConditions.chmaScFasts[1] < mConditions.chmaScSlows[1] && + mConditions.chmaMcFasts[1] < mConditions.chmaMcSlows[1] && + mConditions.chmaLcFasts[1] < mConditions.chmaLcSlows[1] && + // + mConditions.chmaScFasts[2] < mConditions.chmaScSlows[2] && + mConditions.chmaMcFasts[2] < mConditions.chmaMcSlows[2] && + mConditions.chmaLcFasts[2] < mConditions.chmaLcSlows[2] && + // + !( + // + mConditions.chmaScFasts[3] < mConditions.chmaScSlows[3] && + mConditions.chmaMcFasts[3] < mConditions.chmaMcSlows[3] && + mConditions.chmaLcFasts[3] < mConditions.chmaLcSlows[3] + // + ) + // + ) + // + && + // + // Next Step is combine sorts of Conditions which make our choice + // so Exact in Market ... + ( + // + IsReadyForLong(mConditions) + // + ) + // + ; + + // + return result; + } + + // + // XCHMAMN ... + bool XCHMAMNHasSLongignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + return result; + } + + // + // XCHMAMN ... + bool XCHMAMNHasSShortignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + return result; + } + + // + // XCHMAMX ... + bool XCHMAMXHasSLongignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + double nonSC2[] = { + mConditions.chmaMcFasts[2], + mConditions.chmaMcSlows[2], + mConditions.chmaLcFasts[2], + mConditions.chmaLcSlows[2], + }; + + // + double nonSCMax2 = GetMax(nonSC2); + double nonSCMin2 = GetMax(nonSC2); + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + // each Strategy must has a Base Conditions, which they are usually common combinations + // of Market Properties that must be happens to lookup for signals ... + ( + // + mConditions.isXCHMASCCrossedOverMax && + mConditions.chmaScFasts[2] < nonSCMax2 && + mConditions.chmaScSlows[2] < nonSCMax2 && + MathAbs(nonSCMax2 - mConditions.chmaScFasts[2]) > MathAbs(mConditions.chmaScFasts[2] - mConditions.chmaScSlows[2]) && + MathAbs(nonSCMax2 - mConditions.chmaScSlows[2]) > MathAbs(mConditions.chmaScFasts[2] - mConditions.chmaScSlows[2]) + // + ) + // + && + // + // Next Step is combine sorts of Conditions which make our choice + // so Exact in Market ... + ( + // + IsReadyForLong( + mConditions, + true, // XCHMA Min + true, // XCHMA Max + false, // XCHMA Cycles + false, // XCHMA Peaks + false, // XCHMA Trend Powers + true, // XOBD + true // XTS + ) + // + ) + // + ; + + // + return result; + } + + // + // XCHMAMX ... + bool XCHMAMXHasSShortignal( + X5MarketConditions &mConditions // + ) + { + // + bool result = false; + + // + double nonSC2[] = { + mConditions.chmaMcFasts[2], + mConditions.chmaMcSlows[2], + mConditions.chmaLcFasts[2], + mConditions.chmaLcSlows[2], + }; + + // + double nonSCMax2 = GetMax(nonSC2); + double nonSCMin2 = GetMax(nonSC2); + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + // each Strategy must has a Base Conditions, which they are usually common combinations + // of Market Properties that must be happens to lookup for signals ... + ( + // + mConditions.isXCHMASCCrossedUnderMax && + mConditions.chmaScFasts[2] > nonSCMax2 && + mConditions.chmaScSlows[2] > nonSCMax2 + // + ) + // + && + // + // Next Step is combine sorts of Conditions which make our choice + // so Exact in Market ... + ( + // + IsReadyForShort( + mConditions, + true, // XCHMA Min + true, // XCHMA Max + false, // XCHMA Cycles + false, // XCHMA Peaks + false, // XCHMA Trend Powers + true, // XOBD + true // XTS + ) + // + ) + // + ; + + // + return result; + } }; + +// +// Tools ... + +// +void GetAllX5SignalProviders(ENUM_X5_SIGNAL_PROVIDERS &result[]) +{ + // + Clean(result); + + // + Add(NONE, result); + Add(XSP, result); + Add(XTD, result); + Add(XTAM, result); + Add(XSI, result); + Add(XTSFI, result); + Add(XOBDLH, result); + Add(XCHMACC, result); + Add(XCHMAMN, result); + Add(XCHMAMX, result); +} + +// +ENUM_X5_SIGNAL_PROVIDERS ToX5SignalProvider(string content) +{ + // + ENUM_X5_SIGNAL_PROVIDERS result = NONE; + + // + if (!IsValid(content)) + { + return result; + } + + // + if (content == ToString(NONE)) + { + result = NONE; + } + else if (content == ToString(XSP)) + { + result = XSP; + } + else if (content == ToString(XTD)) + { + result = XTD; + } + else if (content == ToString(XTAM)) + { + result = XTAM; + } + else if (content == ToString(XSI)) + { + result = XSI; + } + else if (content == ToString(XTSFI)) + { + result = XTSFI; + } + else if (content == ToString(XOBDLH)) + { + result = XOBDLH; + } + else if (content == ToString(XCHMACC)) + { + result = XCHMACC; + } + else if (content == ToString(XCHMAMN)) + { + result = XCHMAMN; + } + else if (content == ToString(XCHMAMX)) + { + result = XCHMAMX; + } + + // + return result; +} + +// \ No newline at end of file