diff --git a/Experts/x-saherelm.xstrcci.ea.mq5 b/Experts/x-saherelm.xstrcci.ea.mq5 index 7772e202..a7050f92 100644 --- a/Experts/x-saherelm.xstrcci.ea.mq5 +++ b/Experts/x-saherelm.xstrcci.ea.mq5 @@ -62,4 +62,451 @@ XCAlert *eaAlert; XCTrade *eaTrade; // -XCX121XSTRHelper *strHelper; \ No newline at end of file +XSignal eaSignal; +XCXSTRCCISignaller *eaSignaller; +XSTRCCIStrategyConditions eaConditions; + +// +int eaMaxAllowedPositions = 5; +double eaMaxAllowedSpread = 25; +double eaMaxAllowedDrawdownFactor = 0.3; + +// +string eaTag = ""; + +// +// Event Handlers ... + +// +// Initialization ... +int OnInit() +{ + // + // Validate Inputs and Required Parameters + // for EA to Works fine ... + if (!ValidateInputs()) + { + return INIT_PARAMETERS_INCORRECT; + } + + // + // Initialize Timer ... + if (!InitTimer()) + { + return INIT_FAILED; + } + + // + // Initial Requirements ... + InitRequirements(); + + // + // Init Succeed ... + return INIT_SUCCEEDED; +} + +// +// DeInitialization ... +void OnDeinit(const int reason) +{ + // + // REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function + // REASON_REMOVE 1 Program removed from a chart + // REASON_RECOMPILE 2 Program recompiled + // REASON_CHARTCHANGE 3 A symbol or a chart period is changed + // REASON_CHARTCLOSE 4 Chart closed + // REASON_PARAMETERS 5 Inputs changed by a user + // REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings + // REASON_TEMPLATE 7 Another chart template applied + // REASON_INITFAILED 8 The OnInit() handler returned a non-zero value + // REASON_CLOSE 9 Terminal closed + + // + // Destroy Timer ... +} + +// +// On Tick Handler ... +void OnTick() +{ + // + int idx = -1; + int count = 0; + bool has = false; + + // + eaSignal.Clean(); + eaConditions.Clean(); + + // + double sl = 0; + double tp = 0; + double r2r = 5; + double risk = 0; + double entry = 0; + double reward = 0; + double volume = 0.01; + string provider = "XSTRCCI"; + ENUM_POSITION_TYPE type = POSITION_TYPE_BUY; + ENUM_X_ORDER_MODES mode = X_ORDER_MODE_MARKET; + + // + bool hasLong = false; + bool hasShort = false; + + // + double selectedSL = 0; + + // + // Start Calculations ... + + // + // Retrieve Common Data ... + string symbol = eaSignaller.GetSymbol(); + ENUM_TIMEFRAMES period = eaSignaller.GetPeriod(); + + // + datetime cTime = TimeCurrent(); + + // + // Required Value For SL/TP Calculations ... + double points = GetPoints(symbol); + double pip = GetPipPrice(symbol); + double pip2 = 2 * pip; + + // + has = eaSignaller.DetectSignalSetup( + r2r, + 300 // Max Allowed SL Distance ... + ); + if (has) + { + // + count = eaSignaller + .AddConditionsIfNotExists(); + + // + eaSignaller.mConditions.Clean(); + } + + // + // Check Setuped Conditions Exists ... + count = ArraySize(eaSignaller.mConditionsCollection); + has = IsValidSize(count); + if (!has) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + has = eaSignaller + .DetectSignalTrigger(eaSignaller + .mConditionsCollection[i]); + + // + if (has) + { + // + idx = i; + eaConditions = eaSignaller.mConditionsCollection[i]; + break; + } + } + + // + has = IsValidIndex(idx); + if (has) + { + // + ArrayRemove( + eaSignaller.mConditionsCollection, + idx, + 1 // + ); + } + + // + // Check EA Conditions is Valid or not ... + has = eaConditions.IsSetuped() && + eaConditions.CanTrigger(); + if (!has) + { + // + eaConditions.Clean(); + return; + } + + // + // Checking Trigger Direction ... + hasLong = eaConditions.HasBullishSignal(); + hasShort = eaConditions.HasBearishSignal(); + has = hasLong || + hasShort; + if (!has) + { + // + eaConditions.Clean(); + return; + } + + // + // Preparing Signal ... + // + eaSignal.sl = sl; + eaSignal.tp = tp; + eaSignal.type = type; + eaSignal.mode = mode; + eaSignal.entry = entry; + eaSignal.volume = volume; + eaSignal.symbol = symbol; + eaSignal.period = period; + eaSignal.provider = provider; + eaSignal.time = TimeCurrent(); + + // + Copy( + eaConditions.targets, + eaSignal.targets // + ); + + // + has = eaSignal.IsValid(); + if (!has) + { + // + eaSignal.Clean(); + eaConditions.Clean(); + return; + } + + // + // Draw Signal ... + + // + // Execute Signal ... + + // + Print("Execute Signal ..."); + + // + eaSignal.Clean(); + eaConditions.Clean(); +} + +// +// Handle On Trade Event ... +void OnTrade() +{ +} + +// +// On Timer ... +void OnTimer() +{ +} + +// +// Chart Event Handler ... +void OnChartEvent( + const int id, + const long &lparam, + const double &dparam, + const string &sparam // +) +{ +} + +// +// Event Listeners ... + +/** + * Handle StopLoss Triggered Positions ... + * + * @param deal: XDeal instance ... + */ +void OnStopLossTriggered(const XDeal &deal) +{ +} + +/** + * Handle Take Profit Triggered Positions ... + * + * @param deal: XDeal instance ... + */ +void OnTakeProfitTriggered(const XDeal &deal) +{ +} + +/** + * Handle Force Close a Position ... + * + * @param ticket: ULONG ... + * @param position: XPosition instance ... + * @param comment: String ... + */ +void OnPositionForceClosed( + const ulong ticket, + const XPosition &position, + const string comment // +) +{ +} + +/** + * Handle Deals Changes ... + * + * @param count: Integer, Number of Changes ... + */ +void OnDealsChanged(int count) +{ +} + +/** + * Handle Orders Changes ... + * + * @param count: Integer, Number of Changes ... + */ +void OnOrdersChanged(int count) +{ +} + +/** + * Handle Positions Changes ... + * + * @param count: Integer, Number of Changes ... + */ +void OnPositionsChanged(int count) +{ +} + +// +// Custom Functions ... + +/** + * Validate all Inputs of Expert Adviser ... + * + * @return ( bool ) + */ +bool ValidateInputs() +{ + // + bool result = false; + + // + string errMessage = ""; + + // + bool isCommonValid = ( + // + eaSlippage > 0 && + eaMagicNumber > 0 + // + ); + if (!isCommonValid) + { + // + errMessage += "common configurations error;" + "\n"; + } + + // + result = + // + // Common ... + isCommonValid && + // + // Otere ... + true + // + ; + + // + if (!result) + { + // + // Since here Logger not Initiallized, we Use Raw Print Command ... + Print(ShortName + " Errors: \n", errMessage); + } + + // + return result; +} + +/** + * Initialize Timer ... + * + * @return ( bool ) + */ +bool InitTimer() +{ + // + bool result = false; + + // + // TODO: Initialize Timer if necessary ... + // result = EventSetTimer(1); + // result = EventSetMillisecondTimer(100); + result = true; + + // + return result; +} + +/** + * Destroy Timer ... + */ +void DestroyTimer() +{ + // + // TODO: Use This ... + // EventKillTimer(); +} + +/** + * Initial Requirements of EA ... + * + */ +void InitRequirements() +{ + // + // Preparing Tags ... + eaTag = + (IsValid(eaLogSuffix) + ? eaLogSuffix + "_" + : "") + + ShortName; + + // + // EA Alert ... + eaAlert = new XCAlert( + eaTag, + eaEnableAlerts, + eaLogAlerts, + eaTerminalAlerts, + eaMailAlerts, + eaPushAlerts // + ); + + // + // EA Trade ... + eaTrade = new XCTrade( + eaSlippage, + eaMagicNumber, + eaMaxAllowedSpread, + eaMaxAllowedPositions, + eaMaxAllowedDrawdownFactor // + ); + + // + // EA Signaller ... + eaSignaller = new XCXSTRCCISignaller( + _Symbol, + _Period // + ); + + // +} + +// diff --git a/Helpers/x-saherelm.x121.xoscs.helper.mq5 b/Helpers/x-saherelm.x121.xoscs.helper.mq5 index 644a8e45..937ee4f8 100644 --- a/Helpers/x-saherelm.x121.xoscs.helper.mq5 +++ b/Helpers/x-saherelm.x121.xoscs.helper.mq5 @@ -69,9 +69,15 @@ struct X121XOCSInputs // Accumulation/Distribution ... ENUM_APPLIED_VOLUME adAppliedTo; // Applied To + // + // AC ... + int acBullishLevel; // Bullish Level + int acBearishLevel; // Bearish Level + // // ADX ... - int adxLength; // Length + int adxLength; // Length + int adxThreshold; // Big Movement Threshold // // ATR ... @@ -81,20 +87,31 @@ struct X121XOCSInputs // CCI ... int cciLength; // Length ENUM_APPLIED_PRICE cciAppliedTo; // Applied To + int cciOBLevel; // Over Bought Level + int cciOSLevel; // Over Sold Level + int cciReversalLevel; // Reversal Level // // RSI ... int rsiLength; // Length ENUM_APPLIED_PRICE rsiAppliedTo; // Applied To + int rsiOBLevel; // Over Bought Level + int rsiOSLevel; // Over Sold Level + int rsiReversalLevel; // Reversal Level // // MFI ... int mfiLength; // Length ENUM_APPLIED_VOLUME mfiAppliedTo; // Applied To + int mfiOBLevel; // Over Bought Level + int mfiOSLevel; // Over Sold Level + int mfiReversalLevel; // Reversal Level // // RVI ... - int rviLength; // Length + int rviLength; // Length + int rviBullishLevel; // Bullish Level + int rviBearishLevel; // Bearish Level // // MACD ... @@ -102,11 +119,15 @@ struct X121XOCSInputs int macdSlowLength; // Slow EMA Length int macdSignalLength; // Signal Length ENUM_APPLIED_PRICE macdAppliedTo; // Applied To + int macdBullishLevel; // Bullish Level + int macdBearishLevel; // Bearish Level // // Momentum ... int momentumLength; // Length ENUM_APPLIED_PRICE momentumAppliedTo; // Applied To + int momentumBullishLevel; // Bullish Level + int momentumBearishLevel; // Bearish Level // // Stochastic ... @@ -115,6 +136,9 @@ struct X121XOCSInputs int stochasticSmoothingLength; // Smoothing Length ENUM_MA_METHOD stochasticSmoothingMethod; // Smoothing Method ENUM_STO_PRICE stochasticAppliedTo; // Applied To + int stochasticOBLevel; // Over Bought Level + int stochasticOSLevel; // Over Sold Level + int stochasticReversalLevel; // Reversal Level // // Presentation ... @@ -138,9 +162,15 @@ struct X121XOCSInputs // Accumulation/Distribution ... adAppliedTo = VOLUME_TICK; // Applied To + // + // AC ... + acBullishLevel = 0; + acBearishLevel = 0; + // // ADX ... - adxLength = 0; // Length + adxLength = 0; // Length + adxThreshold = 0; // Big Movement Threshold // // ATR ... @@ -150,20 +180,31 @@ struct X121XOCSInputs // CCI ... cciLength = 0; // Length cciAppliedTo = PRICE_TYPICAL; // Applied To + cciOBLevel = 100; // Over Bought Level + cciOSLevel = -100; // Over Sold Level + cciReversalLevel = 0; // Reversal Level // // RSI ... rsiLength = 0; // Length rsiAppliedTo = PRICE_CLOSE; // Applied To + rsiOBLevel = 0; // Over Bought Level + rsiOSLevel = 0; // Over Sold Level + rsiReversalLevel = 0; // Reversal Level // // MFI ... mfiLength = 0; // Length mfiAppliedTo = VOLUME_TICK; // Applied To + mfiOBLevel = 0; // Over Bought Level + mfiOSLevel = 0; // Over Sold Level + mfiReversalLevel = 0; // Reversal Level // // RVI ... - rviLength = 0; // Length + rviLength = 0; // Length + rviBullishLevel = 0; // Bullish Level + rviBearishLevel = 0; // Bearish Level // // MACD ... @@ -171,11 +212,15 @@ struct X121XOCSInputs macdSlowLength = 0; // Slow EMA Length macdSignalLength = 0; // Signal Length macdAppliedTo = PRICE_CLOSE; // Applied To + macdBullishLevel = 0; // Bullish Level + macdBearishLevel = 0; // Bearish Level // // Momentum ... momentumLength = 0; // Length momentumAppliedTo = PRICE_CLOSE; // Applied To + momentumBullishLevel = 0; // Bullish Level + momentumBearishLevel = 0; // Bearish Level // // Stochastic ... @@ -184,6 +229,9 @@ struct X121XOCSInputs stochasticSmoothingLength = 0; // Smoothing Length stochasticSmoothingMethod = MODE_SMA; // Smoothing Method stochasticAppliedTo = STO_LOWHIGH; // Applied To + stochasticOBLevel = 0; // Over Bought Level + stochasticOSLevel = 0; // Over Sold Level + stochasticReversalLevel = 0; // Reversal Level // // Presentation ... @@ -201,9 +249,15 @@ struct X121XOCSInputs // Accumulation/Distribution ... adAppliedTo = VOLUME_TICK; // Applied To + // + // AC ... + acBullishLevel = 0; + acBearishLevel = 0; + // // ADX ... - adxLength = 14; // Length + adxLength = 14; // Length + adxThreshold = 25; // Big Movement Threshold // // ATR ... @@ -213,20 +267,31 @@ struct X121XOCSInputs // CCI ... cciLength = 14; // Length cciAppliedTo = PRICE_TYPICAL; // Applied To + cciOBLevel = 100; // Over Bought Level + cciOSLevel = -100; // Over Sold Level + cciReversalLevel = 0; // Reversal Level // // RSI ... rsiLength = 14; // Length rsiAppliedTo = PRICE_CLOSE; // Applied To + rsiOBLevel = 70; // Over Bought Level + rsiOSLevel = 30; // Over Sold Level + rsiReversalLevel = 50; // Reversal Level // // MFI ... mfiLength = 14; // Length mfiAppliedTo = VOLUME_TICK; // Applied To + mfiOBLevel = 80; // Over Bought Level + mfiOSLevel = 20; // Over Sold Level + mfiReversalLevel = 50; // Reversal Level // // RVI ... - rviLength = 14; // Length + rviLength = 14; // Length + rviBullishLevel = 0; // Bullish Level + rviBearishLevel = 0; // Bearish Level // // MACD ... @@ -234,11 +299,15 @@ struct X121XOCSInputs macdSlowLength = 26; // Slow EMA Length macdSignalLength = 9; // Signal Length macdAppliedTo = PRICE_CLOSE; // Applied To + macdBullishLevel = 0; // Bullish Level + macdBearishLevel = 0; // Bearish Level // // Momentum ... momentumLength = 14; // Length momentumAppliedTo = PRICE_CLOSE; // Applied To + momentumBullishLevel = 100; // Bullish Level + momentumBearishLevel = 100; // Bearish Level // // Stochastic ... @@ -247,6 +316,9 @@ struct X121XOCSInputs stochasticSmoothingLength = 3; // Smoothing Length stochasticSmoothingMethod = MODE_SMA; // Smoothing Method stochasticAppliedTo = STO_LOWHIGH; // Applied To + stochasticOBLevel = 80; // Over Bought Level + stochasticOSLevel = 20; // Over Sold Level + stochasticReversalLevel = 50; // Reversal Level // // Presentation ... @@ -264,10 +336,30 @@ struct X121XOCSInputs result = // adxLength > 0 && + adxThreshold > 0 && + // atrLength > 0 && + // cciLength > 0 && + cciOBLevel > 0 && + cciOSLevel != 0 && + cciOBLevel > cciReversalLevel && + cciOSLevel < cciReversalLevel && + // rsiLength > 0 && + rsiOBLevel > 0 && + rsiOSLevel > 0 && + rsiReversalLevel > 0 && + rsiOBLevel > rsiReversalLevel && + rsiOSLevel < rsiReversalLevel && + // mfiLength > 0 && + mfiOBLevel > 0 && + mfiOSLevel > 0 && + mfiReversalLevel > 0 && + mfiOBLevel > mfiReversalLevel && + mfiOSLevel < mfiReversalLevel && + // rviLength > 0 && // macdFastLength > 0 && @@ -278,6 +370,11 @@ struct X121XOCSInputs stochasticKLength > 0 && stochasticDLength > 0 && stochasticSmoothingLength > 0 && + stochasticOBLevel > 0 && + stochasticOSLevel > 0 && + stochasticReversalLevel > 0 && + stochasticOBLevel > stochasticReversalLevel && + stochasticOSLevel < stochasticReversalLevel && // momentumLength > 0 // @@ -345,6 +442,210 @@ struct X121XOCSConditions // // Conditions ... + // + // AC ... + + // + bool isACBullish; + bool isACBearish; + + // + bool isACSwitchedToBullish; + bool isACSwitchedToBearish; + + // + bool isACOverMax; + bool isACUnderMin; + + // + // AD ... + + // + bool isADBiggerLast; + bool isADLesserLast; + + // + bool isADOverMax; + bool isADUnderMin; + + // + // ADX ... + + // + bool isADXBiggerLast; + bool isADXLesserLast; + + // + bool isADXOverThreshold; + bool isADXUnderThreshold; + + // + bool isDXPBiggerThanDXN; + bool isDXNBiggerThanDXP; + + // + bool isADXBullish; + bool isADXBearish; + + // + bool isADXSwitchedToBullish; + bool isADXSwitchedToBearish; + + // + // ATR ... + + bool isATROverLast; + bool isATRUnderLast; + + // + // CCI ... + + // + bool isCCIBullish; + bool isCCIBearish; + + // + bool isCCISwitchedToBullish; + bool isCCISwitchedToBearish; + + // + bool isCCIOB; + bool isCCIOS; + + // + bool isCCICrossedOverOB; + bool isCCICrossedOverOS; + + // + bool isCCICrossedUnderOB; + bool isCCICrossedUnderOS; + + // + // RSI ... + + // + bool isRSIBullish; + bool isRSIBearish; + + // + bool isRSISwitchedToBullish; + bool isRSISwitchedToBearish; + + // + bool isRSIOB; + bool isRSIOS; + + // + bool isRSICrossedOverOB; + bool isRSICrossedOverOS; + + // + bool isRSICrossedUnderOB; + bool isRSICrossedUnderOS; + + // + // MFI ... + + // + bool isMFIBullish; + bool isMFIBearish; + + // + bool isMFISwitchedToBullish; + bool isMFISwitchedToBearish; + + // + bool isMFIOB; + bool isMFIOS; + + // + bool isMFICrossedOverOB; + bool isMFICrossedOverOS; + + // + bool isMFICrossedUnderOB; + bool isMFICrossedUnderOS; + + // + // RVI ... + + // + bool isRVIBullish; + bool isRVIBearish; + + // + bool isRVISwitchedToBullish; + bool isRVISwitchedToBearish; + + // + bool isRVIOverSignal; + bool isRVIUnderSignal; + + // + bool isRVICrossedOverSignal; + bool isRVICrossedUnderSignal; + + // + // MACD ... + + // + bool isMACDBullish; + bool isMACDBearish; + + // + bool isMACDSwitchedToBullish; + bool isMACDSwitchedToBearish; + + // + bool isMACDOverSignal; + bool isMACDUnderSignal; + + // + bool isMACDCrossedOverSignal; + bool isMACDCrossedUnderSignal; + + // + // MOMENTUM ... + + // + bool isMomentumBullish; + bool isMomentumBearish; + + // + bool isMomentumSwitchedToBullish; + bool isMomentumSwitchedToBearish; + + // + // STOCHASTIC ... + + // + bool isStochasticBullish; + bool isStochasticBearish; + + // + bool isStochasticSwitchedToBullish; + bool isStochasticSwitchedToBearish; + + // + bool isStochasticOverSignal; + bool isStochasticUnderSignal; + + // + bool isStochasticCrossedOverSignal; + bool isStochasticCrossedUnderSignal; + + // + bool isStochasticOB; + bool isStochasticOS; + + // + bool isStochasticCrossedOverOB; + bool isStochasticCrossedOverOS; + + // + bool isStochasticCrossedUnderOB; + bool isStochasticCrossedUnderOS; + // // Constructor ... X121XOCSConditions() @@ -408,6 +709,147 @@ struct X121XOCSConditions // // Conditions ... + // + // AC ... + + // + isACBullish = false; + isACBearish = false; + isACSwitchedToBullish = false; + isACSwitchedToBearish = false; + isACOverMax = false; + isACUnderMin = false; + + // + // AD ... + + // + isADBiggerLast = false; + isADLesserLast = false; + isADOverMax = false; + isADUnderMin = false; + + // + // ADX ... + + // + isADXBiggerLast = false; + isADXLesserLast = false; + isADXOverThreshold = false; + isADXUnderThreshold = false; + isDXPBiggerThanDXN = false; + isDXNBiggerThanDXP = false; + isADXBullish = false; + isADXBearish = false; + isADXSwitchedToBullish = false; + isADXSwitchedToBearish = false; + + // + // ATR ... + + // + isATROverLast = false; + isATRUnderLast = false; + + // + // CCI ... + + // + isCCIBullish = false; + isCCIBearish = false; + isCCISwitchedToBullish = false; + isCCISwitchedToBearish = false; + isCCIOB = false; + isCCIOS = false; + isCCICrossedOverOB = false; + isCCICrossedOverOS = false; + isCCICrossedUnderOB = false; + isCCICrossedUnderOS = false; + + // + // RSI ... + + // + isRSIBullish = false; + isRSIBearish = false; + isRSISwitchedToBullish = false; + isRSISwitchedToBearish = false; + isRSIOB = false; + isRSIOS = false; + isRSICrossedOverOB = false; + isRSICrossedOverOS = false; + isRSICrossedUnderOB = false; + isRSICrossedUnderOS = false; + + // + // MFI ... + + // + isMFIBullish = false; + isMFIBearish = false; + isMFISwitchedToBullish = false; + isMFISwitchedToBearish = false; + isMFIOB = false; + isMFIOS = false; + isMFICrossedOverOB = false; + isMFICrossedOverOS = false; + isMFICrossedUnderOB = false; + isMFICrossedUnderOS = false; + + // + // RVI ... + + // + isRVIBullish = false; + isRVIBearish = false; + isRVISwitchedToBullish = false; + isRVISwitchedToBearish = false; + isRVIOverSignal = false; + isRVIUnderSignal = false; + isRVICrossedOverSignal = false; + isRVICrossedUnderSignal = false; + + // + // MACD ... + + // + isMACDBullish = false; + isMACDBearish = false; + isMACDSwitchedToBullish = false; + isMACDSwitchedToBearish = false; + isMACDOverSignal = false; + isMACDUnderSignal = false; + isMACDCrossedOverSignal = false; + isMACDCrossedUnderSignal = false; + + // + // MOMENTUM ... + + // + isMomentumBullish = false; + isMomentumBearish = false; + isMomentumSwitchedToBullish = false; + isMomentumSwitchedToBearish = false; + + // + // STOCHASTIC ... + + // + isStochasticBullish = false; + isStochasticBearish = false; + isStochasticSwitchedToBullish = false; + isStochasticSwitchedToBearish = false; + isStochasticOverSignal = false; + isStochasticUnderSignal = false; + isStochasticCrossedOverSignal = false; + isStochasticCrossedUnderSignal = false; + isStochasticOB = false; + isStochasticOS = false; + isStochasticCrossedOverOB = false; + isStochasticCrossedOverOS = false; + isStochasticCrossedUnderOB = false; + isStochasticCrossedUnderOS = false; + // ZeroMemory(this); } @@ -432,25 +874,430 @@ struct X121XOCSConditions double minScore = 0.5; double highScore = 1.5; - // // - // if (isSarBullish) - // { - // bullishScore += minScore; - // } - // if (isSarSwitchedToBullish) - // { - // bullishScore += score; - // } + // - // // - // if (isSarBearish) - // { - // bearishScore += minScore; - // } - // if (isSarSwitchedToBearish) - // { - // bearishScore += score; - // } + // + // AC ... + + // + if (isACBullish) + { + bullishScore += minScore; + } + if (isACOverMax) + { + bullishScore += minScore; + } + if (isACSwitchedToBullish) + { + bullishScore += minScore; + } + + // + if (isACBearish) + { + bearishScore += minScore; + } + if (isACUnderMin) + { + bearishScore += minScore; + } + if (isACSwitchedToBearish) + { + bearishScore += minScore; + } + + // + // AD ... + + // + if (isADOverMax) + { + bullishScore += minScore; + } + if (isADBiggerLast) + { + bullishScore += minScore; + } + + // + if (isADUnderMin) + { + bearishScore += minScore; + } + if (isADLesserLast) + { + bearishScore += minScore; + } + + // + // ADX ... + + // + if (isADXBullish) + { + bullishScore += minScore; + } + if (isADXBiggerLast) + { + bullishScore += minScore; + } + if (isADXOverThreshold) + { + bullishScore += minScore; + } + if (isDXPBiggerThanDXN) + { + bullishScore += minScore; + } + if (isADXSwitchedToBullish) + { + bullishScore += minScore; + } + + // + if (isADXBearish) + { + bearishScore += minScore; + } + if (isADXLesserLast) + { + bearishScore += minScore; + } + if (isDXNBiggerThanDXP) + { + bearishScore += minScore; + } + if (isADXUnderThreshold) + { + bearishScore += minScore; + } + if (isADXSwitchedToBearish) + { + bearishScore += minScore; + } + + // + // ATR ... + + // + if (isATROverLast) + { + bullishScore += minScore; + } + + // + if (isATRUnderLast) + { + bearishScore += minScore; + } + + // + // CCI ... + + // + if (isCCIOS) + { + bullishScore += minScore; + } + if (isCCIBullish) + { + bullishScore += minScore; + } + if (isCCICrossedOverOS) + { + bullishScore += minScore; + } + if (isCCICrossedOverOB) + { + bullishScore += minScore; + } + if (isCCISwitchedToBullish) + { + bullishScore += minScore; + } + + // + if (isCCIOB) + { + bearishScore += minScore; + } + if (isCCIBearish) + { + bearishScore += minScore; + } + if (isCCICrossedUnderOS) + { + bearishScore += minScore; + } + if (isCCICrossedUnderOB) + { + bearishScore += minScore; + } + if (isCCISwitchedToBearish) + { + bearishScore += minScore; + } + + // + // RSI ... + + // + if (isRSIOS) + { + bullishScore += minScore; + } + if (isRSIBullish) + { + bullishScore += minScore; + } + if (isRSICrossedOverOB) + { + bullishScore += minScore; + } + if (isRSICrossedOverOS) + { + bullishScore += minScore; + } + if (isRSISwitchedToBullish) + { + bullishScore += minScore; + } + + // + if (isRSIOB) + { + bearishScore += minScore; + } + if (isRSIBearish) + { + bearishScore += minScore; + } + if (isRSICrossedUnderOB) + { + bearishScore += minScore; + } + if (isRSICrossedUnderOS) + { + bearishScore += minScore; + } + if (isRSISwitchedToBearish) + { + bearishScore += minScore; + } + + // + // MFI ... + + // + if (isMFIOS) + { + bullishScore += minScore; + } + if (isMFIBullish) + { + bullishScore += minScore; + } + if (isMFICrossedOverOB) + { + bullishScore += minScore; + } + if (isMFICrossedOverOS) + { + bullishScore += minScore; + } + if (isMFISwitchedToBullish) + { + bullishScore += minScore; + } + + // + if (isMFIOB) + { + bearishScore += minScore; + } + if (isMFIBearish) + { + bearishScore += minScore; + } + if (isMFICrossedUnderOB) + { + bearishScore += minScore; + } + if (isMFICrossedUnderOS) + { + bearishScore += minScore; + } + if (isMFISwitchedToBearish) + { + bearishScore += minScore; + } + + // + // RVI ... + + // + if (isRVIBullish) + { + bullishScore += minScore; + } + if (isRVIOverSignal) + { + bullishScore += minScore; + } + if (isRVISwitchedToBullish) + { + bullishScore += minScore; + } + if (isRVICrossedOverSignal) + { + bullishScore += minScore; + } + + // + if (isRVIBearish) + { + bearishScore += minScore; + } + if (isRVIUnderSignal) + { + bearishScore += minScore; + } + if (isRVISwitchedToBearish) + { + bearishScore += minScore; + } + if (isRVICrossedUnderSignal) + { + bearishScore += minScore; + } + + // + // MACD ... + + // + if (isMACDBullish) + { + bullishScore += minScore; + } + if (isMACDOverSignal) + { + bullishScore += minScore; + } + if (isMACDSwitchedToBullish) + { + bullishScore += minScore; + } + if (isMACDCrossedOverSignal) + { + bullishScore += minScore; + } + + // + if (isMACDBearish) + { + bearishScore += minScore; + } + if (isMACDUnderSignal) + { + bearishScore += minScore; + } + if (isMACDSwitchedToBearish) + { + bearishScore += minScore; + } + if (isMACDCrossedUnderSignal) + { + bearishScore += minScore; + } + + // + // MOMENTUM ... + + // + if (isMomentumBullish) + { + bullishScore += minScore; + } + if (isMomentumSwitchedToBullish) + { + bullishScore += minScore; + } + + // + if (isMomentumBearish) + { + bearishScore += minScore; + } + if (isMomentumSwitchedToBearish) + { + bearishScore += minScore; + } + + // + // STOCHASTIC ... + + // + if (isStochasticOS) + { + bullishScore += minScore; + } + if (isStochasticOverSignal) + { + bullishScore += minScore; + } + if (isStochasticBullish) + { + bullishScore += minScore; + } + if (isStochasticCrossedOverSignal) + { + bullishScore += minScore; + } + if (isStochasticCrossedOverOB) + { + bullishScore += minScore; + } + if (isStochasticCrossedOverOS) + { + bullishScore += minScore; + } + if (isStochasticSwitchedToBullish) + { + bullishScore += minScore; + } + + // + if (isStochasticOB) + { + bearishScore += minScore; + } + if (isStochasticUnderSignal) + { + bearishScore += minScore; + } + if (isStochasticBearish) + { + bearishScore += minScore; + } + if (isStochasticCrossedUnderSignal) + { + bearishScore += minScore; + } + if (isStochasticCrossedUnderOB) + { + bearishScore += minScore; + } + if (isStochasticCrossedUnderOS) + { + bearishScore += minScore; + } + if (isStochasticSwitchedToBearish) + { + bearishScore += minScore; + } + + // } /** @@ -507,7 +1354,92 @@ struct X121XOCSConditions "-----------------------" + separator + "XOSCS: " + separator + "-----------------------" + separator + - // ToString("isSarBullish", isSarBullish, ignoreFalseConditions, separator) + + ToString("isACBullish", isACBullish, ignoreFalseConditions, separator) + + ToString("isACBearish", isACBearish, ignoreFalseConditions, separator) + + ToString("isACSwitchedToBullish", isACSwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isACSwitchedToBearish", isACSwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isACOverMax", isACOverMax, ignoreFalseConditions, separator) + + ToString("isACUnderMin", isACUnderMin, ignoreFalseConditions, separator) + + ToString("isADBiggerLast", isADBiggerLast, ignoreFalseConditions, separator) + + ToString("isADLesserLast", isADLesserLast, ignoreFalseConditions, separator) + + ToString("isADOverMax", isADOverMax, ignoreFalseConditions, separator) + + ToString("isADUnderMin", isADUnderMin, ignoreFalseConditions, separator) + + ToString("isADXBiggerLast", isADXBiggerLast, ignoreFalseConditions, separator) + + ToString("isADXLesserLast", isADXLesserLast, ignoreFalseConditions, separator) + + ToString("isADXOverThreshold", isADXOverThreshold, ignoreFalseConditions, separator) + + ToString("isADXUnderThreshold", isADXUnderThreshold, ignoreFalseConditions, separator) + + ToString("isDXPBiggerThanDXN", isDXPBiggerThanDXN, ignoreFalseConditions, separator) + + ToString("isDXNBiggerThanDXP", isDXNBiggerThanDXP, ignoreFalseConditions, separator) + + ToString("isADXBullish", isADXBullish, ignoreFalseConditions, separator) + + ToString("isADXBearish", isADXBearish, ignoreFalseConditions, separator) + + ToString("isADXSwitchedToBullish", isADXSwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isADXSwitchedToBearish", isADXSwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isATROverLast", isATROverLast, ignoreFalseConditions, separator) + + ToString("isATRUnderLast", isATRUnderLast, ignoreFalseConditions, separator) + + ToString("isCCIBullish", isCCIBullish, ignoreFalseConditions, separator) + + ToString("isCCIBearish", isCCIBearish, ignoreFalseConditions, separator) + + ToString("isCCISwitchedToBullish", isCCISwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isCCISwitchedToBearish", isCCISwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isCCIOB", isCCIOB, ignoreFalseConditions, separator) + + ToString("isCCIOS", isCCIOS, ignoreFalseConditions, separator) + + ToString("isCCICrossedOverOB", isCCICrossedOverOB, ignoreFalseConditions, separator) + + ToString("isCCICrossedOverOS", isCCICrossedOverOS, ignoreFalseConditions, separator) + + ToString("isCCICrossedUnderOB", isCCICrossedUnderOB, ignoreFalseConditions, separator) + + ToString("isCCICrossedUnderOS", isCCICrossedUnderOS, ignoreFalseConditions, separator) + + ToString("isRSIBullish", isRSIBullish, ignoreFalseConditions, separator) + + ToString("isRSIBearish", isRSIBearish, ignoreFalseConditions, separator) + + ToString("isRSISwitchedToBullish", isRSISwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isRSISwitchedToBearish", isRSISwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isRSIOB", isRSIOB, ignoreFalseConditions, separator) + + ToString("isRSIOS", isRSIOS, ignoreFalseConditions, separator) + + ToString("isRSICrossedOverOB", isRSICrossedOverOB, ignoreFalseConditions, separator) + + ToString("isRSICrossedOverOS", isRSICrossedOverOS, ignoreFalseConditions, separator) + + ToString("isRSICrossedUnderOB", isRSICrossedUnderOB, ignoreFalseConditions, separator) + + ToString("isRSICrossedUnderOS", isRSICrossedUnderOS, ignoreFalseConditions, separator) + + ToString("isMFIBullish", isMFIBullish, ignoreFalseConditions, separator) + + ToString("isMFIBearish", isMFIBearish, ignoreFalseConditions, separator) + + ToString("isMFISwitchedToBullish", isMFISwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isMFISwitchedToBearish", isMFISwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isMFIOB", isMFIOB, ignoreFalseConditions, separator) + + ToString("isMFIOS", isMFIOS, ignoreFalseConditions, separator) + + ToString("isMFICrossedOverOB", isMFICrossedOverOB, ignoreFalseConditions, separator) + + ToString("isMFICrossedOverOS", isMFICrossedOverOS, ignoreFalseConditions, separator) + + ToString("isMFICrossedUnderOB", isMFICrossedUnderOB, ignoreFalseConditions, separator) + + ToString("isMFICrossedUnderOS", isMFICrossedUnderOS, ignoreFalseConditions, separator) + + ToString("isRVIBullish", isRVIBullish, ignoreFalseConditions, separator) + + ToString("isRVIBearish", isRVIBearish, ignoreFalseConditions, separator) + + ToString("isRVISwitchedToBullish", isRVISwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isRVISwitchedToBearish", isRVISwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isRVIOverSignal", isRVIOverSignal, ignoreFalseConditions, separator) + + ToString("isRVIUnderSignal", isRVIUnderSignal, ignoreFalseConditions, separator) + + ToString("isRVICrossedOverSignal", isRVICrossedOverSignal, ignoreFalseConditions, separator) + + ToString("isRVICrossedUnderSignal", isRVICrossedUnderSignal, ignoreFalseConditions, separator) + + ToString("isMACDBullish", isMACDBullish, ignoreFalseConditions, separator) + + ToString("isMACDBearish", isMACDBearish, ignoreFalseConditions, separator) + + ToString("isMACDSwitchedToBullish", isMACDSwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isMACDSwitchedToBearish", isMACDSwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isMACDOverSignal", isMACDOverSignal, ignoreFalseConditions, separator) + + ToString("isMACDUnderSignal", isMACDUnderSignal, ignoreFalseConditions, separator) + + ToString("isMACDCrossedOverSignal", isMACDCrossedOverSignal, ignoreFalseConditions, separator) + + ToString("isMACDCrossedUnderSignal", isMACDCrossedUnderSignal, ignoreFalseConditions, separator) + + ToString("isMomentumBullish", isMomentumBullish, ignoreFalseConditions, separator) + + ToString("isMomentumBearish", isMomentumBearish, ignoreFalseConditions, separator) + + ToString("isMomentumSwitchedToBullish", isMomentumSwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isMomentumSwitchedToBearish", isMomentumSwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isStochasticBullish", isStochasticBullish, ignoreFalseConditions, separator) + + ToString("isStochasticBearish", isStochasticBearish, ignoreFalseConditions, separator) + + ToString("isStochasticSwitchedToBullish", isStochasticSwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isStochasticSwitchedToBearish", isStochasticSwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isStochasticOverSignal", isStochasticOverSignal, ignoreFalseConditions, separator) + + ToString("isStochasticUnderSignal", isStochasticUnderSignal, ignoreFalseConditions, separator) + + ToString("isStochasticCrossedOverSignal", isStochasticCrossedOverSignal, ignoreFalseConditions, separator) + + ToString("isStochasticCrossedUnderSignal", isStochasticCrossedUnderSignal, ignoreFalseConditions, separator) + + ToString("isStochasticOB", isStochasticOB, ignoreFalseConditions, separator) + + ToString("isStochasticOS", isStochasticOS, ignoreFalseConditions, separator) + + ToString("isStochasticCrossedOverOB", isStochasticCrossedOverOB, ignoreFalseConditions, separator) + + ToString("isStochasticCrossedOverOS", isStochasticCrossedOverOS, ignoreFalseConditions, separator) + + ToString("isStochasticCrossedUnderOB", isStochasticCrossedUnderOB, ignoreFalseConditions, separator) + + ToString("isStochasticCrossedUnderOS", isStochasticCrossedUnderOS, ignoreFalseConditions, separator) + // "" // @@ -571,7 +1503,22 @@ class XCX121XOCSHelper : XCBaseHelper mInputs.Clean(); // - // Clean(x3maFastBuffer); + Clean(acBuffer); + Clean(adBuffer); + Clean(atrBuffer); + Clean(cciBuffer); + Clean(rsiBuffer); + Clean(mfiBuffer); + Clean(rviBuffer); + Clean(adxBuffer); + Clean(adxpBuffer); + Clean(adxnBuffer); + Clean(macdBuffer); + Clean(momentumBuffer); + Clean(rviSignalBuffer); + Clean(macdSignalBuffer); + Clean(stochasticBuffer); + Clean(stochasticSignalBuffer); } // @@ -597,37 +1544,91 @@ class XCX121XOCSHelper : XCBaseHelper } // - // ArraySetAsSeries(x3maFastBuffer, true); + ArraySetAsSeries(acBuffer, true); + ArraySetAsSeries(adBuffer, true); + ArraySetAsSeries(atrBuffer, true); + ArraySetAsSeries(cciBuffer, true); + ArraySetAsSeries(rsiBuffer, true); + ArraySetAsSeries(mfiBuffer, true); + ArraySetAsSeries(rviBuffer, true); + ArraySetAsSeries(adxBuffer, true); + ArraySetAsSeries(adxpBuffer, true); + ArraySetAsSeries(adxnBuffer, true); + ArraySetAsSeries(macdBuffer, true); + ArraySetAsSeries(momentumBuffer, true); + ArraySetAsSeries(rviSignalBuffer, true); + ArraySetAsSeries(macdSignalBuffer, true); + ArraySetAsSeries(stochasticBuffer, true); + ArraySetAsSeries(stochasticSignalBuffer, true); // mInputs = inputs; // - // mHandler = iCustom( - // mSymbol, - // mPeriod, - // "x-saherelm.x121.x3ma", - // // - // // Inputs ... - // // - // // Market ... - // "", - // mInputs.x3maFastMALength, - // mInputs.x3maMidMALength, - // mInputs.x3maSlowMALength, - // mInputs.x3maMaMethod, - // mInputs.x3maMaAppliedTo, - // // - // // Presentation ... - // "", - // // - // mInputs.startCalculationForLastBars, - // // - // mInputs.showX3MaFast, - // mInputs.showX3MaMid, - // mInputs.showX3MaSlow - // // - // ); + mHandler = iCustom( + mSymbol, + mPeriod, + "x-saherelm.x121.xoscs", + // + // Inputs ... + // + // AD ... + "", + mInputs.adAppliedTo, + // + // ADX ... + "", + mInputs.adxLength, + // + // ATR ... + "", + mInputs.atrLength, + // + // CCI ... + "", + mInputs.cciLength, + mInputs.cciAppliedTo, + // + // RSI ... + "", + mInputs.rsiLength, + mInputs.rsiAppliedTo, + // + // MFI ... + "", + mInputs.mfiLength, + mInputs.mfiAppliedTo, + // + // RVI ... + "", + mInputs.rviLength, + // + // MACD ... + "", + mInputs.macdFastLength, + mInputs.macdSlowLength, + mInputs.macdSignalLength, + mInputs.macdAppliedTo, + // + // MOMENTUM ... + "", + mInputs.momentumLength, + mInputs.momentumAppliedTo, + // + // STOCHASTIC ... + "", + mInputs.stochasticKLength, + mInputs.stochasticDLength, + mInputs.stochasticSmoothingLength, + mInputs.stochasticSmoothingMethod, + mInputs.stochasticAppliedTo, + // + // Presentation ... + "", + // + mInputs.startCalculationForLastBars + // + ); result = mHandler != INVALID_HANDLE; if (!result) { @@ -1689,6 +2690,420 @@ class XCX121XOCSHelper : XCBaseHelper // int cIDX = 1; int pIDX = cIDX + 1; + int ppIDX = pIDX + 1; + + // + // AC ... + + // + bool isACBullish = conditions.acBuffer[cIDX] > mInputs.acBullishLevel; + bool isACBullishPrev = conditions.acBuffer[pIDX] > mInputs.acBullishLevel; + bool isACSwitchedToBullish = isACBullish && + !isACBullishPrev; + + // + bool isACBearish = conditions.acBuffer[cIDX] < mInputs.acBearishLevel; + bool isACBearishPrev = conditions.acBuffer[pIDX] < mInputs.acBearishLevel; + bool isACSwitchedToBearish = isACBearish && + !isACBearishPrev; + + // + bool isACOverMax = conditions.acBuffer[cIDX] >= GetMax(conditions.acBuffer); + bool isACUnderMin = conditions.acBuffer[cIDX] <= GetMin(conditions.acBuffer); + + // + // AD ... + + // + bool isADBiggerLast = conditions.adBuffer[cIDX] > conditions.adBuffer[pIDX]; + bool isADLesserLast = conditions.adBuffer[cIDX] < conditions.adBuffer[pIDX]; + + // + bool isADOverMax = conditions.adBuffer[cIDX] >= GetMax(conditions.adBuffer); + bool isADUnderMin = conditions.adBuffer[cIDX] <= GetMin(conditions.adBuffer); + + // + // ADX ... + + // + bool isADXBiggerLast = conditions.adxBuffer[cIDX] > conditions.adxBuffer[pIDX]; + bool isADXBiggerLastPrev = conditions.adxBuffer[pIDX] > conditions.adxBuffer[ppIDX]; + + // + bool isADXLesserLast = conditions.adxBuffer[cIDX] < conditions.adxBuffer[pIDX]; + bool isADXLesserLastPrev = conditions.adxBuffer[pIDX] < conditions.adxBuffer[ppIDX]; + + // + bool isADXOverThreshold = conditions.adxBuffer[cIDX] > mInputs.adxThreshold; + bool isADXOverThresholdPrev = conditions.adxBuffer[pIDX] > mInputs.adxThreshold; + + // + bool isADXUnderThreshold = conditions.adxBuffer[cIDX] < mInputs.adxThreshold; + bool isADXUnderThresholdPrev = conditions.adxBuffer[pIDX] < mInputs.adxThreshold; + + // + bool isDXPBiggerThanDXN = conditions.adxpBuffer[cIDX] > conditions.adxnBuffer[cIDX]; + bool isDXPBiggerThanDXNPrev = conditions.adxpBuffer[pIDX] > conditions.adxnBuffer[pIDX]; + + // + bool isDXNBiggerThanDXP = conditions.adxnBuffer[cIDX] > conditions.adxpBuffer[cIDX]; + bool isDXNBiggerThanDXPPrev = conditions.adxnBuffer[pIDX] > conditions.adxpBuffer[pIDX]; + + // + bool isADXBullish = isADXBiggerLast && + isDXPBiggerThanDXN && + isADXOverThreshold; + bool isADXBullishPrev = isADXBiggerLastPrev && + isDXPBiggerThanDXNPrev && + isADXOverThresholdPrev; + bool isADXSwitchedToBullish = isADXBullish && + !isADXBullishPrev; + + // + bool isADXBearish = isADXLesserLast && + isDXNBiggerThanDXP && + isADXUnderThreshold; + bool isADXBearishPrev = isADXLesserLastPrev && + isDXNBiggerThanDXP && + isADXUnderThresholdPrev; + bool isADXSwitchedToBearish = isADXBearish && + !isADXBearishPrev; + + // + // ATR ... + + // + bool isATROverLast = conditions.atrBuffer[cIDX] > conditions.atrBuffer[pIDX]; + bool isATRUnderLast = conditions.atrBuffer[cIDX] < conditions.atrBuffer[pIDX]; + + // + // CCI ... + + // + bool isCCIBullish = conditions.cciBuffer[cIDX] > mInputs.cciReversalLevel; + bool isCCIBullishPrev = conditions.cciBuffer[pIDX] > mInputs.cciReversalLevel; + bool isCCISwitchedToBullish = isCCIBullish && + !isCCIBullishPrev; + + // + bool isCCIBearish = conditions.cciBuffer[cIDX] < mInputs.cciReversalLevel; + bool isCCIBearishPrev = conditions.cciBuffer[pIDX] < mInputs.cciReversalLevel; + bool isCCISwitchedToBearish = isCCIBearish && + !isCCIBearishPrev; + + // + bool isCCIOB = conditions.cciBuffer[cIDX] > mInputs.cciOBLevel; + bool isCCIOBPrev = conditions.cciBuffer[pIDX] > mInputs.cciOBLevel; + bool isCCICrossedOverOB = isCCIOB && + !isCCIOBPrev; + + // + bool isCCIUnderOB = conditions.cciBuffer[cIDX] < mInputs.cciOBLevel; + bool isCCIUnderOBPrev = conditions.cciBuffer[pIDX] < mInputs.cciOBLevel; + bool isCCICrossedUnderOB = isCCIUnderOB && + !isCCIUnderOBPrev; + + // + bool isCCIOS = conditions.cciBuffer[cIDX] < mInputs.cciOSLevel; + bool isCCIOSPrev = conditions.cciBuffer[pIDX] < mInputs.cciOSLevel; + bool isCCICrossedUnderOS = isCCIOS && + !isCCIOSPrev; + + // + bool isCCIOverOS = conditions.cciBuffer[cIDX] > mInputs.cciOSLevel; + bool isCCIOverOSPrev = conditions.cciBuffer[pIDX] > mInputs.cciOSLevel; + bool isCCICrossedOverOS = isCCIOverOS && + !isCCIOverOSPrev; + + // + // RSI ... + + // + bool isRSIBullish = conditions.rsiBuffer[cIDX] > mInputs.rsiReversalLevel; + bool isRSIBullishPrev = conditions.rsiBuffer[pIDX] > mInputs.rsiReversalLevel; + bool isRSISwitchedToBullish = isRSIBullish && + !isRSIBullishPrev; + + // + bool isRSIBearish = conditions.rsiBuffer[cIDX] < mInputs.rsiReversalLevel; + bool isRSIBearishPrev = conditions.rsiBuffer[pIDX] < mInputs.rsiReversalLevel; + bool isRSISwitchedToBearish = isRSIBearish && + !isRSIBearishPrev; + + // + bool isRSIOB = conditions.rsiBuffer[cIDX] > mInputs.rsiOBLevel; + bool isRSIOBPrev = conditions.rsiBuffer[pIDX] > mInputs.rsiOBLevel; + bool isRSICrossedOverOB = isRSIOB && + !isRSIOBPrev; + + // + bool isRSIUnderOB = conditions.rsiBuffer[cIDX] < mInputs.rsiOBLevel; + bool isRSIUnderOBPrev = conditions.rsiBuffer[pIDX] < mInputs.rsiOBLevel; + bool isRSICrossedUnderOB = isRSIUnderOB && + !isRSIUnderOBPrev; + + // + bool isRSIOS = conditions.rsiBuffer[cIDX] < mInputs.rsiOSLevel; + bool isRSIOSPrev = conditions.rsiBuffer[pIDX] < mInputs.rsiOSLevel; + bool isRSICrossedUnderOS = isRSIOS && + !isRSIOSPrev; + + // + bool isRSIOverOS = conditions.rsiBuffer[cIDX] > mInputs.rsiOSLevel; + bool isRSIOverOSPrev = conditions.rsiBuffer[pIDX] > mInputs.rsiOSLevel; + bool isRSICrossedOverOS = isRSIOverOS && + !isRSIOverOSPrev; + + // + // MFI ... + + // + bool isMFIBullish = conditions.mfiBuffer[cIDX] > mInputs.mfiReversalLevel; + bool isMFIBullishPrev = conditions.mfiBuffer[pIDX] > mInputs.mfiReversalLevel; + bool isMFISwitchedToBullish = isMFIBullish && + !isMFIBullishPrev; + + // + bool isMFIBearish = conditions.mfiBuffer[cIDX] < mInputs.mfiReversalLevel; + bool isMFIBearishPrev = conditions.mfiBuffer[pIDX] < mInputs.mfiReversalLevel; + bool isMFISwitchedToBearish = isMFIBearish && + !isMFIBearishPrev; + + // + bool isMFIOB = conditions.mfiBuffer[cIDX] > mInputs.mfiOBLevel; + bool isMFIOBPrev = conditions.mfiBuffer[pIDX] > mInputs.mfiOBLevel; + bool isMFICrossedOverOB = isMFIOB && + !isMFIOBPrev; + + // + bool isMFIUnderOB = conditions.mfiBuffer[cIDX] < mInputs.mfiOBLevel; + bool isMFIUnderOBPrev = conditions.mfiBuffer[pIDX] < mInputs.mfiOBLevel; + bool isMFICrossedUnderOB = isMFIUnderOB && + !isMFIUnderOBPrev; + + // + bool isMFIOS = conditions.mfiBuffer[cIDX] < mInputs.mfiOSLevel; + bool isMFIOSPrev = conditions.mfiBuffer[pIDX] < mInputs.mfiOSLevel; + bool isMFICrossedUnderOS = isMFIOS && + !isMFIOSPrev; + + // + bool isMFIOverOS = conditions.mfiBuffer[cIDX] > mInputs.mfiOSLevel; + bool isMFIOverOSPrev = conditions.mfiBuffer[pIDX] > mInputs.mfiOSLevel; + bool isMFICrossedOverOS = isMFIOverOS && + !isMFIOverOSPrev; + + // + // RVI ... + + // + bool isRVIBullish = conditions.rviBuffer[cIDX] > mInputs.rviBullishLevel; + bool isRVIBullishPrev = conditions.rviBuffer[pIDX] > mInputs.rviBullishLevel; + bool isRVISwitchedToBullish = isRVIBullish && + !isRVIBullishPrev; + + // + bool isRVIBearish = conditions.rviBuffer[cIDX] < mInputs.rviBearishLevel; + bool isRVIBearishPrev = conditions.rviBuffer[pIDX] < mInputs.rviBearishLevel; + bool isRVISwitchedToBearish = isRVIBearish && + !isRVIBearishPrev; + + // + bool isRVIOverSignal = conditions.rviBuffer[cIDX] > conditions.rviSignalBuffer[cIDX]; + bool isRVIOverSignalPrev = conditions.rviBuffer[pIDX] > conditions.rviSignalBuffer[pIDX]; + bool isRVICrossedOverSignal = isRVIOverSignal && + !isRVIOverSignalPrev; + + // + bool isRVIUnderSignal = conditions.rviBuffer[cIDX] < conditions.rviSignalBuffer[cIDX]; + bool isRVIUnderSignalPrev = conditions.rviBuffer[pIDX] < conditions.rviSignalBuffer[pIDX]; + bool isRVICrossedUnderSignal = isRVIUnderSignal && + !isRVIUnderSignalPrev; + + // + // MACD ... + + // + bool isMACDBullish = conditions.macdBuffer[cIDX] > mInputs.macdBullishLevel; + bool isMACDBullishPrev = conditions.macdBuffer[pIDX] > mInputs.macdBullishLevel; + bool isMACDSwitchedToBullish = isMACDBullish && + !isMACDBullishPrev; + + // + bool isMACDBearish = conditions.macdBuffer[cIDX] < mInputs.macdBearishLevel; + bool isMACDBearishPrev = conditions.macdBuffer[pIDX] < mInputs.macdBearishLevel; + bool isMACDSwitchedToBearish = isMACDBearish && + !isMACDBearishPrev; + + // + bool isMACDOverSignal = conditions.macdBuffer[cIDX] > conditions.macdSignalBuffer[cIDX]; + bool isMACDOverSignalPrev = conditions.macdBuffer[pIDX] > conditions.macdSignalBuffer[pIDX]; + bool isMACDCrossedOverSignal = isMACDOverSignal && + !isMACDOverSignalPrev; + + // + bool isMACDUnderSignal = conditions.macdBuffer[cIDX] < conditions.macdSignalBuffer[cIDX]; + bool isMACDUnderSignalPrev = conditions.macdBuffer[pIDX] < conditions.macdSignalBuffer[pIDX]; + bool isMACDCrossedUnderSignal = isMACDUnderSignal && + !isMACDUnderSignalPrev; + + // + // MOMENTUM ... + + // + bool isMomentumBullish = conditions.momentumBuffer[cIDX] > mInputs.momentumBullishLevel; + bool isMomentumBullishPrev = conditions.momentumBuffer[pIDX] > mInputs.momentumBullishLevel; + bool isMomentumSwitchedToBullish = isMomentumBullish && + !isMomentumBullishPrev; + + // + bool isMomentumBearish = conditions.momentumBuffer[cIDX] < mInputs.momentumBearishLevel; + bool isMomentumBearishPrev = conditions.momentumBuffer[pIDX] < mInputs.momentumBearishLevel; + bool isMomentumSwitchedToBearish = isMomentumBearish && + !isMomentumBearishPrev; + + // + // STOCHASTIC ... + + // + bool isStochasticBullish = conditions.stochasticBuffer[cIDX] > mInputs.stochasticReversalLevel; + bool isStochasticBullishPrev = conditions.stochasticBuffer[pIDX] > mInputs.stochasticReversalLevel; + bool isStochasticSwitchedToBullish = isStochasticBullish && + !isStochasticBullishPrev; + + // + bool isStochasticBearish = conditions.stochasticBuffer[cIDX] < mInputs.stochasticReversalLevel; + bool isStochasticBearishPrev = conditions.stochasticBuffer[pIDX] < mInputs.stochasticReversalLevel; + bool isStochasticSwitchedToBearish = isStochasticBearish && + !isStochasticBearishPrev; + + // + bool isStochasticOverSignal = conditions.stochasticBuffer[cIDX] > conditions.stochasticSignalBuffer[cIDX]; + bool isStochasticOverSignalPrev = conditions.stochasticBuffer[pIDX] > conditions.stochasticSignalBuffer[pIDX]; + bool isStochasticCrossedOverSignal = isStochasticOverSignal && + !isStochasticOverSignalPrev; + + // + bool isStochasticUnderSignal = conditions.stochasticBuffer[cIDX] < conditions.stochasticSignalBuffer[cIDX]; + bool isStochasticUnderSignalPrev = conditions.stochasticBuffer[pIDX] < conditions.stochasticSignalBuffer[pIDX]; + bool isStochasticCrossedUnderSignal = isStochasticUnderSignal && + !isStochasticUnderSignalPrev; + + // + bool isStochasticOB = conditions.stochasticBuffer[cIDX] > mInputs.stochasticOBLevel; + bool isStochasticOBPrev = conditions.stochasticBuffer[pIDX] > mInputs.stochasticOBLevel; + bool isStochasticCrossedOverOB = isStochasticOB && + !isStochasticOBPrev; + + // + bool isStochasticUnderOB = conditions.stochasticBuffer[cIDX] < mInputs.stochasticOBLevel; + bool isStochasticUnderOBPrev = conditions.stochasticBuffer[pIDX] < mInputs.stochasticOBLevel; + bool isStochasticCrossedUnderOB = isStochasticUnderOB && + !isStochasticUnderOBPrev; + + // + bool isStochasticOS = conditions.stochasticBuffer[cIDX] < mInputs.stochasticOSLevel; + bool isStochasticOSPrev = conditions.stochasticBuffer[pIDX] < mInputs.stochasticOSLevel; + bool isStochasticCrossedUnderOS = isStochasticOS && + !isStochasticOSPrev; + + // + bool isStochasticOverOS = conditions.stochasticBuffer[cIDX] > mInputs.stochasticOSLevel; + bool isStochasticOverOSPrev = conditions.stochasticBuffer[pIDX] > mInputs.stochasticOSLevel; + bool isStochasticCrossedOverOS = isStochasticOverOS && + !isStochasticOverOSPrev; + + // + // + // + + // + conditions.isCCIOB = isCCIOB; + conditions.isCCIOS = isCCIOS; + conditions.isRSIOB = isRSIOB; + conditions.isRSIOS = isRSIOS; + conditions.isMFIOB = isMFIOB; + conditions.isMFIOS = isMFIOS; + conditions.isACBullish = isACBullish; + conditions.isACBearish = isACBearish; + conditions.isACOverMax = isACOverMax; + conditions.isADOverMax = isADOverMax; + conditions.isACUnderMin = isACUnderMin; + conditions.isADUnderMin = isADUnderMin; + conditions.isADXBullish = isADXBullish; + conditions.isADXBearish = isADXBearish; + conditions.isCCIBullish = isCCIBullish; + conditions.isCCIBearish = isCCIBearish; + conditions.isRSIBullish = isRSIBullish; + conditions.isRSIBearish = isRSIBearish; + conditions.isMFIBullish = isMFIBullish; + conditions.isMFIBearish = isMFIBearish; + conditions.isRVIBullish = isRVIBullish; + conditions.isRVIBearish = isRVIBearish; + conditions.isATROverLast = isATROverLast; + conditions.isMACDBullish = isMACDBullish; + conditions.isMACDBearish = isMACDBearish; + conditions.isATRUnderLast = isATRUnderLast; + conditions.isADBiggerLast = isADBiggerLast; + conditions.isADLesserLast = isADLesserLast; + conditions.isStochasticOB = isStochasticOB; + conditions.isStochasticOS = isStochasticOS; + conditions.isADXBiggerLast = isADXBiggerLast; + conditions.isADXLesserLast = isADXLesserLast; + conditions.isRVIOverSignal = isRVIOverSignal; + conditions.isRVIUnderSignal = isRVIUnderSignal; + conditions.isMACDOverSignal = isMACDOverSignal; + conditions.isMACDUnderSignal = isMACDUnderSignal; + conditions.isMomentumBullish = isMomentumBullish; + conditions.isMomentumBearish = isMomentumBearish; + conditions.isADXOverThreshold = isADXOverThreshold; + conditions.isDXPBiggerThanDXN = isDXPBiggerThanDXN; + conditions.isDXNBiggerThanDXP = isDXNBiggerThanDXP; + conditions.isCCICrossedOverOB = isCCICrossedOverOB; + conditions.isCCICrossedOverOS = isCCICrossedOverOS; + conditions.isRSICrossedOverOB = isRSICrossedOverOB; + conditions.isRSICrossedOverOS = isRSICrossedOverOS; + conditions.isMFICrossedOverOB = isMFICrossedOverOB; + conditions.isMFICrossedOverOS = isMFICrossedOverOS; + conditions.isADXUnderThreshold = isADXUnderThreshold; + conditions.isCCICrossedUnderOB = isCCICrossedUnderOB; + conditions.isCCICrossedUnderOS = isCCICrossedUnderOS; + conditions.isRSICrossedUnderOB = isRSICrossedUnderOB; + conditions.isRSICrossedUnderOS = isRSICrossedUnderOS; + conditions.isMFICrossedUnderOB = isMFICrossedUnderOB; + conditions.isMFICrossedUnderOS = isMFICrossedUnderOS; + conditions.isStochasticBullish = isStochasticBullish; + conditions.isStochasticBearish = isStochasticBearish; + conditions.isACSwitchedToBullish = isACSwitchedToBullish; + conditions.isACSwitchedToBearish = isACSwitchedToBearish; + conditions.isADXSwitchedToBullish = isADXSwitchedToBullish; + conditions.isADXSwitchedToBearish = isADXSwitchedToBearish; + conditions.isCCISwitchedToBullish = isCCISwitchedToBullish; + conditions.isCCISwitchedToBearish = isCCISwitchedToBearish; + conditions.isRSISwitchedToBullish = isRSISwitchedToBullish; + conditions.isRSISwitchedToBearish = isRSISwitchedToBearish; + conditions.isMFISwitchedToBullish = isMFISwitchedToBullish; + conditions.isMFISwitchedToBearish = isMFISwitchedToBearish; + conditions.isRVISwitchedToBullish = isRVISwitchedToBullish; + conditions.isRVISwitchedToBearish = isRVISwitchedToBearish; + conditions.isRVICrossedOverSignal = isRVICrossedOverSignal; + conditions.isStochasticOverSignal = isStochasticOverSignal; + conditions.isStochasticUnderSignal = isStochasticUnderSignal; + conditions.isRVICrossedUnderSignal = isRVICrossedUnderSignal; + conditions.isMACDSwitchedToBullish = isMACDSwitchedToBullish; + conditions.isMACDSwitchedToBearish = isMACDSwitchedToBearish; + conditions.isMACDCrossedOverSignal = isMACDCrossedOverSignal; + conditions.isMACDCrossedUnderSignal = isMACDCrossedUnderSignal; + conditions.isStochasticCrossedOverOB = isStochasticCrossedOverOB; + conditions.isStochasticCrossedOverOS = isStochasticCrossedOverOS; + conditions.isStochasticCrossedUnderOB = isStochasticCrossedUnderOB; + conditions.isStochasticCrossedUnderOS = isStochasticCrossedUnderOS; + conditions.isMomentumSwitchedToBullish = isMomentumSwitchedToBullish; + conditions.isMomentumSwitchedToBearish = isMomentumSwitchedToBearish; + conditions.isStochasticSwitchedToBullish = isStochasticSwitchedToBullish; + conditions.isStochasticSwitchedToBearish = isStochasticSwitchedToBearish; + conditions.isStochasticCrossedOverSignal = isStochasticCrossedOverSignal; + conditions.isStochasticCrossedUnderSignal = isStochasticCrossedUnderSignal; // Cleanup(); diff --git a/Helpers/x-saherelm.x121.xstr.helper.mq5 b/Helpers/x-saherelm.x121.xstr.helper.mq5 index 6a0550da..4cf9d994 100644 --- a/Helpers/x-saherelm.x121.xstr.helper.mq5 +++ b/Helpers/x-saherelm.x121.xstr.helper.mq5 @@ -38,12 +38,10 @@ enum ENUM_X121_XSTR_BUFFERS X121_XSTR_DOWN_LINE = 3, X121_XSTR_HSM_LINE = 4, X121_XSTR_LSM_LINE = 5, - X121_XSTR_MID_LINE = 6, - X121_XSTR_MID_STATE_LINE = 7, - X121_XSTR_XVIDYA_LINE = 8, - X121_XSTR_ATR_LINE = 9, - X121_XSTR_PRICE_LINE = 10, - X121_XSTR_STATE_LINE = 11, + X121_XSTR_XVIDYA_LINE = 6, + X121_XSTR_ATR_LINE = 7, + X121_XSTR_PRICE_LINE = 8, + X121_XSTR_STATE_LINE = 9, }; // @@ -63,7 +61,6 @@ struct X121XSTRInputs // bool showStr; // Show Str bool showVidya; // Show Vidya - bool showStrMid; // Show Str Mid bool showStrUpper; // Show Str Upper bool showStrLower; // Show Str Lower bool showStrSMLow; // Show Str SM Low @@ -95,7 +92,6 @@ struct X121XSTRInputs // showStr = false; showVidya = false; - showStrMid = false; showStrUpper = false; showStrLower = false; showStrSMLow = false; @@ -120,7 +116,6 @@ struct X121XSTRInputs // showStr = true; showVidya = true; - showStrMid = true; showStrUpper = true; showStrLower = true; showStrSMLow = true; @@ -177,17 +172,18 @@ struct X121XSTRConditions double atrBuffer[]; double vidyaBuffer[]; double strUpBuffer[]; - double strMidBuffer[]; double strDownBuffer[]; double strPriceBuffer[]; double strStateBuffer[]; double strSMLowBuffer[]; double strSMHighBuffer[]; - double strMidStateBuffer[]; // // Conditions ... + // + // STR ... + // bool isStrBullish; bool isStrBearish; @@ -196,6 +192,91 @@ struct X121XSTRConditions bool isStrSwitchedToBullish; bool isStrSwitchedToBearish; + // + // VIDYA ... + + // + bool isRejectUpVidya; + bool isClosedOverVidya; + bool isCrossedOverVidya; + + // + bool isRejectDownVidya; + bool isCloseUnderVidya; + bool isCrossedUnderVidya; + + // + // HMS ... + + // + bool isRejectUpLSM; + bool isCloseOverLSM; + bool isCrossedOverLSM; + + // + bool isRejectDownLSM; + bool isCloseUnderLSM; + bool isCrossedUnderLSM; + + // + // HSM .. + + // + bool isRejectUpHSM; + bool isCloseOverHSM; + bool isCrossedOverHSM; + + // + bool isRejectDownHSM; + bool isCloseUnderHSM; + bool isCrossedUnderHSM; + + // + // STR ... + + // + bool isRejectUpStr; + bool isCloseOverStr; + bool isCrossedOverStr; + + // + bool isRejectDownStr; + bool isCloseUnderStr; + bool isCrossedUnderStr; + + // + // HSM / ViDYA ... + + // + bool isVidyaOverHSM; + bool isVidyaCrossedOverHSM; + + // + bool isVidyaUnderHSM; + bool isVidyaCrossedUnderHSM; + + // + // LSM / VIDYA ... + + // + bool isVidyaOverLSM; + bool isVidyaCrossedOverLSM; + + // + bool isVidyaUnderLSM; + bool isVidyaCrossedUnderLSM; + + // + // STR / VIDYA ... + + // + bool isVidyaOverStr; + bool isVidyaCrossedOverStr; + + // + bool isVidyaUnderStr; + bool isVidyaCrossedUnderStr; + // // bool isCloseLower @@ -228,35 +309,64 @@ struct X121XSTRConditions Clean(atrBuffer); Clean(vidyaBuffer); Clean(strUpBuffer); - Clean(strMidBuffer); Clean(strDownBuffer); Clean(strPriceBuffer); Clean(strStateBuffer); Clean(strSMLowBuffer); Clean(strSMHighBuffer); - Clean(strMidStateBuffer); // ArraySetAsSeries(strBuffer, true); ArraySetAsSeries(atrBuffer, true); ArraySetAsSeries(vidyaBuffer, true); ArraySetAsSeries(strUpBuffer, true); - ArraySetAsSeries(strMidBuffer, true); ArraySetAsSeries(strDownBuffer, true); ArraySetAsSeries(strPriceBuffer, true); ArraySetAsSeries(strStateBuffer, true); ArraySetAsSeries(strSMLowBuffer, true); ArraySetAsSeries(strSMHighBuffer, true); - ArraySetAsSeries(strMidStateBuffer, true); // // Conditions ... - // isStrBullish = false; isStrBearish = false; - - // + isRejectUpLSM = false; + isRejectUpHSM = false; + isRejectUpStr = false; + isCloseOverHSM = false; + isCloseOverLSM = false; + isCloseOverStr = false; + isVidyaOverHSM = false; + isVidyaOverLSM = false; + isVidyaOverStr = false; + isRejectDownLSM = false; + isRejectDownHSM = false; + isVidyaUnderStr = false; + isVidyaUnderHSM = false; + isVidyaUnderLSM = false; + isCloseUnderStr = false; + isRejectDownStr = false; + isRejectUpVidya = false; + isCloseUnderHSM = false; + isCloseUnderLSM = false; + isCrossedOverLSM = false; + isCrossedOverHSM = false; + isCrossedOverStr = false; + isCrossedUnderHSM = false; + isCrossedUnderLSM = false; + isCrossedUnderStr = false; + isClosedOverVidya = false; + isRejectDownVidya = false; + isCloseUnderVidya = false; + isCrossedOverVidya = false; + isCrossedUnderVidya = false; + isVidyaCrossedOverHSM = false; + isVidyaCrossedOverStr = false; + isVidyaCrossedOverLSM = false; + isVidyaCrossedUnderHSM = false; + isVidyaCrossedUnderLSM = false; + isVidyaCrossedUnderStr = false; isStrSwitchedToBullish = false; isStrSwitchedToBearish = false; @@ -293,6 +403,78 @@ struct X121XSTRConditions { bullishScore += score; } + if (isRejectUpVidya) + { + bullishScore += minScore; + } + if (isClosedOverVidya) + { + bullishScore += minScore; + } + if (isCrossedOverVidya) + { + bullishScore += minScore; + } + if (isRejectUpLSM) + { + bullishScore += minScore; + } + if (isCloseOverLSM) + { + bullishScore += minScore; + } + if (isCrossedOverLSM) + { + bullishScore += minScore; + } + if (isRejectUpHSM) + { + bullishScore += minScore; + } + if (isCloseOverHSM) + { + bullishScore += minScore; + } + if (isCrossedOverHSM) + { + bullishScore += minScore; + } + if (isRejectUpStr) + { + bullishScore += minScore; + } + if (isCloseOverStr) + { + bullishScore += minScore; + } + if (isCrossedOverStr) + { + bullishScore += minScore; + } + if (isVidyaOverHSM) + { + bullishScore += minScore; + } + if (isVidyaCrossedOverHSM) + { + bullishScore += minScore; + } + if (isVidyaOverLSM) + { + bullishScore += minScore; + } + if (isVidyaCrossedOverLSM) + { + bullishScore += minScore; + } + if (isVidyaOverStr) + { + bullishScore += minScore; + } + if (isVidyaCrossedOverStr) + { + bullishScore += minScore; + } // if (isStrBearish) @@ -303,6 +485,78 @@ struct X121XSTRConditions { bearishScore += score; } + if (isRejectDownVidya) + { + bearishScore += minScore; + } + if (isCloseUnderVidya) + { + bearishScore += minScore; + } + if (isCrossedUnderVidya) + { + bearishScore += minScore; + } + if (isRejectDownLSM) + { + bearishScore += minScore; + } + if (isCloseUnderLSM) + { + bearishScore += minScore; + } + if (isCrossedUnderLSM) + { + bearishScore += minScore; + } + if (isRejectDownHSM) + { + bearishScore += minScore; + } + if (isCloseUnderHSM) + { + bearishScore += minScore; + } + if (isCrossedUnderHSM) + { + bearishScore += minScore; + } + if (isRejectDownStr) + { + bearishScore += minScore; + } + if (isCloseUnderStr) + { + bearishScore += minScore; + } + if (isCrossedUnderStr) + { + bearishScore += minScore; + } + if (isVidyaUnderHSM) + { + bearishScore += minScore; + } + if (isVidyaCrossedUnderHSM) + { + bearishScore += minScore; + } + if (isVidyaUnderLSM) + { + bearishScore += minScore; + } + if (isVidyaCrossedUnderLSM) + { + bearishScore += minScore; + } + if (isVidyaUnderStr) + { + bearishScore += minScore; + } + if (isVidyaCrossedUnderStr) + { + bearishScore += minScore; + } } /** @@ -363,6 +617,42 @@ struct X121XSTRConditions ToString("isStrBearish", isStrBearish, ignoreFalseConditions, separator) + ToString("isStrSwitchedToBullish", isStrSwitchedToBullish, ignoreFalseConditions, separator) + ToString("isStrSwitchedToBearish", isStrSwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isRejectUpVidya", isRejectUpVidya, ignoreFalseConditions, separator) + + ToString("isClosedOverVidya", isClosedOverVidya, ignoreFalseConditions, separator) + + ToString("isCrossedOverVidya", isCrossedOverVidya, ignoreFalseConditions, separator) + + ToString("isRejectDownVidya", isRejectDownVidya, ignoreFalseConditions, separator) + + ToString("isCloseUnderVidya", isCloseUnderVidya, ignoreFalseConditions, separator) + + ToString("isCrossedUnderVidya", isCrossedUnderVidya, ignoreFalseConditions, separator) + + ToString("isRejectUpLSM", isRejectUpLSM, ignoreFalseConditions, separator) + + ToString("isCloseOverLSM", isCloseOverLSM, ignoreFalseConditions, separator) + + ToString("isCrossedOverLSM", isCrossedOverLSM, ignoreFalseConditions, separator) + + ToString("isRejectDownLSM", isRejectDownLSM, ignoreFalseConditions, separator) + + ToString("isCloseUnderLSM", isCloseUnderLSM, ignoreFalseConditions, separator) + + ToString("isCrossedUnderLSM", isCrossedUnderLSM, ignoreFalseConditions, separator) + + ToString("isRejectUpHSM", isRejectUpHSM, ignoreFalseConditions, separator) + + ToString("isCloseOverHSM", isCloseOverHSM, ignoreFalseConditions, separator) + + ToString("isCrossedOverHSM", isCrossedOverHSM, ignoreFalseConditions, separator) + + ToString("isRejectDownHSM", isRejectDownHSM, ignoreFalseConditions, separator) + + ToString("isCloseUnderHSM", isCloseUnderHSM, ignoreFalseConditions, separator) + + ToString("isCrossedUnderHSM", isCrossedUnderHSM, ignoreFalseConditions, separator) + + ToString("isRejectUpStr", isRejectUpStr, ignoreFalseConditions, separator) + + ToString("isCloseOverStr", isCloseOverStr, ignoreFalseConditions, separator) + + ToString("isCrossedOverStr", isCrossedOverStr, ignoreFalseConditions, separator) + + ToString("isRejectDownStr", isRejectDownStr, ignoreFalseConditions, separator) + + ToString("isCloseUnderStr", isCloseUnderStr, ignoreFalseConditions, separator) + + ToString("isCrossedUnderStr", isCrossedUnderStr, ignoreFalseConditions, separator) + + ToString("isVidyaOverHSM", isVidyaOverHSM, ignoreFalseConditions, separator) + + ToString("isVidyaCrossedOverHSM", isVidyaCrossedOverHSM, ignoreFalseConditions, separator) + + ToString("isVidyaUnderHSM", isVidyaUnderHSM, ignoreFalseConditions, separator) + + ToString("isVidyaCrossedUnderHSM", isVidyaCrossedUnderHSM, ignoreFalseConditions, separator) + + ToString("isVidyaOverLSM", isVidyaOverLSM, ignoreFalseConditions, separator) + + ToString("isVidyaCrossedOverLSM", isVidyaCrossedOverLSM, ignoreFalseConditions, separator) + + ToString("isVidyaUnderLSM", isVidyaUnderLSM, ignoreFalseConditions, separator) + + ToString("isVidyaCrossedUnderLSM", isVidyaCrossedUnderLSM, ignoreFalseConditions, separator) + + ToString("isVidyaOverStr", isVidyaOverStr, ignoreFalseConditions, separator) + + ToString("isVidyaCrossedOverStr", isVidyaCrossedOverStr, ignoreFalseConditions, separator) + + ToString("isVidyaUnderStr", isVidyaUnderStr, ignoreFalseConditions, separator) + + ToString("isVidyaCrossedUnderStr", isVidyaCrossedUnderStr, ignoreFalseConditions, separator) + // "" // @@ -463,13 +753,11 @@ class XCX121XSTRHelper : public XCBaseHelper ArraySetAsSeries(atrBuffer, true); ArraySetAsSeries(vidyaBuffer, true); ArraySetAsSeries(strUpBuffer, true); - ArraySetAsSeries(strMidBuffer, true); ArraySetAsSeries(strDownBuffer, true); ArraySetAsSeries(strPriceBuffer, true); ArraySetAsSeries(strStateBuffer, true); ArraySetAsSeries(strSMLowBuffer, true); ArraySetAsSeries(strSMHighBuffer, true); - ArraySetAsSeries(strMidStateBuffer, true); // mInputs = inputs; @@ -495,7 +783,6 @@ class XCX121XSTRHelper : public XCBaseHelper "", mInputs.showStr, mInputs.showVidya, - mInputs.showStrMid, mInputs.showStrUpper, mInputs.showStrLower, mInputs.showStrSMLow, @@ -740,104 +1027,6 @@ class XCX121XSTRHelper : public XCBaseHelper ); } - // - double GetSTRMid( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(barIndex); - - // - int count = ArraySize(strMidBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return strMidBuffer[barIndex]; - } - - // - int CopySTRMid( - int start, // Start - int count, // Number of Items for read - double &buffer[], // Dest Buffer - bool forceClean = true // Force To Clean buffer - ) - { - // - // Update Calculations ... - Calculate(start); - - // - // Copy Items ... - return Copy( - 0, - count, - strMidBuffer, - buffer, - forceClean - // - ); - } - - // - double GetSTRMidState( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(barIndex); - - // - int count = ArraySize(strMidStateBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return strMidStateBuffer[barIndex]; - } - - // - int CopySTRMidState( - int start, // Start - int count, // Number of Items for read - double &buffer[], // Dest Buffer - bool forceClean = true // Force To Clean buffer - ) - { - // - // Update Calculations ... - Calculate(start); - - // - // Copy Items ... - return Copy( - 0, - count, - strMidStateBuffer, - buffer, - forceClean - // - ); - } - // double GetSTRPrice( int barIndex // Bar Index @@ -1239,20 +1428,6 @@ class XCX121XSTRHelper : public XCBaseHelper conditions.strStateBuffer // ); - // - CopySTRMid( - zIndex, - loopback, - conditions.strMidBuffer // - ); - - // - CopySTRMidState( - zIndex, - loopback, - conditions.strMidStateBuffer // - ); - // CopySTRPrice( zIndex, @@ -1295,6 +1470,9 @@ class XCX121XSTRHelper : public XCBaseHelper int cIDX = 1; int pIDX = cIDX + 1; + // + // STR ... + // bool isStrBullish = strStateBuffer[cIDX] > 0; bool isStrBullishPrev = strStateBuffer[pIDX] > 0; @@ -1309,9 +1487,202 @@ class XCX121XSTRHelper : public XCBaseHelper bool isStrSwitchedToBearish = isStrBearish && !isStrBearishPrev; + // + // VIDYA ... + + // + bool isRejectUpVidya = cBar.IsRejected( + vidyaBuffer[cIDX], + X_DIRECTION_BULLISH // + ); + + // + bool isClosedOverVidya = cBar.close > vidyaBuffer[cIDX]; + bool isClosedOverVidyaPrev = pBar.close > vidyaBuffer[pIDX]; + bool isCrossedOverVidya = isClosedOverVidya && + !isClosedOverVidyaPrev; + + // + bool isRejectDownVidya = cBar.IsRejected( + vidyaBuffer[cIDX], + X_DIRECTION_BEARISH // + ); + + // + bool isCloseUnderVidya = cBar.close < vidyaBuffer[cIDX]; + bool isCloseUnderVidyaPrev = pBar.close < vidyaBuffer[pIDX]; + bool isCrossedUnderVidya = isCloseUnderVidya && + !isCloseUnderVidyaPrev; + + // + // LMS ... + + // + bool isRejectUpLSM = cBar.IsRejected( + strSMLowBuffer[cIDX], + X_DIRECTION_BULLISH // + ); + + // + bool isCloseOverLSM = cBar.close > strSMLowBuffer[cIDX]; + bool isCloseOverLSMPrev = pBar.close > strSMLowBuffer[pIDX]; + bool isCrossedOverLSM = isCloseOverLSM && + !isCloseOverLSMPrev; + + // + bool isRejectDownLSM = cBar.IsRejected( + strSMLowBuffer[cIDX], + X_DIRECTION_BEARISH // + ); + + // + bool isCloseUnderLSM = cBar.close < strSMLowBuffer[cIDX]; + bool isCloseUnderLSMPrev = pBar.close < strSMLowBuffer[pIDX]; + bool isCrossedUnderLSM = isCloseUnderLSM && + !isCloseUnderLSMPrev; + + // + // HSM .. + + // + bool isRejectUpHSM = cBar.IsRejected( + strSMHighBuffer[cIDX], + X_DIRECTION_BULLISH // + ); + + // + bool isCloseOverHSM = cBar.close > strSMHighBuffer[cIDX]; + bool isCloseOverHSMPrev = pBar.close > strSMHighBuffer[pIDX]; + bool isCrossedOverHSM = isCloseOverHSM && + !isCloseOverHSMPrev; + + // + bool isRejectDownHSM = cBar.IsRejected( + strSMHighBuffer[cIDX], + X_DIRECTION_BEARISH // + ); + + // + bool isCloseUnderHSM = cBar.close > strSMHighBuffer[cIDX]; + bool isCloseUnderHSMPrev = pBar.close > strSMHighBuffer[pIDX]; + bool isCrossedUnderHSM = isCloseUnderHSM && + !isCloseUnderHSMPrev; + + // + // STR ... + + // + bool isRejectUpStr = cBar.IsRejected( + strBuffer[cIDX], + X_DIRECTION_BULLISH // + ); + + // + bool isCloseOverStr = cBar.close > strBuffer[cIDX]; + bool isCloseOverStrPrev = pBar.close > strBuffer[pIDX]; + bool isCrossedOverStr = isCloseOverStr && + !isCloseOverStrPrev; + + // + bool isRejectDownStr = cBar.IsRejected( + strBuffer[cIDX], + X_DIRECTION_BEARISH // + ); + + // + bool isCloseUnderStr = cBar.close < strBuffer[cIDX]; + bool isCloseUnderStrPrev = pBar.close < strBuffer[pIDX]; + bool isCrossedUnderStr = isCloseUnderStr && + !isCloseUnderStrPrev; + + // + // HSM / ViDYA ... + + // + bool isVidyaOverHSM = vidyaBuffer[cIDX] > strSMHighBuffer[cIDX]; + bool isVidyaOverHSMPrev = vidyaBuffer[pIDX] > strSMHighBuffer[pIDX]; + bool isVidyaCrossedOverHSM = isVidyaOverHSM && + !isVidyaOverHSMPrev; + + // + bool isVidyaUnderHSM = vidyaBuffer[cIDX] < strSMHighBuffer[cIDX]; + bool isVidyaUnderHSMPrev = vidyaBuffer[pIDX] < strSMHighBuffer[pIDX]; + bool isVidyaCrossedUnderHSM = isVidyaUnderHSM && + !isVidyaUnderHSMPrev; + + // + // LSM / VIDYA ... + + // + bool isVidyaOverLSM = vidyaBuffer[cIDX] > strSMLowBuffer[cIDX]; + bool isVidyaOverLSMPrev = vidyaBuffer[pIDX] > strSMLowBuffer[pIDX]; + bool isVidyaCrossedOverLSM = isVidyaOverLSM && + !isVidyaOverLSMPrev; + + // + bool isVidyaUnderLSM = vidyaBuffer[cIDX] < strSMLowBuffer[cIDX]; + bool isVidyaUnderLSMPrev = vidyaBuffer[pIDX] < strSMLowBuffer[pIDX]; + bool isVidyaCrossedUnderLSM = isVidyaUnderLSM && + !isVidyaUnderLSMPrev; + + // + // STR / VIDYA ... + + // + bool isVidyaOverStr = vidyaBuffer[cIDX] > strBuffer[cIDX]; + bool isVidyaOverStrPrev = vidyaBuffer[pIDX] > strBuffer[pIDX]; + bool isVidyaCrossedOverStr = isVidyaOverStr && + !isVidyaOverStrPrev; + + // + bool isVidyaUnderStr = vidyaBuffer[cIDX] < strBuffer[cIDX]; + bool isVidyaUnderStrPrev = vidyaBuffer[pIDX] < strBuffer[pIDX]; + bool isVidyaCrossedUnderStr = isVidyaUnderStr && + !isVidyaUnderStrPrev; + + // + // + // + // conditions.isStrBullish = isStrBullish; conditions.isStrBearish = isStrBearish; + conditions.isRejectUpLSM = isRejectUpLSM; + conditions.isRejectUpHSM = isRejectUpHSM; + conditions.isRejectUpStr = isRejectUpStr; + conditions.isCloseOverHSM = isCloseOverHSM; + conditions.isCloseOverLSM = isCloseOverLSM; + conditions.isCloseOverStr = isCloseOverStr; + conditions.isVidyaOverHSM = isVidyaOverHSM; + conditions.isVidyaOverLSM = isVidyaOverLSM; + conditions.isVidyaOverStr = isVidyaOverStr; + conditions.isRejectDownLSM = isRejectDownLSM; + conditions.isRejectDownHSM = isRejectDownHSM; + conditions.isVidyaUnderStr = isVidyaUnderStr; + conditions.isVidyaUnderHSM = isVidyaUnderHSM; + conditions.isVidyaUnderLSM = isVidyaUnderLSM; + conditions.isCloseUnderStr = isCloseUnderStr; + conditions.isRejectDownStr = isRejectDownStr; + conditions.isRejectUpVidya = isRejectUpVidya; + conditions.isCloseUnderHSM = isCloseUnderHSM; + conditions.isCloseUnderLSM = isCloseUnderLSM; + conditions.isCrossedOverLSM = isCrossedOverLSM; + conditions.isCrossedOverHSM = isCrossedOverHSM; + conditions.isCrossedOverStr = isCrossedOverStr; + conditions.isCrossedUnderHSM = isCrossedUnderHSM; + conditions.isCrossedUnderLSM = isCrossedUnderLSM; + conditions.isCrossedUnderStr = isCrossedUnderStr; + conditions.isClosedOverVidya = isClosedOverVidya; + conditions.isRejectDownVidya = isRejectDownVidya; + conditions.isCloseUnderVidya = isCloseUnderVidya; + conditions.isCrossedOverVidya = isCrossedOverVidya; + conditions.isCrossedUnderVidya = isCrossedUnderVidya; + conditions.isVidyaCrossedOverHSM = isVidyaCrossedOverHSM; + conditions.isVidyaCrossedOverStr = isVidyaCrossedOverStr; + conditions.isVidyaCrossedOverLSM = isVidyaCrossedOverLSM; + conditions.isVidyaCrossedUnderHSM = isVidyaCrossedUnderHSM; + conditions.isVidyaCrossedUnderLSM = isVidyaCrossedUnderLSM; + conditions.isVidyaCrossedUnderStr = isVidyaCrossedUnderStr; conditions.isStrSwitchedToBullish = isStrSwitchedToBullish; conditions.isStrSwitchedToBearish = isStrSwitchedToBearish; @@ -1343,13 +1714,11 @@ class XCX121XSTRHelper : public XCBaseHelper double atrBuffer[]; double vidyaBuffer[]; double strUpBuffer[]; - double strMidBuffer[]; double strDownBuffer[]; double strPriceBuffer[]; double strStateBuffer[]; double strSMLowBuffer[]; double strSMHighBuffer[]; - double strMidStateBuffer[]; // void Calculate( @@ -1397,26 +1766,6 @@ class XCX121XSTRHelper : public XCBaseHelper // ); - // - CopyBuffer( - mHandler, - X121_XSTR_MID_LINE, - barIndex, - maxRequiredBars, - strMidBuffer - // - ); - - // - CopyBuffer( - mHandler, - X121_XSTR_MID_STATE_LINE, - barIndex, - maxRequiredBars, - strMidStateBuffer - // - ); - // // Price ... CopyBuffer( @@ -1513,12 +1862,6 @@ class XCX121XSTRHelper : public XCBaseHelper maxAllowed // ); - // - CleanupArray( - strMidBuffer, - maxAllowed // - ); - // CleanupArray( strDownBuffer, @@ -1548,12 +1891,6 @@ class XCX121XSTRHelper : public XCBaseHelper strSMHighBuffer, maxAllowed // ); - - // - CleanupArray( - strMidStateBuffer, - maxAllowed // - ); } // diff --git a/Indicators/x-saherelm.x121.xstr.mq5 b/Indicators/x-saherelm.x121.xstr.mq5 index ecdcd1e7..3a95d4d4 100644 --- a/Indicators/x-saherelm.x121.xstr.mq5 +++ b/Indicators/x-saherelm.x121.xstr.mq5 @@ -46,7 +46,6 @@ input ENUM_APPLIED_PRICE vidyaAppliedTo = PRICE_CLOSE; // Smoothing Applied To input group "Presentation"; input bool showStr = true; // Show Str input bool showVidya = true; // Show Vidya -input bool showStrMid = true; // Show Str Mid input bool showStrUpper = true; // Show Str Upper input bool showStrLower = true; // Show Str Lower input bool showStrLowMa = true; // Show Low Smoothed Buffer @@ -68,8 +67,8 @@ input bool showStrHighMa = true; // Show High Smoothed Buffer #property indicator_chart_window // -#property indicator_buffers 12 -#property indicator_plots 7 +#property indicator_buffers 10 +#property indicator_plots 6 // // STR ... @@ -139,40 +138,24 @@ double strLowMaBuffer[]; #property indicator_style5 STYLE_SOLID #property indicator_width5 1 -// -// STR Mmid ... -#define strMidBufferIndex 6 -double strMidBuffer[]; - -#define strMidColorBufferIndex 7 -double strMidColorBuffer[]; - -// -#define strMidPlotBufferIndex 5 -#property indicator_label6 "X121 STR Mid" -#property indicator_type6 DRAW_COLOR_LINE -#property indicator_color6 CLR_NONE, clrLime, clrRed, clrGray -#property indicator_style6 STYLE_SOLID -#property indicator_width6 1 - // // VIDYA ... -#define vidyaBufferIndex 8 +#define vidyaBufferIndex 6 double vidyaBuffer[]; // -#define vidyaPlotBufferIndex 6 -#property indicator_label7 "X121 VIDYA" -#property indicator_type7 DRAW_LINE -#property indicator_color7 clrYellow -#property indicator_style7 STYLE_SOLID -#property indicator_width7 1 +#define vidyaPlotBufferIndex 5 +#property indicator_label6 "X121 VIDYA" +#property indicator_type6 DRAW_LINE +#property indicator_color6 clrYellow +#property indicator_style6 STYLE_SOLID +#property indicator_width6 1 // // Data Buffers ... // -int mLastBufferIndex = 8; +int mLastBufferIndex = 6; // // STR ... @@ -577,14 +560,6 @@ void DefineBuffers() PlotIndexSetInteger(vidyaPlotBufferIndex, PLOT_SHOW_DATA, showVidya); PlotIndexSetInteger(vidyaPlotBufferIndex, PLOT_DRAW_TYPE, vidyaDrawType); - // - ENUM_DRAW_TYPE strMidDrawType = showStrMid ? DRAW_COLOR_LINE : DRAW_NONE; - SetIndexBuffer(strMidBufferIndex, strMidBuffer, INDICATOR_DATA); - SetIndexBuffer(strMidColorBufferIndex, strMidColorBuffer, INDICATOR_COLOR_INDEX); - PlotIndexSetDouble(strMidPlotBufferIndex, PLOT_EMPTY_VALUE, emptyValue); - PlotIndexSetInteger(strMidPlotBufferIndex, PLOT_SHOW_DATA, showStrMid); - PlotIndexSetInteger(strMidPlotBufferIndex, PLOT_DRAW_TYPE, strMidDrawType); - // // Data Buffers ... @@ -650,8 +625,6 @@ void FillBuffersZero(int barIndex) // STR ... strBuffer[barIndex] = emptyValue; strUpBuffer[barIndex] = emptyValue; - strMidBuffer[barIndex] = emptyValue; - strMidBuffer[barIndex] = emptyValue; strDownBuffer[barIndex] = emptyValue; strPriceBuffer[barIndex] = emptyValue; strLowMaBuffer[barIndex] = emptyValue; @@ -832,15 +805,6 @@ void CalculateStr( // double iStrMid = strDownBuffer[bar_index] + ((strUpBuffer[bar_index] - strDownBuffer[bar_index]) / 2); - strMidBuffer[bar_index] = iStrMid; - - // - double iStrColor = close[bar_index] > strMidBuffer[bar_index] - ? bullishColorIDX - : close[bar_index] < strMidBuffer[bar_index] - ? bearishColorIDX - : neuturalColorIDX; - strMidColorBuffer[bar_index] = iStrColor; // } diff --git a/XSTRCCI/Helpers/xstrcci.helper.mq5 b/XSTRCCI/Helpers/xstrcci.helper.mq5 index 97975560..947e9d17 100644 --- a/XSTRCCI/Helpers/xstrcci.helper.mq5 +++ b/XSTRCCI/Helpers/xstrcci.helper.mq5 @@ -22,6 +22,8 @@ // // Imports ... +#include "../../Helpers/x-saherelm.x121.xcc.helper.mq5" +#include "../../Helpers/x-saherelm.x121.xct.helper.mq5" #include "../../Helpers/x-saherelm.x121.xoscs.helper.mq5" #include "../../Helpers/x-saherelm.x121.xstr.helper.mq5" @@ -43,6 +45,8 @@ struct XSTRCCIInputs bool showStochastic; // + X121XCTInputs ctInputs; + X121XCCInputs ccInputs; X121XSTRInputs strInputs; X121XOCSInputs oscsInputs; @@ -75,6 +79,8 @@ struct XSTRCCIInputs showStochastic = false; // + ctInputs.Clean(); + ccInputs.Clean(); strInputs.Clean(); oscsInputs.Clean(); @@ -88,6 +94,8 @@ struct XSTRCCIInputs void Default() { // + ctInputs.Default(); + ccInputs.Default(); strInputs.Default(); oscsInputs.Default(); } @@ -105,8 +113,12 @@ struct XSTRCCIInputs // result = // + ctInputs.IsValid() && + ccInputs.IsValid() && strInputs.IsValid() && - oscsInputs.IsValid(); + oscsInputs.IsValid() + // + ; // return result; @@ -123,11 +135,15 @@ struct XSTRCCIInputs int result = 0; // + int ctMax = ctInputs.Max(); + int ccMax = ccInputs.Max(); int strMax = strInputs.Max(); int ocsMax = oscsInputs.Max(); // result = MathMax(strMax, ocsMax); + result = MathMax(result, ccMax); + result = MathMax(result, ctMax); // return result; @@ -147,16 +163,24 @@ struct XSTRCCIConditions // // XSTR ... + // + // Buffers ... + + // double strBuffer[]; double vidyaBuffer[]; double strUpBuffer[]; - double strMidBuffer[]; double strDownBuffer[]; double strPriceBuffer[]; double strStateBuffer[]; double strSMLowBuffer[]; double strSMHighBuffer[]; - double strMidStateBuffer[]; + + // + // Conditions ... + + // + // STR ... // bool isStrBullish; @@ -166,9 +190,98 @@ struct XSTRCCIConditions bool isStrSwitchedToBullish; bool isStrSwitchedToBearish; + // + // VIDYA ... + + // + bool isRejectUpVidya; + bool isClosedOverVidya; + bool isCrossedOverVidya; + + // + bool isRejectDownVidya; + bool isCloseUnderVidya; + bool isCrossedUnderVidya; + + // + // HMS ... + + // + bool isRejectUpLSM; + bool isCloseOverLSM; + bool isCrossedOverLSM; + + // + bool isRejectDownLSM; + bool isCloseUnderLSM; + bool isCrossedUnderLSM; + + // + // HSM .. + + // + bool isRejectUpHSM; + bool isCloseOverHSM; + bool isCrossedOverHSM; + + // + bool isRejectDownHSM; + bool isCloseUnderHSM; + bool isCrossedUnderHSM; + + // + // STR ... + + // + bool isRejectUpStr; + bool isCloseOverStr; + bool isCrossedOverStr; + + // + bool isRejectDownStr; + bool isCloseUnderStr; + bool isCrossedUnderStr; + + // + // HSM / ViDYA ... + + // + bool isVidyaOverHSM; + bool isVidyaCrossedOverHSM; + + // + bool isVidyaUnderHSM; + bool isVidyaCrossedUnderHSM; + + // + // LSM / VIDYA ... + + // + bool isVidyaOverLSM; + bool isVidyaCrossedOverLSM; + + // + bool isVidyaUnderLSM; + bool isVidyaCrossedUnderLSM; + + // + // STR / VIDYA ... + + // + bool isVidyaOverStr; + bool isVidyaCrossedOverStr; + + // + bool isVidyaUnderStr; + bool isVidyaCrossedUnderStr; + // // XOSCS ... + // + // Buffers ... + + // double acBuffer[]; double adBuffer[]; double atrBuffer[]; @@ -186,6 +299,218 @@ struct XSTRCCIConditions double stochasticBuffer[]; double stochasticSignalBuffer[]; + // + // Conditions ... + + // + // AC ... + + // + bool isACBullish; + bool isACBearish; + + // + bool isACSwitchedToBullish; + bool isACSwitchedToBearish; + + // + bool isACOverMax; + bool isACUnderMin; + + // + // AD ... + + // + bool isADBiggerLast; + bool isADLesserLast; + + // + bool isADOverMax; + bool isADUnderMin; + + // + // ADX ... + + // + bool isADXBiggerLast; + bool isADXLesserLast; + + // + bool isADXOverThreshold; + bool isADXUnderThreshold; + + // + bool isDXPBiggerThanDXN; + bool isDXNBiggerThanDXP; + + // + bool isADXBullish; + bool isADXBearish; + + // + bool isADXSwitchedToBullish; + bool isADXSwitchedToBearish; + + // + // ATR ... + + bool isATROverLast; + bool isATRUnderLast; + + // + // CCI ... + + // + bool isCCIBullish; + bool isCCIBearish; + + // + bool isCCISwitchedToBullish; + bool isCCISwitchedToBearish; + + // + bool isCCIOB; + bool isCCIOS; + + // + bool isCCICrossedOverOB; + bool isCCICrossedOverOS; + + // + bool isCCICrossedUnderOB; + bool isCCICrossedUnderOS; + + // + // RSI ... + + // + bool isRSIBullish; + bool isRSIBearish; + + // + bool isRSISwitchedToBullish; + bool isRSISwitchedToBearish; + + // + bool isRSIOB; + bool isRSIOS; + + // + bool isRSICrossedOverOB; + bool isRSICrossedOverOS; + + // + bool isRSICrossedUnderOB; + bool isRSICrossedUnderOS; + + // + // MFI ... + + // + bool isMFIBullish; + bool isMFIBearish; + + // + bool isMFISwitchedToBullish; + bool isMFISwitchedToBearish; + + // + bool isMFIOB; + bool isMFIOS; + + // + bool isMFICrossedOverOB; + bool isMFICrossedOverOS; + + // + bool isMFICrossedUnderOB; + bool isMFICrossedUnderOS; + + // + // RVI ... + + // + bool isRVIBullish; + bool isRVIBearish; + + // + bool isRVISwitchedToBullish; + bool isRVISwitchedToBearish; + + // + bool isRVIOverSignal; + bool isRVIUnderSignal; + + // + bool isRVICrossedOverSignal; + bool isRVICrossedUnderSignal; + + // + // MACD ... + + // + bool isMACDBullish; + bool isMACDBearish; + + // + bool isMACDSwitchedToBullish; + bool isMACDSwitchedToBearish; + + // + bool isMACDOverSignal; + bool isMACDUnderSignal; + + // + bool isMACDCrossedOverSignal; + bool isMACDCrossedUnderSignal; + + // + // MOMENTUM ... + + // + bool isMomentumBullish; + bool isMomentumBearish; + + // + bool isMomentumSwitchedToBullish; + bool isMomentumSwitchedToBearish; + + // + // STOCHASTIC ... + + // + bool isStochasticBullish; + bool isStochasticBearish; + + // + bool isStochasticSwitchedToBullish; + bool isStochasticSwitchedToBearish; + + // + bool isStochasticOverSignal; + bool isStochasticUnderSignal; + + // + bool isStochasticCrossedOverSignal; + bool isStochasticCrossedUnderSignal; + + // + bool isStochasticOB; + bool isStochasticOS; + + // + bool isStochasticCrossedOverOB; + bool isStochasticCrossedOverOS; + + // + bool isStochasticCrossedUnderOB; + bool isStochasticCrossedUnderOS; + + // + // Specified Conditions ... + + // + // // Constructor ... XSTRCCIConditions() @@ -210,31 +535,30 @@ struct XSTRCCIConditions // // XSTR ... + // + // Buffers ... + // Clean(strBuffer); Clean(atrBuffer); Clean(vidyaBuffer); Clean(strUpBuffer); - Clean(strMidBuffer); Clean(strDownBuffer); Clean(strPriceBuffer); Clean(strStateBuffer); Clean(strSMLowBuffer); Clean(strSMHighBuffer); - Clean(strMidStateBuffer); // ArraySetAsSeries(strBuffer, true); ArraySetAsSeries(atrBuffer, true); ArraySetAsSeries(vidyaBuffer, true); ArraySetAsSeries(strUpBuffer, true); - ArraySetAsSeries(strMidBuffer, true); ArraySetAsSeries(strDownBuffer, true); ArraySetAsSeries(strPriceBuffer, true); ArraySetAsSeries(strStateBuffer, true); ArraySetAsSeries(strSMLowBuffer, true); ArraySetAsSeries(strSMHighBuffer, true); - ArraySetAsSeries(strMidStateBuffer, true); // // Conditions ... @@ -242,11 +566,231 @@ struct XSTRCCIConditions // isStrBullish = false; isStrBearish = false; - - // + isRejectUpLSM = false; + isRejectUpHSM = false; + isRejectUpStr = false; + isCloseOverHSM = false; + isCloseOverLSM = false; + isCloseOverStr = false; + isVidyaOverHSM = false; + isVidyaOverLSM = false; + isVidyaOverStr = false; + isRejectDownLSM = false; + isRejectDownHSM = false; + isVidyaUnderStr = false; + isVidyaUnderHSM = false; + isVidyaUnderLSM = false; + isCloseUnderStr = false; + isRejectDownStr = false; + isRejectUpVidya = false; + isCloseUnderHSM = false; + isCloseUnderLSM = false; + isCrossedOverLSM = false; + isCrossedOverHSM = false; + isCrossedOverStr = false; + isCrossedUnderHSM = false; + isCrossedUnderLSM = false; + isCrossedUnderStr = false; + isClosedOverVidya = false; + isRejectDownVidya = false; + isCloseUnderVidya = false; + isCrossedOverVidya = false; + isCrossedUnderVidya = false; + isVidyaCrossedOverHSM = false; + isVidyaCrossedOverStr = false; + isVidyaCrossedOverLSM = false; + isVidyaCrossedUnderHSM = false; + isVidyaCrossedUnderLSM = false; + isVidyaCrossedUnderStr = false; isStrSwitchedToBullish = false; isStrSwitchedToBearish = false; + // + // XOSCS ... + + // + // Buffers ... + + // + Clean(acBuffer); + Clean(adBuffer); + Clean(atrBuffer); + Clean(cciBuffer); + Clean(rsiBuffer); + Clean(mfiBuffer); + Clean(rviBuffer); + Clean(adxBuffer); + Clean(adxpBuffer); + Clean(adxnBuffer); + Clean(macdBuffer); + Clean(momentumBuffer); + Clean(rviSignalBuffer); + Clean(macdSignalBuffer); + Clean(stochasticBuffer); + Clean(stochasticSignalBuffer); + + // + ArraySetAsSeries(acBuffer, true); + ArraySetAsSeries(adBuffer, true); + ArraySetAsSeries(atrBuffer, true); + ArraySetAsSeries(cciBuffer, true); + ArraySetAsSeries(rsiBuffer, true); + ArraySetAsSeries(mfiBuffer, true); + ArraySetAsSeries(rviBuffer, true); + ArraySetAsSeries(adxBuffer, true); + ArraySetAsSeries(adxpBuffer, true); + ArraySetAsSeries(adxnBuffer, true); + ArraySetAsSeries(macdBuffer, true); + ArraySetAsSeries(momentumBuffer, true); + ArraySetAsSeries(rviSignalBuffer, true); + ArraySetAsSeries(macdSignalBuffer, true); + ArraySetAsSeries(stochasticBuffer, true); + ArraySetAsSeries(stochasticSignalBuffer, true); + + // + // Conditions ... + + // + // AC ... + + // + isACBullish = false; + isACBearish = false; + isACSwitchedToBullish = false; + isACSwitchedToBearish = false; + isACOverMax = false; + isACUnderMin = false; + + // + // AD ... + + // + isADBiggerLast = false; + isADLesserLast = false; + isADOverMax = false; + isADUnderMin = false; + + // + // ADX ... + + // + isADXBiggerLast = false; + isADXLesserLast = false; + isADXOverThreshold = false; + isADXUnderThreshold = false; + isDXPBiggerThanDXN = false; + isDXNBiggerThanDXP = false; + isADXBullish = false; + isADXBearish = false; + isADXSwitchedToBullish = false; + isADXSwitchedToBearish = false; + + // + // ATR ... + + // + isATROverLast = false; + isATRUnderLast = false; + + // + // CCI ... + + // + isCCIBullish = false; + isCCIBearish = false; + isCCISwitchedToBullish = false; + isCCISwitchedToBearish = false; + isCCIOB = false; + isCCIOS = false; + isCCICrossedOverOB = false; + isCCICrossedOverOS = false; + isCCICrossedUnderOB = false; + isCCICrossedUnderOS = false; + + // + // RSI ... + + // + isRSIBullish = false; + isRSIBearish = false; + isRSISwitchedToBullish = false; + isRSISwitchedToBearish = false; + isRSIOB = false; + isRSIOS = false; + isRSICrossedOverOB = false; + isRSICrossedOverOS = false; + isRSICrossedUnderOB = false; + isRSICrossedUnderOS = false; + + // + // MFI ... + + // + isMFIBullish = false; + isMFIBearish = false; + isMFISwitchedToBullish = false; + isMFISwitchedToBearish = false; + isMFIOB = false; + isMFIOS = false; + isMFICrossedOverOB = false; + isMFICrossedOverOS = false; + isMFICrossedUnderOB = false; + isMFICrossedUnderOS = false; + + // + // RVI ... + + // + isRVIBullish = false; + isRVIBearish = false; + isRVISwitchedToBullish = false; + isRVISwitchedToBearish = false; + isRVIOverSignal = false; + isRVIUnderSignal = false; + isRVICrossedOverSignal = false; + isRVICrossedUnderSignal = false; + + // + // MACD ... + + // + isMACDBullish = false; + isMACDBearish = false; + isMACDSwitchedToBullish = false; + isMACDSwitchedToBearish = false; + isMACDOverSignal = false; + isMACDUnderSignal = false; + isMACDCrossedOverSignal = false; + isMACDCrossedUnderSignal = false; + + // + // MOMENTUM ... + + // + isMomentumBullish = false; + isMomentumBearish = false; + isMomentumSwitchedToBullish = false; + isMomentumSwitchedToBearish = false; + + // + // STOCHASTIC ... + + // + isStochasticBullish = false; + isStochasticBearish = false; + isStochasticSwitchedToBullish = false; + isStochasticSwitchedToBearish = false; + isStochasticOverSignal = false; + isStochasticUnderSignal = false; + isStochasticCrossedOverSignal = false; + isStochasticCrossedUnderSignal = false; + isStochasticOB = false; + isStochasticOS = false; + isStochasticCrossedOverOB = false; + isStochasticCrossedOverOS = false; + isStochasticCrossedUnderOB = false; + isStochasticCrossedUnderOS = false; + // ZeroMemory(this); } @@ -283,6 +827,78 @@ struct XSTRCCIConditions { bullishScore += score; } + if (isRejectUpVidya) + { + bullishScore += minScore; + } + if (isClosedOverVidya) + { + bullishScore += minScore; + } + if (isCrossedOverVidya) + { + bullishScore += minScore; + } + if (isRejectUpLSM) + { + bullishScore += minScore; + } + if (isCloseOverLSM) + { + bullishScore += minScore; + } + if (isCrossedOverLSM) + { + bullishScore += minScore; + } + if (isRejectUpHSM) + { + bullishScore += minScore; + } + if (isCloseOverHSM) + { + bullishScore += minScore; + } + if (isCrossedOverHSM) + { + bullishScore += minScore; + } + if (isRejectUpStr) + { + bullishScore += minScore; + } + if (isCloseOverStr) + { + bullishScore += minScore; + } + if (isCrossedOverStr) + { + bullishScore += minScore; + } + if (isVidyaOverHSM) + { + bullishScore += minScore; + } + if (isVidyaCrossedOverHSM) + { + bullishScore += minScore; + } + if (isVidyaOverLSM) + { + bullishScore += minScore; + } + if (isVidyaCrossedOverLSM) + { + bullishScore += minScore; + } + if (isVidyaOverStr) + { + bullishScore += minScore; + } + if (isVidyaCrossedOverStr) + { + bullishScore += minScore; + } // if (isStrBearish) @@ -293,9 +909,501 @@ struct XSTRCCIConditions { bearishScore += score; } + if (isRejectDownVidya) + { + bearishScore += minScore; + } + if (isCloseUnderVidya) + { + bearishScore += minScore; + } + if (isCrossedUnderVidya) + { + bearishScore += minScore; + } + if (isRejectDownLSM) + { + bearishScore += minScore; + } + if (isCloseUnderLSM) + { + bearishScore += minScore; + } + if (isCrossedUnderLSM) + { + bearishScore += minScore; + } + if (isRejectDownHSM) + { + bearishScore += minScore; + } + if (isCloseUnderHSM) + { + bearishScore += minScore; + } + if (isCrossedUnderHSM) + { + bearishScore += minScore; + } + if (isRejectDownStr) + { + bearishScore += minScore; + } + if (isCloseUnderStr) + { + bearishScore += minScore; + } + if (isCrossedUnderStr) + { + bearishScore += minScore; + } + if (isVidyaUnderHSM) + { + bearishScore += minScore; + } + if (isVidyaCrossedUnderHSM) + { + bearishScore += minScore; + } + if (isVidyaUnderLSM) + { + bearishScore += minScore; + } + if (isVidyaCrossedUnderLSM) + { + bearishScore += minScore; + } + if (isVidyaUnderStr) + { + bearishScore += minScore; + } + if (isVidyaCrossedUnderStr) + { + bearishScore += minScore; + } // // XOCS ... + // + // AC ... + + // + if (isACBullish) + { + bullishScore += minScore; + } + if (isACOverMax) + { + bullishScore += minScore; + } + if (isACSwitchedToBullish) + { + bullishScore += minScore; + } + + // + if (isACBearish) + { + bearishScore += minScore; + } + if (isACUnderMin) + { + bearishScore += minScore; + } + if (isACSwitchedToBearish) + { + bearishScore += minScore; + } + + // + // AD ... + + // + if (isADOverMax) + { + bullishScore += minScore; + } + if (isADBiggerLast) + { + bullishScore += minScore; + } + + // + if (isADUnderMin) + { + bearishScore += minScore; + } + if (isADLesserLast) + { + bearishScore += minScore; + } + + // + // ADX ... + + // + if (isADXBullish) + { + bullishScore += minScore; + } + if (isADXBiggerLast) + { + bullishScore += minScore; + } + if (isADXOverThreshold) + { + bullishScore += minScore; + } + if (isDXPBiggerThanDXN) + { + bullishScore += minScore; + } + if (isADXSwitchedToBullish) + { + bullishScore += minScore; + } + + // + if (isADXBearish) + { + bearishScore += minScore; + } + if (isADXLesserLast) + { + bearishScore += minScore; + } + if (isDXNBiggerThanDXP) + { + bearishScore += minScore; + } + if (isADXUnderThreshold) + { + bearishScore += minScore; + } + if (isADXSwitchedToBearish) + { + bearishScore += minScore; + } + + // + // ATR ... + + // + if (isATROverLast) + { + bullishScore += minScore; + } + + // + if (isATRUnderLast) + { + bearishScore += minScore; + } + + // + // CCI ... + + // + if (isCCIOS) + { + bullishScore += minScore; + } + if (isCCIBullish) + { + bullishScore += minScore; + } + if (isCCICrossedOverOS) + { + bullishScore += minScore; + } + if (isCCICrossedOverOB) + { + bullishScore += minScore; + } + if (isCCISwitchedToBullish) + { + bullishScore += minScore; + } + + // + if (isCCIOB) + { + bearishScore += minScore; + } + if (isCCIBearish) + { + bearishScore += minScore; + } + if (isCCICrossedUnderOS) + { + bearishScore += minScore; + } + if (isCCICrossedUnderOB) + { + bearishScore += minScore; + } + if (isCCISwitchedToBearish) + { + bearishScore += minScore; + } + + // + // RSI ... + + // + if (isRSIOS) + { + bullishScore += minScore; + } + if (isRSIBullish) + { + bullishScore += minScore; + } + if (isRSICrossedOverOB) + { + bullishScore += minScore; + } + if (isRSICrossedOverOS) + { + bullishScore += minScore; + } + if (isRSISwitchedToBullish) + { + bullishScore += minScore; + } + + // + if (isRSIOB) + { + bearishScore += minScore; + } + if (isRSIBearish) + { + bearishScore += minScore; + } + if (isRSICrossedUnderOB) + { + bearishScore += minScore; + } + if (isRSICrossedUnderOS) + { + bearishScore += minScore; + } + if (isRSISwitchedToBearish) + { + bearishScore += minScore; + } + + // + // MFI ... + + // + if (isMFIOS) + { + bullishScore += minScore; + } + if (isMFIBullish) + { + bullishScore += minScore; + } + if (isMFICrossedOverOB) + { + bullishScore += minScore; + } + if (isMFICrossedOverOS) + { + bullishScore += minScore; + } + if (isMFISwitchedToBullish) + { + bullishScore += minScore; + } + + // + if (isMFIOB) + { + bearishScore += minScore; + } + if (isMFIBearish) + { + bearishScore += minScore; + } + if (isMFICrossedUnderOB) + { + bearishScore += minScore; + } + if (isMFICrossedUnderOS) + { + bearishScore += minScore; + } + if (isMFISwitchedToBearish) + { + bearishScore += minScore; + } + + // + // RVI ... + + // + if (isRVIBullish) + { + bullishScore += minScore; + } + if (isRVIOverSignal) + { + bullishScore += minScore; + } + if (isRVISwitchedToBullish) + { + bullishScore += minScore; + } + if (isRVICrossedOverSignal) + { + bullishScore += minScore; + } + + // + if (isRVIBearish) + { + bearishScore += minScore; + } + if (isRVIUnderSignal) + { + bearishScore += minScore; + } + if (isRVISwitchedToBearish) + { + bearishScore += minScore; + } + if (isRVICrossedUnderSignal) + { + bearishScore += minScore; + } + + // + // MACD ... + + // + if (isMACDBullish) + { + bullishScore += minScore; + } + if (isMACDOverSignal) + { + bullishScore += minScore; + } + if (isMACDSwitchedToBullish) + { + bullishScore += minScore; + } + if (isMACDCrossedOverSignal) + { + bullishScore += minScore; + } + + // + if (isMACDBearish) + { + bearishScore += minScore; + } + if (isMACDUnderSignal) + { + bearishScore += minScore; + } + if (isMACDSwitchedToBearish) + { + bearishScore += minScore; + } + if (isMACDCrossedUnderSignal) + { + bearishScore += minScore; + } + + // + // MOMENTUM ... + + // + if (isMomentumBullish) + { + bullishScore += minScore; + } + if (isMomentumSwitchedToBullish) + { + bullishScore += minScore; + } + + // + if (isMomentumBearish) + { + bearishScore += minScore; + } + if (isMomentumSwitchedToBearish) + { + bearishScore += minScore; + } + + // + // STOCHASTIC ... + + // + if (isStochasticOS) + { + bullishScore += minScore; + } + if (isStochasticOverSignal) + { + bullishScore += minScore; + } + if (isStochasticBullish) + { + bullishScore += minScore; + } + if (isStochasticCrossedOverSignal) + { + bullishScore += minScore; + } + if (isStochasticCrossedOverOB) + { + bullishScore += minScore; + } + if (isStochasticCrossedOverOS) + { + bullishScore += minScore; + } + if (isStochasticSwitchedToBullish) + { + bullishScore += minScore; + } + + // + if (isStochasticOB) + { + bearishScore += minScore; + } + if (isStochasticUnderSignal) + { + bearishScore += minScore; + } + if (isStochasticBearish) + { + bearishScore += minScore; + } + if (isStochasticCrossedUnderSignal) + { + bearishScore += minScore; + } + if (isStochasticCrossedUnderOB) + { + bearishScore += minScore; + } + if (isStochasticCrossedUnderOS) + { + bearishScore += minScore; + } + if (isStochasticSwitchedToBearish) + { + bearishScore += minScore; + } } /** @@ -356,9 +1464,131 @@ struct XSTRCCIConditions ToString("isStrBearish", isStrBearish, ignoreFalseConditions, separator) + ToString("isStrSwitchedToBullish", isStrSwitchedToBullish, ignoreFalseConditions, separator) + ToString("isStrSwitchedToBearish", isStrSwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isRejectUpVidya", isRejectUpVidya, ignoreFalseConditions, separator) + + ToString("isClosedOverVidya", isClosedOverVidya, ignoreFalseConditions, separator) + + ToString("isCrossedOverVidya", isCrossedOverVidya, ignoreFalseConditions, separator) + + ToString("isRejectDownVidya", isRejectDownVidya, ignoreFalseConditions, separator) + + ToString("isCloseUnderVidya", isCloseUnderVidya, ignoreFalseConditions, separator) + + ToString("isCrossedUnderVidya", isCrossedUnderVidya, ignoreFalseConditions, separator) + + ToString("isRejectUpLSM", isRejectUpLSM, ignoreFalseConditions, separator) + + ToString("isCloseOverLSM", isCloseOverLSM, ignoreFalseConditions, separator) + + ToString("isCrossedOverLSM", isCrossedOverLSM, ignoreFalseConditions, separator) + + ToString("isRejectDownLSM", isRejectDownLSM, ignoreFalseConditions, separator) + + ToString("isCloseUnderLSM", isCloseUnderLSM, ignoreFalseConditions, separator) + + ToString("isCrossedUnderLSM", isCrossedUnderLSM, ignoreFalseConditions, separator) + + ToString("isRejectUpHSM", isRejectUpHSM, ignoreFalseConditions, separator) + + ToString("isCloseOverHSM", isCloseOverHSM, ignoreFalseConditions, separator) + + ToString("isCrossedOverHSM", isCrossedOverHSM, ignoreFalseConditions, separator) + + ToString("isRejectDownHSM", isRejectDownHSM, ignoreFalseConditions, separator) + + ToString("isCloseUnderHSM", isCloseUnderHSM, ignoreFalseConditions, separator) + + ToString("isCrossedUnderHSM", isCrossedUnderHSM, ignoreFalseConditions, separator) + + ToString("isRejectUpStr", isRejectUpStr, ignoreFalseConditions, separator) + + ToString("isCloseOverStr", isCloseOverStr, ignoreFalseConditions, separator) + + ToString("isCrossedOverStr", isCrossedOverStr, ignoreFalseConditions, separator) + + ToString("isRejectDownStr", isRejectDownStr, ignoreFalseConditions, separator) + + ToString("isCloseUnderStr", isCloseUnderStr, ignoreFalseConditions, separator) + + ToString("isCrossedUnderStr", isCrossedUnderStr, ignoreFalseConditions, separator) + + ToString("isVidyaOverHSM", isVidyaOverHSM, ignoreFalseConditions, separator) + + ToString("isVidyaCrossedOverHSM", isVidyaCrossedOverHSM, ignoreFalseConditions, separator) + + ToString("isVidyaUnderHSM", isVidyaUnderHSM, ignoreFalseConditions, separator) + + ToString("isVidyaCrossedUnderHSM", isVidyaCrossedUnderHSM, ignoreFalseConditions, separator) + + ToString("isVidyaOverLSM", isVidyaOverLSM, ignoreFalseConditions, separator) + + ToString("isVidyaCrossedOverLSM", isVidyaCrossedOverLSM, ignoreFalseConditions, separator) + + ToString("isVidyaUnderLSM", isVidyaUnderLSM, ignoreFalseConditions, separator) + + ToString("isVidyaCrossedUnderLSM", isVidyaCrossedUnderLSM, ignoreFalseConditions, separator) + + ToString("isVidyaOverStr", isVidyaOverStr, ignoreFalseConditions, separator) + + ToString("isVidyaCrossedOverStr", isVidyaCrossedOverStr, ignoreFalseConditions, separator) + + ToString("isVidyaUnderStr", isVidyaUnderStr, ignoreFalseConditions, separator) + + ToString("isVidyaCrossedUnderStr", isVidyaCrossedUnderStr, ignoreFalseConditions, separator) + "-----------------------" + separator + "XOCS: " + separator + "-----------------------" + separator + + ToString("isACBullish", isACBullish, ignoreFalseConditions, separator) + + ToString("isACBearish", isACBearish, ignoreFalseConditions, separator) + + ToString("isACSwitchedToBullish", isACSwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isACSwitchedToBearish", isACSwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isACOverMax", isACOverMax, ignoreFalseConditions, separator) + + ToString("isACUnderMin", isACUnderMin, ignoreFalseConditions, separator) + + ToString("isADBiggerLast", isADBiggerLast, ignoreFalseConditions, separator) + + ToString("isADLesserLast", isADLesserLast, ignoreFalseConditions, separator) + + ToString("isADOverMax", isADOverMax, ignoreFalseConditions, separator) + + ToString("isADUnderMin", isADUnderMin, ignoreFalseConditions, separator) + + ToString("isADXBiggerLast", isADXBiggerLast, ignoreFalseConditions, separator) + + ToString("isADXLesserLast", isADXLesserLast, ignoreFalseConditions, separator) + + ToString("isADXOverThreshold", isADXOverThreshold, ignoreFalseConditions, separator) + + ToString("isADXUnderThreshold", isADXUnderThreshold, ignoreFalseConditions, separator) + + ToString("isDXPBiggerThanDXN", isDXPBiggerThanDXN, ignoreFalseConditions, separator) + + ToString("isDXNBiggerThanDXP", isDXNBiggerThanDXP, ignoreFalseConditions, separator) + + ToString("isADXBullish", isADXBullish, ignoreFalseConditions, separator) + + ToString("isADXBearish", isADXBearish, ignoreFalseConditions, separator) + + ToString("isADXSwitchedToBullish", isADXSwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isADXSwitchedToBearish", isADXSwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isATROverLast", isATROverLast, ignoreFalseConditions, separator) + + ToString("isATRUnderLast", isATRUnderLast, ignoreFalseConditions, separator) + + ToString("isCCIBullish", isCCIBullish, ignoreFalseConditions, separator) + + ToString("isCCIBearish", isCCIBearish, ignoreFalseConditions, separator) + + ToString("isCCISwitchedToBullish", isCCISwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isCCISwitchedToBearish", isCCISwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isCCIOB", isCCIOB, ignoreFalseConditions, separator) + + ToString("isCCIOS", isCCIOS, ignoreFalseConditions, separator) + + ToString("isCCICrossedOverOB", isCCICrossedOverOB, ignoreFalseConditions, separator) + + ToString("isCCICrossedOverOS", isCCICrossedOverOS, ignoreFalseConditions, separator) + + ToString("isCCICrossedUnderOB", isCCICrossedUnderOB, ignoreFalseConditions, separator) + + ToString("isCCICrossedUnderOS", isCCICrossedUnderOS, ignoreFalseConditions, separator) + + ToString("isRSIBullish", isRSIBullish, ignoreFalseConditions, separator) + + ToString("isRSIBearish", isRSIBearish, ignoreFalseConditions, separator) + + ToString("isRSISwitchedToBullish", isRSISwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isRSISwitchedToBearish", isRSISwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isRSIOB", isRSIOB, ignoreFalseConditions, separator) + + ToString("isRSIOS", isRSIOS, ignoreFalseConditions, separator) + + ToString("isRSICrossedOverOB", isRSICrossedOverOB, ignoreFalseConditions, separator) + + ToString("isRSICrossedOverOS", isRSICrossedOverOS, ignoreFalseConditions, separator) + + ToString("isRSICrossedUnderOB", isRSICrossedUnderOB, ignoreFalseConditions, separator) + + ToString("isRSICrossedUnderOS", isRSICrossedUnderOS, ignoreFalseConditions, separator) + + ToString("isMFIBullish", isMFIBullish, ignoreFalseConditions, separator) + + ToString("isMFIBearish", isMFIBearish, ignoreFalseConditions, separator) + + ToString("isMFISwitchedToBullish", isMFISwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isMFISwitchedToBearish", isMFISwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isMFIOB", isMFIOB, ignoreFalseConditions, separator) + + ToString("isMFIOS", isMFIOS, ignoreFalseConditions, separator) + + ToString("isMFICrossedOverOB", isMFICrossedOverOB, ignoreFalseConditions, separator) + + ToString("isMFICrossedOverOS", isMFICrossedOverOS, ignoreFalseConditions, separator) + + ToString("isMFICrossedUnderOB", isMFICrossedUnderOB, ignoreFalseConditions, separator) + + ToString("isMFICrossedUnderOS", isMFICrossedUnderOS, ignoreFalseConditions, separator) + + ToString("isRVIBullish", isRVIBullish, ignoreFalseConditions, separator) + + ToString("isRVIBearish", isRVIBearish, ignoreFalseConditions, separator) + + ToString("isRVISwitchedToBullish", isRVISwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isRVISwitchedToBearish", isRVISwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isRVIOverSignal", isRVIOverSignal, ignoreFalseConditions, separator) + + ToString("isRVIUnderSignal", isRVIUnderSignal, ignoreFalseConditions, separator) + + ToString("isRVICrossedOverSignal", isRVICrossedOverSignal, ignoreFalseConditions, separator) + + ToString("isRVICrossedUnderSignal", isRVICrossedUnderSignal, ignoreFalseConditions, separator) + + ToString("isMACDBullish", isMACDBullish, ignoreFalseConditions, separator) + + ToString("isMACDBearish", isMACDBearish, ignoreFalseConditions, separator) + + ToString("isMACDSwitchedToBullish", isMACDSwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isMACDSwitchedToBearish", isMACDSwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isMACDOverSignal", isMACDOverSignal, ignoreFalseConditions, separator) + + ToString("isMACDUnderSignal", isMACDUnderSignal, ignoreFalseConditions, separator) + + ToString("isMACDCrossedOverSignal", isMACDCrossedOverSignal, ignoreFalseConditions, separator) + + ToString("isMACDCrossedUnderSignal", isMACDCrossedUnderSignal, ignoreFalseConditions, separator) + + ToString("isMomentumBullish", isMomentumBullish, ignoreFalseConditions, separator) + + ToString("isMomentumBearish", isMomentumBearish, ignoreFalseConditions, separator) + + ToString("isMomentumSwitchedToBullish", isMomentumSwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isMomentumSwitchedToBearish", isMomentumSwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isStochasticBullish", isStochasticBullish, ignoreFalseConditions, separator) + + ToString("isStochasticBearish", isStochasticBearish, ignoreFalseConditions, separator) + + ToString("isStochasticSwitchedToBullish", isStochasticSwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isStochasticSwitchedToBearish", isStochasticSwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isStochasticOverSignal", isStochasticOverSignal, ignoreFalseConditions, separator) + + ToString("isStochasticUnderSignal", isStochasticUnderSignal, ignoreFalseConditions, separator) + + ToString("isStochasticCrossedOverSignal", isStochasticCrossedOverSignal, ignoreFalseConditions, separator) + + ToString("isStochasticCrossedUnderSignal", isStochasticCrossedUnderSignal, ignoreFalseConditions, separator) + + ToString("isStochasticOB", isStochasticOB, ignoreFalseConditions, separator) + + ToString("isStochasticOS", isStochasticOS, ignoreFalseConditions, separator) + + ToString("isStochasticCrossedOverOB", isStochasticCrossedOverOB, ignoreFalseConditions, separator) + + ToString("isStochasticCrossedOverOS", isStochasticCrossedOverOS, ignoreFalseConditions, separator) + + ToString("isStochasticCrossedUnderOB", isStochasticCrossedUnderOB, ignoreFalseConditions, separator) + + ToString("isStochasticCrossedUnderOS", isStochasticCrossedUnderOS, ignoreFalseConditions, separator) + // "" // @@ -406,6 +1636,8 @@ class XCXSTRCCIHelper : XCBase public: // // Props ... + XCX121XCCHelper *ccHelper; + XCX121XCTHelper *ctHelper; XCX121XSTRHelper *strHelper; XCX121XOCSHelper *ocsHelper; @@ -423,6 +1655,8 @@ class XCXSTRCCIHelper : XCBase mInputs.Clean(); // + ZeroMemory(ccHelper); + ZeroMemory(ctHelper); ZeroMemory(strHelper); ZeroMemory(ocsHelper); @@ -496,6 +1730,28 @@ class XCXSTRCCIHelper : XCBase // // Initial Helpers ... + // + // XCT ... + ctHelper = new XCX121XCTHelper(); + result = + result && + ctHelper.Init( + symbol, + period, + mInputs.ctInputs // + ); + + // + // XCC ... + ccHelper = new XCX121XCCHelper(); + result = + result && + ccHelper.Init( + symbol, + period, + mInputs.ccInputs // + ); + // // XSTR ... strHelper = new XCX121XSTRHelper(); @@ -522,6 +1778,8 @@ class XCXSTRCCIHelper : XCBase if (!result) { // + ZeroMemory(ccHelper); + ZeroMemory(ctHelper); ZeroMemory(strHelper); ZeroMemory(ocsHelper); @@ -737,6 +1995,8 @@ class XCXSTRCCIHelper : XCBase mInputs.Clean(); // + ZeroMemory(ccHelper); + ZeroMemory(ctHelper); ZeroMemory(strHelper); ZeroMemory(ocsHelper); @@ -954,12 +2214,6 @@ class XCXSTRCCIHelper : XCBase conditions.strBuffer // ); - // - Copy( - xstrConditions.strMidBuffer, - conditions.strMidBuffer // - ); - // Copy( xstrConditions.strUpBuffer, @@ -996,18 +2250,48 @@ class XCXSTRCCIHelper : XCBase conditions.strSMHighBuffer // ); - // - Copy( - xstrConditions.strMidStateBuffer, - conditions.strMidStateBuffer // - ); - // // Conditions ... // conditions.isStrBullish = xstrConditions.isStrBullish; conditions.isStrBearish = xstrConditions.isStrBearish; + conditions.isRejectUpLSM = xstrConditions.isRejectUpLSM; + conditions.isRejectUpHSM = xstrConditions.isRejectUpHSM; + conditions.isRejectUpStr = xstrConditions.isRejectUpStr; + conditions.isCloseOverHSM = xstrConditions.isCloseOverHSM; + conditions.isCloseOverLSM = xstrConditions.isCloseOverLSM; + conditions.isCloseOverStr = xstrConditions.isCloseOverStr; + conditions.isVidyaOverHSM = xstrConditions.isVidyaOverHSM; + conditions.isVidyaOverLSM = xstrConditions.isVidyaOverLSM; + conditions.isVidyaOverStr = xstrConditions.isVidyaOverStr; + conditions.isRejectDownLSM = xstrConditions.isRejectDownLSM; + conditions.isRejectDownHSM = xstrConditions.isRejectDownHSM; + conditions.isVidyaUnderStr = xstrConditions.isVidyaUnderStr; + conditions.isVidyaUnderHSM = xstrConditions.isVidyaUnderHSM; + conditions.isVidyaUnderLSM = xstrConditions.isVidyaUnderLSM; + conditions.isCloseUnderStr = xstrConditions.isCloseUnderStr; + conditions.isRejectDownStr = xstrConditions.isRejectDownStr; + conditions.isRejectUpVidya = xstrConditions.isRejectUpVidya; + conditions.isCloseUnderHSM = xstrConditions.isCloseUnderHSM; + conditions.isCloseUnderLSM = xstrConditions.isCloseUnderLSM; + conditions.isCrossedOverLSM = xstrConditions.isCrossedOverLSM; + conditions.isCrossedOverHSM = xstrConditions.isCrossedOverHSM; + conditions.isCrossedOverStr = xstrConditions.isCrossedOverStr; + conditions.isCrossedUnderHSM = xstrConditions.isCrossedUnderHSM; + conditions.isCrossedUnderLSM = xstrConditions.isCrossedUnderLSM; + conditions.isCrossedUnderStr = xstrConditions.isCrossedUnderStr; + conditions.isClosedOverVidya = xstrConditions.isClosedOverVidya; + conditions.isRejectDownVidya = xstrConditions.isRejectDownVidya; + conditions.isCloseUnderVidya = xstrConditions.isCloseUnderVidya; + conditions.isCrossedOverVidya = xstrConditions.isCrossedOverVidya; + conditions.isCrossedUnderVidya = xstrConditions.isCrossedUnderVidya; + conditions.isVidyaCrossedOverHSM = xstrConditions.isVidyaCrossedOverHSM; + conditions.isVidyaCrossedOverStr = xstrConditions.isVidyaCrossedOverStr; + conditions.isVidyaCrossedOverLSM = xstrConditions.isVidyaCrossedOverLSM; + conditions.isVidyaCrossedUnderHSM = xstrConditions.isVidyaCrossedUnderHSM; + conditions.isVidyaCrossedUnderLSM = xstrConditions.isVidyaCrossedUnderLSM; + conditions.isVidyaCrossedUnderStr = xstrConditions.isVidyaCrossedUnderStr; conditions.isStrSwitchedToBullish = xstrConditions.isStrSwitchedToBullish; conditions.isStrSwitchedToBearish = xstrConditions.isStrSwitchedToBearish; @@ -1115,7 +2399,94 @@ class XCXSTRCCIHelper : XCBase // // Conditions ... - + // + conditions.isCCIOB = xocsConditions.isCCIOB; + conditions.isCCIOS = xocsConditions.isCCIOS; + conditions.isRSIOB = xocsConditions.isRSIOB; + conditions.isRSIOS = xocsConditions.isRSIOS; + conditions.isMFIOB = xocsConditions.isMFIOB; + conditions.isMFIOS = xocsConditions.isMFIOS; + conditions.isACBullish = xocsConditions.isACBullish; + conditions.isACBearish = xocsConditions.isACBearish; + conditions.isACOverMax = xocsConditions.isACOverMax; + conditions.isADOverMax = xocsConditions.isADOverMax; + conditions.isACUnderMin = xocsConditions.isACUnderMin; + conditions.isADUnderMin = xocsConditions.isADUnderMin; + conditions.isADXBullish = xocsConditions.isADXBullish; + conditions.isADXBearish = xocsConditions.isADXBearish; + conditions.isCCIBullish = xocsConditions.isCCIBullish; + conditions.isCCIBearish = xocsConditions.isCCIBearish; + conditions.isRSIBullish = xocsConditions.isRSIBullish; + conditions.isRSIBearish = xocsConditions.isRSIBearish; + conditions.isMFIBullish = xocsConditions.isMFIBullish; + conditions.isMFIBearish = xocsConditions.isMFIBearish; + conditions.isRVIBullish = xocsConditions.isRVIBullish; + conditions.isRVIBearish = xocsConditions.isRVIBearish; + conditions.isATROverLast = xocsConditions.isATROverLast; + conditions.isMACDBullish = xocsConditions.isMACDBullish; + conditions.isMACDBearish = xocsConditions.isMACDBearish; + conditions.isATRUnderLast = xocsConditions.isATRUnderLast; + conditions.isADBiggerLast = xocsConditions.isADBiggerLast; + conditions.isADLesserLast = xocsConditions.isADLesserLast; + conditions.isStochasticOB = xocsConditions.isStochasticOB; + conditions.isStochasticOS = xocsConditions.isStochasticOS; + conditions.isADXBiggerLast = xocsConditions.isADXBiggerLast; + conditions.isADXLesserLast = xocsConditions.isADXLesserLast; + conditions.isRVIOverSignal = xocsConditions.isRVIOverSignal; + conditions.isRVIUnderSignal = xocsConditions.isRVIUnderSignal; + conditions.isMACDOverSignal = xocsConditions.isMACDOverSignal; + conditions.isMACDUnderSignal = xocsConditions.isMACDUnderSignal; + conditions.isMomentumBullish = xocsConditions.isMomentumBullish; + conditions.isMomentumBearish = xocsConditions.isMomentumBearish; + conditions.isADXOverThreshold = xocsConditions.isADXOverThreshold; + conditions.isDXPBiggerThanDXN = xocsConditions.isDXPBiggerThanDXN; + conditions.isDXNBiggerThanDXP = xocsConditions.isDXNBiggerThanDXP; + conditions.isCCICrossedOverOB = xocsConditions.isCCICrossedOverOB; + conditions.isCCICrossedOverOS = xocsConditions.isCCICrossedOverOS; + conditions.isRSICrossedOverOB = xocsConditions.isRSICrossedOverOB; + conditions.isRSICrossedOverOS = xocsConditions.isRSICrossedOverOS; + conditions.isMFICrossedOverOB = xocsConditions.isMFICrossedOverOB; + conditions.isMFICrossedOverOS = xocsConditions.isMFICrossedOverOS; + conditions.isADXUnderThreshold = xocsConditions.isADXUnderThreshold; + conditions.isCCICrossedUnderOB = xocsConditions.isCCICrossedUnderOB; + conditions.isCCICrossedUnderOS = xocsConditions.isCCICrossedUnderOS; + conditions.isRSICrossedUnderOB = xocsConditions.isRSICrossedUnderOB; + conditions.isRSICrossedUnderOS = xocsConditions.isRSICrossedUnderOS; + conditions.isMFICrossedUnderOB = xocsConditions.isMFICrossedUnderOB; + conditions.isMFICrossedUnderOS = xocsConditions.isMFICrossedUnderOS; + conditions.isStochasticBullish = xocsConditions.isStochasticBullish; + conditions.isStochasticBearish = xocsConditions.isStochasticBearish; + conditions.isACSwitchedToBullish = xocsConditions.isACSwitchedToBullish; + conditions.isACSwitchedToBearish = xocsConditions.isACSwitchedToBearish; + conditions.isADXSwitchedToBullish = xocsConditions.isADXSwitchedToBullish; + conditions.isADXSwitchedToBearish = xocsConditions.isADXSwitchedToBearish; + conditions.isCCISwitchedToBullish = xocsConditions.isCCISwitchedToBullish; + conditions.isCCISwitchedToBearish = xocsConditions.isCCISwitchedToBearish; + conditions.isRSISwitchedToBullish = xocsConditions.isRSISwitchedToBullish; + conditions.isRSISwitchedToBearish = xocsConditions.isRSISwitchedToBearish; + conditions.isMFISwitchedToBullish = xocsConditions.isMFISwitchedToBullish; + conditions.isMFISwitchedToBearish = xocsConditions.isMFISwitchedToBearish; + conditions.isRVISwitchedToBullish = xocsConditions.isRVISwitchedToBullish; + conditions.isRVISwitchedToBearish = xocsConditions.isRVISwitchedToBearish; + conditions.isRVICrossedOverSignal = xocsConditions.isRVICrossedOverSignal; + conditions.isStochasticOverSignal = xocsConditions.isStochasticOverSignal; + conditions.isStochasticUnderSignal = xocsConditions.isStochasticUnderSignal; + conditions.isRVICrossedUnderSignal = xocsConditions.isRVICrossedUnderSignal; + conditions.isMACDSwitchedToBullish = xocsConditions.isMACDSwitchedToBullish; + conditions.isMACDSwitchedToBearish = xocsConditions.isMACDSwitchedToBearish; + conditions.isMACDCrossedOverSignal = xocsConditions.isMACDCrossedOverSignal; + conditions.isMACDCrossedUnderSignal = xocsConditions.isMACDCrossedUnderSignal; + conditions.isStochasticCrossedOverOB = xocsConditions.isStochasticCrossedOverOB; + conditions.isStochasticCrossedOverOS = xocsConditions.isStochasticCrossedOverOS; + conditions.isStochasticCrossedUnderOB = xocsConditions.isStochasticCrossedUnderOB; + conditions.isStochasticCrossedUnderOS = xocsConditions.isStochasticCrossedUnderOS; + conditions.isMomentumSwitchedToBullish = xocsConditions.isMomentumSwitchedToBullish; + conditions.isMomentumSwitchedToBearish = xocsConditions.isMomentumSwitchedToBearish; + conditions.isStochasticSwitchedToBullish = xocsConditions.isStochasticSwitchedToBullish; + conditions.isStochasticSwitchedToBearish = xocsConditions.isStochasticSwitchedToBearish; + conditions.isStochasticCrossedOverSignal = xocsConditions.isStochasticCrossedOverSignal; + conditions.isStochasticCrossedUnderSignal = xocsConditions.isStochasticCrossedUnderSignal; + // // Cleanup Resource ... diff --git a/XSTRCCI/Libraries/xstrcci.signaller.lib.mq5 b/XSTRCCI/Libraries/xstrcci.signaller.lib.mq5 index 185e34dc..f78f93a5 100644 --- a/XSTRCCI/Libraries/xstrcci.signaller.lib.mq5 +++ b/XSTRCCI/Libraries/xstrcci.signaller.lib.mq5 @@ -22,8 +22,400 @@ // // Imports ... #include "../../Libraries/x-saherelm.common.lib.mq5" +#include "../../Libraries/x-saherelm.x-poi.lib.mq5" +#include "../../Libraries/x-saherelm.x-trade.lib.mq5" + +// +// Enumeration ... + +// +// Guard Actions ... +enum ENUM_GUARD_ACTIONS +{ + X_GUARD_ACTION_NONE, // Nothing to Do + X_GUARD_ACTION_CLOSE, // Close Specified Position + X_GUARD_ACTION_CLOSE_ALL, // Close All Positions + X_GUARD_ACTION_CLOSE_LONGS, // Close All Long Positions + X_GUARD_ACTION_CLOSE_SHORTS, // Close All Short Position + X_GUARD_ACTION_PARTIAL_CLOSE, // Partial Close Specified Position + X_GUARD_ACTION_TRAIL_STOP, // Trail Stop of Specified Position + X_GUARD_ACTION_TRAIL_TARGET, // Trail Target of Specified Position + X_GUARD_ACTION_HEDGE, // Hedge Specified Positions +}; // // Definitions ... +// +// Conditions Struct ... +struct XSTRCCIStrategyConditions +{ + // + // Props ... + + // + string symbol; + ENUM_TIMEFRAMES period; + + // + // Setup Props ... + + // + double sl; + double tp; + double pivot; + double point; + double sls[]; + string provider; + double targets[]; + + // + datetime time; + datetime setupTime; + datetime triggerTime; + + // + XBoxZone signalBox; + ENUM_X_DIRECTION dir; + ENUM_X_POSITION_TYPES type; + ENUM_X_DIRECTION signalDir; + + // + // Constructor ... + XSTRCCIStrategyConditions() + { + Clean(); + } + + // + // Tools ... + + /** + * Cleaning Up ... + */ + void Clean() + { + // + sl = 0; + tp = 0; + pivot = 0; + point = 0; + + // + symbol = NULL; + period = NULL; + provider = NULL; + + // + time = NULL; + setupTime = NULL; + triggerTime = NULL; + + // + Clean(sls); + Clean(targets); + + // + signalBox.Clean(); + + // + dir = X_DIRECTION_NONE; + type = X_POSITION_TYPE_NONE; + signalDir = X_DIRECTION_NONE; + + // + } + + // + // Signalling ... + + /** + * Validate ... + * + * @return ( bool ) + */ + bool IsValid() + { + // + bool result = false; + + // + result = IsSpecifiedValid(symbol) && + IsSpecifiedValid(period) && + IsSpecifiedValid(time); + + // + return result; + } + + /** + * Check Conditions Has Valid Bullish Signal ... + * + * @return ( bool ) + */ + bool HasBullishSignal() + { + // + bool result = false; + + // + result = + (sl > 0 || + tp > 0) && + IsValid() && + HasDirection(signalDir); + if (!result) + { + return result; + } + + // + result = + IsBullish(signalDir); + + // + return result; + } + + /** + * Check Conditions Has Valid Bearish Signal ... + * + * @return ( bool ) + */ + bool HasBearishSignal() + { + // + bool result = false; + + // + result = + (sl > 0 || + tp > 0) && + IsValid() && + HasDirection(signalDir); + if (!result) + { + return result; + } + + // + result = + IsBearish(signalDir); + + // + return result; + } + + // + // Setting Up and Triggering Up ... + + /** + * Check Condition is Setting Up ... + * + * @param dir: ENUM_X_DIRECTION member, Setting Up Direction ... + * + * @return ( bool ) + */ + bool IsSetuped() + { + // + bool result = false; + + // + result = IsValid(setupTime) && + HasDirection(dir); + if (!result) + { + return result; + } + + // + return result; + } + + /** + * Calculate Setup Age ... + * + * @return ( int ) + */ + int GetSetupAge() + { + // + int result = 0; + + // + if (!IsSetuped()) + { + return result; + } + + // + result = (int)(TimeCurrent() - setupTime) / PeriodSeconds(period); + + // + return result; + } + + /** + * Detect How we Can Trigger Signal ... + * + * @return ( bool ) + */ + bool CanTrigger() + { + // + bool result = false; + + // + result = + // + sl > 0 && + IsValid(symbol) && + IsValid(period) && + IsValid(triggerTime) && + type != X_POSITION_TYPE_ALL && + type != X_POSITION_TYPE_NONE + // + ; + + // + return result; + } + + // +}; + +// +// Model a Guard Action ... +struct XSTRCCIGuard +{ + // + // Props ... + ENUM_GUARD_ACTIONS action; + datetime time; + + // + string symbol; + string provider; + + // + // Specified Position ... + ulong ticket; + + // + // Partial Close ... + double volumeMultiplier; + + // + // SL Trial ... + double sl; + + // + // TP Trial ... + double tp; + + // + // Constructor ... + XSTRCCIGuard() + { + Clean(); + } + + // + // Tools ... + + /** + * Cleanup ... + */ + void Clean() + { + // + time = NULL; + action = X_GUARD_ACTION_NONE; + + // + symbol = NULL; + provider = NULL; + + // + ticket = 0; + + // + volumeMultiplier = 0; + + // + sl = 0; + tp = 0; + + // + ZeroMemory(this); + } + + /** + * Validate ... + * + * @return ( bool ) + */ + bool IsValid() + { + // + bool result = false; + + // + result = + // + IsValid(time) && + IsValid(symbol) && + IsValid(provider) && + action != X_GUARD_ACTION_NONE + // + ; + if (!result) + { + return result; + } + + // + // Validate Model Based On Specified Guard Actions ... + + // + return result; + } +}; + +/** + * Add Guard to Collection ... + * + * @param guard: XSTRCCIGuard instance ... + * @param guards: XSTRCCIGuard instance Collection ... + * + * @return ( int ) + */ +int AddGuard( + XSTRCCIGuard &guard, + XSTRCCIGuard &guards[] // +) +{ + // + int result = 0; + + // + if (!guard.IsValid()) + { + return result; + } + + // + AddRef( + guard, + guards // + ); + + // + result = ArraySize(guards); + + // + return result; +} + // \ No newline at end of file diff --git a/XSTRCCI/Signals/xstrcci.signaller.class.mq5 b/XSTRCCI/Signals/xstrcci.signaller.class.mq5 index 8cd9edec..3c3fc14b 100644 --- a/XSTRCCI/Signals/xstrcci.signaller.class.mq5 +++ b/XSTRCCI/Signals/xstrcci.signaller.class.mq5 @@ -22,6 +22,7 @@ // // Imports ... #include "../../Classes/x-saherelm.base.class.mq5" +#include "../../Classes/x-saherelm.x-cobject.class.mq5" #include "../Helpers/xstrcci.helper.mq5" #include "../Libraries/xstrcci.signaller.lib.mq5" @@ -35,25 +36,340 @@ class XCXSTRCCISignaller : XCBase public: // // Props ... + bool useGuards; + double rfReward; + bool isPassedBoxes; + XSTRCCIInputs inputs; + XCXSTRCCIHelper *helper; + bool continuesRFTillTarget; + XSTRCCIStrategyConditions mConditions; + XSTRCCIStrategyConditions mConditionsCollection[]; // // Constructor ... - XCXSTRCCISignaller() + XCXSTRCCISignaller( + string _symbol, + ENUM_TIMEFRAMES _period // + ) { + // + symbol = _symbol; + period = _period; + Init(); } // // Deconstructor ... ~XCXSTRCCISignaller() { + DeInit(); + } + + // + // Properties ... + + string GetSymbol() + { + return symbol; + } + + ENUM_TIMEFRAMES GetPeriod() + { + return period; + } + + // + // Signaller Tools ... + + /** + * Detect Setup Conditions based on Signalling ... + * + * @param maxAllowedSLDistanceInPoint: int, Max Allowed SL Distance in Points (if Bigger thn Zero Provided) ... + * + * @return ( bool ) + */ + bool DetectSignalSetup( + double tpReward = 3, + double maxAllowedSLDistanceInPoint = 300 // + ) + { + // + bool result = false; + + // + return result; + } + + /** + * Detect Trigger Conditions for Specified Signal ... + * + * @param conditions: XSTRCCIStrategyConditions instance Reference, Specified Signal Conditions ... + * @param maxAllowedSetupAge: specified Setup Age for Expiration (if bigger than Zero) ... + * + * @return ( bool ) + */ + bool DetectSignalTrigger( + XSTRCCIStrategyConditions &conditions, + int maxAllowedSetupAge = 60 // + ) + { + // + bool result = false; + + // + result = conditions.IsSetuped(); + if (!result) + { + return result; + } + + // + datetime setupTime = conditions.setupTime; + ENUM_X_DIRECTION setupDir = conditions.dir; + + // + bool isBullish = IsBullish(setupDir); + bool isBearish = IsBearish(setupDir); + + // + int zIndex = 0; + int cIndex = zIndex + 1; + int pIndex = cIndex + 1; + int ppIndex = pIndex + 1; + + // + int loopback = 10; + + // + double ask = GetAsk(symbol); + double bid = GetBid(symbol); + datetime cTime = TimeCurrent(); + double points = GetPoints(symbol); + + // + // Check Signal Validation ... + // IMPORTANT: since all Validations done in SetUp Process ... + // here we only Execute Signal ... + + // + result = isBullish || + isBearish; + + // + if (result) + { + // + conditions.triggerTime = cTime; + conditions.type = isBullish + ? X_POSITION_TYPE_LONG + : X_POSITION_TYPE_SHORT; + + // + } + + // + // Cleanup ... + + // + return result; + } + + /** + * Detect Guards bsed on Signalling Class ... + * + * @param guards: XSTRCCIGuard instance Collection, Holds Provided Guards ... + * @param positions: XPosition instance Collection, Provides Signalling Based Positions for Apply Guards on them ... + * @param provider: X121SMCStrategySignalProviderData instance Reference, Specified Data for Cycles ... + * + * @return ( bool ) + */ + bool DetectGuards( + XSTRCCIGuard &guards[], + const XPosition &positions[] // + ) + { + // + bool result = false; + + // + return result; + } + + /** + * Add Conditions to Conditions Collection if not Exists ... + * + * @param maxAllowed: int, Specified Max Allowed Holding Conditions ... + * + * @return ( int ) + */ + int AddConditionsIfNotExists( + int maxAllowed = 10 // + ) + { + // + int result = 0; + + // + bool isSetuped = IsValid(mConditions.setupTime) && + HasDirection(mConditions.dir); + if (!isSetuped) + { + return result; + } + + // + int count = ArraySize(mConditionsCollection); + if (IsValidSize(count)) + { + // + // Copy Original Items ... + XSTRCCIStrategyConditions tmpItems[]; + Copy( + mConditionsCollection, + tmpItems // + ); + + // + // Prese Item Data ... + bool isBullish = IsBullish(mConditions.dir); + + // + for (int i = 0; i < count; i++) + { + // + XSTRCCIStrategyConditions iItem = tmpItems[i]; + + // + bool canRemove = mConditions.dir == iItem.dir && + mConditions.pivot == iItem.pivot; + if (canRemove) + { + // + ArrayRemove( + mConditionsCollection, + i, + 1 // + ); + } + } + + // + Clean(tmpItems); + } + + // + AddRef( + mConditions, + mConditionsCollection // + ); + + // + // Remove Olds ... + CleanupArray( + mConditionsCollection, + maxAllowed // + ); + + // + result = ArraySize(mConditionsCollection); + + // + return result; } // // Protected ... protected: + // + // // Private ... private: + // + // Props ... + string symbol; + ENUM_TIMEFRAMES period; + CArrayObj mObjects; + CArrayObj mBarObjects; + + /** + * Initialize ... + */ + void Init() + { + // + rfReward = 2; + useGuards = false; + isPassedBoxes = false; + continuesRFTillTarget = true; + + // + inputs.Default(); + + // + // Configure Indicators ... + + // + // XCC ... + inputs.ccInputs.showCandles = true; + + // + // XCT ... + inputs.ctInputs.showCandleTime = true; + + // + // XSTR ... + inputs.strInputs.showStr = true; + inputs.strInputs.showVidya = true; + inputs.strInputs.showStrUpper = false; + inputs.strInputs.showStrLower = false; + inputs.strInputs.showStrSMLow = true; + inputs.strInputs.showStrSMHigh = true; + + // + // XOSCS ... + inputs.oscsInputs.rsiLength = 5; + inputs.oscsInputs.mfiLength = 5; + inputs.oscsInputs.rviLength = 5; + inputs.oscsInputs.cciLength = 5; + + // + // Oscillators Views ... + inputs.showCCI = false; + inputs.showRSI = false; + inputs.showMFI = false; + inputs.showRVI = false; + inputs.showMACD = false; + + // + // XSTRCCI Helper ... + helper = new XCXSTRCCIHelper(); + helper.Init( + symbol, + period, + inputs // + ); + } + + /** + * DeInitialize ... + */ + void DeInit() + { + // + inputs.Clean(); + ZeroMemory(helper); + + // + mConditions.Clean(); + Clean(mConditionsCollection); + + // + mObjects.Clear(); + mBarObjects.Clear(); + } + + // }; // \ No newline at end of file