From d912210e68384539d6b703b52b9226037d3380b7 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Tue, 15 Apr 2025 04:31:43 +0330 Subject: [PATCH] complete XCA Indicator, implements it's Helper and Add all Conditions, and also rename XSTRCCI tProject o XCAEA and only use XCA and XOSC inside it ... --- Documents/BKP/1/signals/2.mq5 | 365 ++ ...xstrcci.ea.mq5 => x-saherelm.xcaea.ea.mq5} | 26 +- Helpers/x-saherelm.x121.xca.helper.mq5 | 3591 +++++++++++++++++ Indicators/x-saherelm.x121.xca.mq5 | 1942 +++++++++ Libraries/x-saherelm.x-enums.lib.mq5 | 22 + Libraries/x-saherelm.x-ohcl.lib.mq5 | 40 + .../Classes/xcaea.x-trade.manager.class.mq5 | 145 +- .../Helpers/xcaea.helper.mq5 | 1800 +++------ .../Libraries/xcaea.signaller.lib.mq5 | 132 +- .../Signals/xcaea.signaller.class.mq5 | 106 +- cleanupEX.js | 1 + 11 files changed, 6725 insertions(+), 1445 deletions(-) rename Experts/{x-saherelm.xstrcci.ea.mq5 => x-saherelm.xcaea.ea.mq5} (96%) create mode 100644 Helpers/x-saherelm.x121.xca.helper.mq5 create mode 100644 Indicators/x-saherelm.x121.xca.mq5 rename XSTRCCI/Classes/xstrcci.x-trade.manager.class.mq5 => XCAEA/Classes/xcaea.x-trade.manager.class.mq5 (73%) rename XSTRCCI/Helpers/xstrcci.helper.mq5 => XCAEA/Helpers/xcaea.helper.mq5 (61%) rename XSTRCCI/Libraries/xstrcci.signaller.lib.mq5 => XCAEA/Libraries/xcaea.signaller.lib.mq5 (76%) rename XSTRCCI/Signals/xstrcci.signaller.class.mq5 => XCAEA/Signals/xcaea.signaller.class.mq5 (83%) diff --git a/Documents/BKP/1/signals/2.mq5 b/Documents/BKP/1/signals/2.mq5 index d69c8d28..4d60af7c 100644 --- a/Documents/BKP/1/signals/2.mq5 +++ b/Documents/BKP/1/signals/2.mq5 @@ -1801,6 +1801,371 @@ bool IsFVGBoxValid( } ///////////////////////////////////////////////////////// +// + +bool DetectXCAEAConditions( + XCAEAConditions &conditions, + XBoxZone &box, + ENUM_X_DIRECTION &dir, + XCXCAEAHelper *helper, + int barIndex = 0, + int loopback = 10 // +) +{ + // + bool result = false; + + // + box.Clean(); + conditions.Clean(); + dir = X_DIRECTION_NONE; + + // + if (barIndex < 0) + { + barIndex = 0; + } + loopback = NormalizeInt(loopback, 5); + + // + string symbol = helper.GetSymbol(); + ENUM_TIMEFRAMES period = helper.GetPeriod(); + + // + result = helper.GetConditions( + conditions, + barIndex, + loopback // + ); + if (!result) + { + // + conditions.Clean(); + return result; + } + + // + int zIDX = barIndex; + int cIDX = zIDX + 1; + int pIDX = cIDX + 1; + int ppIDX = pIDX + 1; + int p3IDX = ppIDX + 1; + int p4IDX = p3IDX + 1; + + // + XOHCL zBar; + XOHCL cBar; + XOHCL pBar; + XOHCL ppBar; + XOHCL p3Bar; + XOHCL p4Bar; + result = zBar.Init( + symbol, + period, + zIDX // + ); + result = + result && + zBar.GetPreviousBar(cBar); + result = + result && + cBar.GetPreviousBar(pBar); + result = + result && + pBar.GetPreviousBar(ppBar); + result = + result && + ppBar.GetPreviousBar(p3Bar); + result = + result && + p3Bar.GetPreviousBar(p4Bar); + if (!result) + { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + ppBar.Clean(); + p3Bar.Clean(); + p4Bar.Clean(); + + // + box.Clean(); + conditions.Clean(); + + // + return result; + } + + // + // Bars Conditions ... + + // + ENUM_X_DIRECTION cBarDir; + + // + // Hammer ... + bool isCBarHammer = helper + .barAnalyser + .IsHammer( + cBar, + cBarDir // + ); + bool isCBarBullishHammer = + isCBarHammer && + IsBullish(cBarDir); + bool isCBarBearishHammer = + isCBarHammer && + IsBearish(cBarDir); + + // + // Rejected ... + bool isCBarRejected = helper + .barAnalyser + .IsRejected( + cBar, + cBarDir, + false, // Force Type ... + true // Force Fibo Pressure ... + ); + bool isCBarBullishRejected = + isCBarRejected && + IsBullish(cBarDir); + bool isCBarBearishRejected = + isCBarRejected && + IsBearish(cBarDir); + + // + // Engulfed ... + bool isCBarEngulfed = helper + .barAnalyser + .IsEngulfed( + cBar, + cBarDir // + ); + bool isCBarBullishEngulfed = + isCBarEngulfed && + IsBullish(cBarDir); + bool isCBarBearishEngulfed = + isCBarEngulfed && + IsBearish(cBarDir); + + // + // Momentum ... + bool isCBarMomentum = helper + .barAnalyser + .IsMomentum( + cBar, + cBarDir, + 1 // + ); + bool isCBarBullishMomentum = + isCBarMomentum && + IsBullish(cBarDir); + bool isCBarBearishMomentum = + isCBarMomentum && + IsBearish(cBarDir); + + // + // Bar Sumarise ... + + // + bool isCBarValidForBullish = + (isCBarBullishHammer || + isCBarBullishRejected || + isCBarBullishMomentum || + isCBarBullishEngulfed); + + // + bool isCBarValidForBearish = + (isCBarBearishHammer || + isCBarBearishRejected || + isCBarBearishMomentum || + isCBarBearishEngulfed); + + // + // Conditions ... + + // + bool isLowsUnderValesGolden = + // + pBar.low < conditions.valesGoldenBuffer[pIDX] && + ppBar.low < conditions.valesGoldenBuffer[ppIDX] && + p3Bar.low < conditions.valesGoldenBuffer[p3IDX] && + p4Bar.low < conditions.valesGoldenBuffer[p4IDX] + // + ; + + // + bool isHighsOverPeaksGolden = + // + pBar.high > conditions.peaksGoldenBuffer[pIDX] && + ppBar.high > conditions.peaksGoldenBuffer[ppIDX] && + p3Bar.high > conditions.peaksGoldenBuffer[p3IDX] && + p4Bar.high > conditions.peaksGoldenBuffer[p4IDX] + // + ; + + // + bool isSwingLowSameAsVale = + conditions.swingLowsBuffer[p4IDX] == conditions.valesBuffer[p4IDX]; + + // + bool isSwingHighSameAsPeak = + conditions.swingHighsBuffer[p4IDX] == conditions.peaksBuffer[p4IDX]; + + // + bool isStrSame = conditions.strBuffer[cIDX] == conditions.strBuffer[pIDX] && + conditions.strBuffer[pIDX] == conditions.strBuffer[ppIDX]; + + // + bool isSameStrBreakedUp = + isStrSame && + conditions.strBuffer[zIDX] > conditions.strBuffer[cIDX]; + + // + bool isSameStrBreakedDown = + isStrSame && + conditions.strBuffer[zIDX] < conditions.strBuffer[cIDX]; + + // + bool isStrBullishVPattern = + // + conditions.strStateBuffer[zIDX] > 0 && + conditions.strStateBuffer[cIDX] > 0 && + conditions.strStateBuffer[pIDX] > 0 && + conditions.strBuffer[pIDX] < conditions.strBuffer[ppIDX] && + conditions.strBuffer[pIDX] < conditions.strBuffer[cIDX] && + conditions.strBuffer[pIDX] < conditions.strBuffer[zIDX] && + conditions.strBuffer[zIDX] > conditions.strBuffer[cIDX] + // + ; + + // + bool isStrBearishVPattern = + // + conditions.strStateBuffer[zIDX] < 0 && + conditions.strStateBuffer[cIDX] < 0 && + conditions.strStateBuffer[pIDX] < 0 && + conditions.strBuffer[pIDX] > conditions.strBuffer[ppIDX] && + conditions.strBuffer[pIDX] > conditions.strBuffer[cIDX] && + conditions.strBuffer[pIDX] > conditions.strBuffer[zIDX] && + conditions.strBuffer[zIDX] < conditions.strBuffer[cIDX] + // + ; + + // + bool isCBarLowInTKZone = + // + cBar.low < conditions.tenkanSenBuffer[cIDX] && + cBar.low > conditions.kijunSenBuffer[cIDX] + // + ; + + // + bool isCBarHighInTKZone = + // + cBar.high > conditions.tenkanSenBuffer[cIDX] && + cBar.high < conditions.kijunSenBuffer[cIDX] + // + ; + + // + // Summarise Conditions ... + + // + bool isBullish = + // + isCBarLowInTKZone && + isCBarBullishRejected && + isCBarValidForBullish && + conditions.isX3MaSlowBullish && + conditions.isTenkanSenOverKijunSen && + conditions.kijunSenBuffer[cIDX] > conditions.x3maSlowBuffer[cIDX] + // + ; + + // + bool isBearish = + // + isCBarHighInTKZone && + isCBarBearishRejected && + isCBarValidForBearish && + conditions.isX3MaSlowBearish && + conditions.isTenkanSenUnderKijunSen && + conditions.kijunSenBuffer[cIDX] < conditions.x3maSlowBuffer[cIDX] + // + ; + + // + result = isBullish || + isBearish; + if (result) + { + // + dir = + isBullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + + // + double entry = GetEntry( + conditions.symbol, + dir // + ); + double sl = conditions.kijunSenBuffer[cIDX]; + + // + box.dir = dir; + box.symbol = conditions.symbol; + box.period = conditions.period; + + // + box.upper = + isBullish + ? entry + : sl; + + // + box.lower = + isBullish + ? sl + : entry; + + // + box.to = zBar.time; + box.from = p4Bar.time; + + // + box.type = ToString(dir) + "_Signal_" + conditions.symbol + "_" + ToString(conditions.period); + } + + // + result = box.IsValid() && + HasDirection(dir); + + // + // Cleanup Resources ... + + // + if (!result) + { + // + box.Clean(); + conditions.Clean(); + } + + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + ppBar.Clean(); + p3Bar.Clean(); + p4Bar.Clean(); + + // + return result; +} ///////////////////////////////////////////////////////// diff --git a/Experts/x-saherelm.xstrcci.ea.mq5 b/Experts/x-saherelm.xcaea.ea.mq5 similarity index 96% rename from Experts/x-saherelm.xstrcci.ea.mq5 rename to Experts/x-saherelm.xcaea.ea.mq5 index 90c15f8f..bd643f44 100644 --- a/Experts/x-saherelm.xstrcci.ea.mq5 +++ b/Experts/x-saherelm.xcaea.ea.mq5 @@ -2,7 +2,7 @@ // // SaherElm IT Center XTest MQL5 Expert Advisor // ------------------------------------------------- -// Name: XSTRCCIEA +// Name: XCAEA // Description: an Exper Advisor which used Panels // // Maintainer: @@ -15,7 +15,7 @@ #property copyright "Copyright 2023, SaherElm IT Center" #property link "https://saherelm.ir" #property version "1.00" -#property description "SaherElm XSTRCCIEA" +#property description "SaherElm XCAEA EA" #property strict // @@ -23,11 +23,11 @@ #include "../Classes/x-saherelm.x-alert.class.mq5" #include "../Classes/x-saherelm.x-trade.class.mq5" #include "../Classes/x-saherelm.x-volume.class.mq5" -#include "../XSTRCCI/Classes/xstrcci.x-trade.manager.class.mq5" -#include "../XSTRCCI/Signals/xstrcci.signaller.class.mq5" +#include "../XCAEA/Classes/xcaea.x-trade.manager.class.mq5" +#include "../XCAEA/Signals/xcaea.signaller.class.mq5" // -#define ShortName "XSTRCCIEA" +#define ShortName "XCAEAEA" // // Inputs ... @@ -73,13 +73,11 @@ input bool eaReportNewHours = false; // Report New Hours // Variables, Instances ... XCAlert *eaAlert; XCTrade *eaTrade; -XCVolume *eaVolume; -XCXSTRCCITradeManager *eaTradeManager; - -// XSignal eaSignal; -XCXSTRCCISignaller *eaSignaller; -XSTRCCIStrategyConditions eaConditions; +XCVolume *eaVolume; +XCXCAEASignaller *eaSignaller; +XCXCAEATradeManager *eaTradeManager; +XCAEAStrategyConditions eaConditions; // int eaMaxAllowedPositions = 5; @@ -176,7 +174,7 @@ void OnTick() // double r2r = 5; - string provider = "XSTRCCI"; + string provider = "XCAEA"; ENUM_POSITION_TYPE type = POSITION_TYPE_BUY; ENUM_X_ORDER_MODES mode = X_ORDER_MODE_MARKET; @@ -603,7 +601,7 @@ void InitRequirements() // // EA Trae Manager ... - eaTradeManager = new XCXSTRCCITradeManager( + eaTradeManager = new XCXCAEATradeManager( eaTrade // ); eaTradeManager.SetAlertEnableAlerts(eaEnableAlerts); @@ -615,7 +613,7 @@ void InitRequirements() // // EA Signaller ... - eaSignaller = new XCXSTRCCISignaller( + eaSignaller = new XCXCAEASignaller( _Symbol, _Period // ); diff --git a/Helpers/x-saherelm.x121.xca.helper.mq5 b/Helpers/x-saherelm.x121.xca.helper.mq5 new file mode 100644 index 00000000..7933fb1b --- /dev/null +++ b/Helpers/x-saherelm.x121.xca.helper.mq5 @@ -0,0 +1,3591 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 Helper Class Library +// ---------------------------------------------- +// Name: XCX121XCAHelper +// Description: provides all Indicator +// Helper requirements ... +// +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// +// +// Global Properties ... +#property library +#property copyright "Copyright 2023, SaherElm IT Center" +#property link "https://www.saherelm.ir" +#property version "1.00" +#property strict + +// +// Imports ... +#include "../Classes/x-saherelm.x-helper.class.mq5" + +// +// Definitions ... + +// +// Definitions ... +enum ENUM_X121_XCA_BUFFERS +{ + // + X121_XCA_S_HH_LINE = 0, + X121_XCA_S_LL_LINE = 1, + X121_XCA_M_HH_LINE = 2, + X121_XCA_M_LL_LINE = 3, + X121_XCA_L_HH_LINE = 4, + X121_XCA_L_LL_LINE = 5, + X121_XCA_H_HH_LINE = 6, + X121_XCA_H_LL_LINE = 7, + X121_XCA_SUPPORT_LINE = 8, + X121_XCA_RESISTANCE_LINE = 9, + X121_XCA_PEAK_LINE = 10, + X121_XCA_PEAK_GOLDEN_LINE = 11, + X121_XCA_VALE_LINE = 12, + X121_XCA_VALE_GOLDEN_LINE = 13, + X121_XCA_FIBO_L1_LINE = 14, + X121_XCA_FIBO_L2_LINE = 15, + X121_XCA_FIBO_L3_LINE = 16, + X121_XCA_SAR_LINE = 17, + X121_XCA_TREND_LINE = 18, + X121_XCA_TREND_STATE_LINE = 24, + X121_XCA_KI_LINE = 20, + X121_XCA_KI_STATE_LINE = 25, + X121_XCA_SWING_LOW_LINE = 22, + X121_XCA_SWING_HIGH_LINE = 23, +}; + +// +// Input Models ... +struct X121XCAInputs +{ + // + // Props ... + + // + // Market ... + + // + // Short ... + ENUM_X_PERIOD_METHOD scMethod; // How to Find Period + ENUM_TIMEFRAMES scPeriod; // Time Period + + // + // Medium ... + ENUM_X_PERIOD_METHOD mcMethod; // How to Find Period + ENUM_TIMEFRAMES mcPeriod; // Time Period + + // + // Long ... + ENUM_X_PERIOD_METHOD lcMethod; // How to Find Period + ENUM_TIMEFRAMES lcPeriod; // Time Period + + // + // Hind ... + ENUM_X_PERIOD_METHOD hcMethod; // How to Find Period + ENUM_TIMEFRAMES hcPeriod; // Time Period + + // + // Boundary Detection ... + ENUM_SERIESMODE hhMode; // Highest High Calculation Method + ENUM_SERIESMODE llMode; // Lowest Low Calculation Method + ENUM_X_FIBO_LEVELS goldenZoneLevel; // Golden Zone Detection + + // + // Fibo Levels ... + ENUM_X_FIBO_LEVELS fiboLevel1; // Fibo Level 1 + ENUM_X_FIBO_LEVELS fiboLevel2; // Fibo Level 2 + ENUM_X_FIBO_LEVELS fiboLevel3; // Fibo Level 3 + + // + // Sar Detection ... + double sarStep; // Step + double sarMax; // Maximum + + // + // KI ... + int kiLength; // KI Length + + // + // Swing Detection ... + int swingLength; // Length + + // + // Support and Resistance ... + int supResSmoothingLength; // Smoothing Length + ENUM_X_MA_METHOD supResSmoothingMode; // Smoothing Method + + // + // Presentation ... + + // + int startCalculationForLastBars; // Calculate Last n Bars + + // + bool showSar; // Show Sar + bool showKI; // Show KI + bool showTrend; // Show Trend + bool showSwings; // Show Swings + bool showFiboLevel1; // Show Fibo Level 1 + bool showFiboLevel2; // Show Fibo Level 2 + bool showFiboLevel3; // Show Fibo Level 3 + bool showPeaksAndVales; // Show Peaks And Vales + bool showPeakAndValeGolden; // Show Peak and Vale Golden + bool showSupportAndResistance; // Show Support and Resistance + bool showShortCycle; // Show Short Cycle + bool showMediumCycle; // Show Medium Cycle + bool showLongCycle; // Show Long Cycle + bool showHindCycle; // Show Hind Cycle + + // + int sarArrowCode; // Parabolic Sar Arrow Code + int peakArrowCode; // Peaks Arrow Code + int valeArrowCode; // Vales Arrow Code + int swingLowArrowCode; // Swing Low Arrow Code + int swingHighArrowCode; // Swing High Arrow Code + + // + // Constructor(s) ... + X121XCAInputs() + { + // + Clean(); + } + + // + // Tools ... + + // + // Clean ... + void Clean() + { + // + // Market ... + + // + // Short ... + scMethod = X_PERIOD_AUTO; // How to Find Period + scPeriod = NULL; // Time Period + + // + // Medium ... + mcMethod = X_PERIOD_AUTO; // How to Find Period + mcPeriod = NULL; // Time Period + + // + // Long ... + lcMethod = X_PERIOD_AUTO; // How to Find Period + lcPeriod = NULL; // Time Period + + // + // Hind ... + hcMethod = X_PERIOD_AUTO; // How to Find Period + hcPeriod = NULL; // Time Period + + // + // Boundary Detection ... + hhMode = MODE_HIGH; // Highest High Calculation Method + llMode = MODE_LOW; // Lowest Low Calculation Method + + // + // Fibo Levels ... + fiboLevel1 = X_FIBO_LEVEL_236; // Fibo Level 1 + fiboLevel2 = X_FIBO_LEVEL_500; // Fibo Level 2 + fiboLevel3 = X_FIBO_LEVEL_764; // Fibo Level 3 + + // + // Sar Detection ... + sarStep = 0; // Step + sarMax = 0; // Maximum + + // + // KI ... + kiLength = 0; // KI Length + + // + // Swing Detection ... + swingLength = 0; // Length + + // + // Support and Resistance ... + supResSmoothingLength = 0; // Smoothing Length + supResSmoothingMode = X_MA_MODE_NONE; // Smoothing Method + + // + // Presentation ... + + // + startCalculationForLastBars = 0; // Calculate Last n Bars + + // + showSar = true; // Show Sar + showKI = true; // Show KI + showTrend = true; // Show Trend + showSwings = true; // Show Swings + showFiboLevel1 = true; // Show Fibo Level 1 + showFiboLevel2 = true; // Show Fibo Level 2 + showFiboLevel3 = true; // Show Fibo Level 3 + showPeaksAndVales = true; // Show Peaks And Vales + showPeakAndValeGolden = true; // Show Peak and Vale Golden + showSupportAndResistance = true; // Show Support and Resistance + showShortCycle = true; // Show Short Cycle + showMediumCycle = true; // Show Medium Cycle + showLongCycle = true; // Show Long Cycle + showHindCycle = true; // Show Hind Cycle + + // + sarArrowCode = 0; // Parabolic Sar Arrow Code + peakArrowCode = 0; // Peaks Arrow Code + valeArrowCode = 0; // Vales Arrow Code + swingLowArrowCode = 0; // Swing Low Arrow Code + swingHighArrowCode = 0; // Swing High Arrow Code + + // + ZeroMemory(this); + } + + // + // Default ... + void Default() + { + // + // Market ... + + // + // Short ... + scMethod = X_PERIOD_AUTO; // How to Find Period + scPeriod = NULL; // Time Period + + // + // Medium ... + mcMethod = X_PERIOD_AUTO; // How to Find Period + mcPeriod = NULL; // Time Period + + // + // Long ... + lcMethod = X_PERIOD_AUTO; // How to Find Period + lcPeriod = NULL; // Time Period + + // + // Hind ... + hcMethod = X_PERIOD_AUTO; // How to Find Period + hcPeriod = NULL; // Time Period + + // + // Boundary Detection ... + hhMode = MODE_HIGH; // Highest High Calculation Method + llMode = MODE_LOW; // Lowest Low Calculation Method + + // + // Fibo Levels ... + fiboLevel1 = X_FIBO_LEVEL_236; // Fibo Level 1 + fiboLevel2 = X_FIBO_LEVEL_500; // Fibo Level 2 + fiboLevel3 = X_FIBO_LEVEL_764; // Fibo Level 3 + + // + // Sar Detection ... + sarStep = 0.02; // Step + sarMax = 0.2; // Maximum + + // + // KI ... + kiLength = 26; // KI Length + + // + // Swing Detection ... + swingLength = 5; // Length + + // + // Presentation ... + + // + startCalculationForLastBars = 1000; // Calculate Last n Bars + + // + showSar = true; // Show Sar + showKI = true; // Show KI + showTrend = true; // Show Trend + showSwings = true; // Show Swings + showFiboLevel1 = true; // Show Fibo Level 1 + showFiboLevel2 = true; // Show Fibo Level 2 + showFiboLevel3 = true; // Show Fibo Level 3 + showPeaksAndVales = true; // Show Peaks And Vales + showPeakAndValeGolden = true; // Show Peak and Vale Golden + showSupportAndResistance = true; // Show Support and Resistance + showShortCycle = true; // Show Short Cycle + showMediumCycle = true; // Show Medium Cycle + showLongCycle = true; // Show Long Cycle + showHindCycle = true; // Show Hind Cycle + + // + sarArrowCode = 159; // Parabolic Sar Arrow Code + peakArrowCode = 159; // Peaks Arrow Code + valeArrowCode = 159; // Vales Arrow Code + swingLowArrowCode = 225; // Swing Low Arrow Code + swingHighArrowCode = 226; // Swing High Arrow Code + } + + // + // Validate ... + bool IsValid() + { + // + bool result = false; + + // + result = + // + // SAR ... + sarMax > 0 && + sarStep > 0 && + kiLength > 0 && + swingLength > 0 && + sarMax > sarStep && + // + // XCA ... + (IsValid(scMethod, scPeriod) && + IsValid(mcMethod, mcPeriod) && + IsValid(lcMethod, lcPeriod) && + IsValid(hcMethod, hcPeriod)) + // + ; + + // + return result; + } + + // + // Retrieve MAx Length ... + int Max() + { + // + int result = 0; + + // + result = MathMax(kiLength, swingLength); + + // + return result; + } +}; + +// +// Conditions ... +struct X121XCAConditions +{ + // + // Common ... + string symbol; + ENUM_TIMEFRAMES period; + datetime time; + + // + // Buffers ... + double kiBuffer[]; + double sHHBuffer[]; + double sLLBuffer[]; + double mHHBuffer[]; + double mLLBuffer[]; + double lHHBuffer[]; + double lLLBuffer[]; + double hHHBuffer[]; + double hLLBuffer[]; + double sarBuffer[]; + double peakBuffer[]; + double valeBuffer[]; + double trendBuffer[]; + double kiStateBuffer[]; + double supportBuffer[]; + double swingLowBuffer[]; + double swingHighBuffer[]; + double resistanceBuffer[]; + double peakGoldenBuffer[]; + double valeGoldenBuffer[]; + double fiboLevel1Buffer[]; + double fiboLevel2Buffer[]; + double fiboLevel3Buffer[]; + double trendStateBuffer[]; + + // + // Conditions ... + + // + // KI ... + + // + bool isKIRejectUp; + bool isKIRejectDown; + + // + bool isKIBullish; + bool isKIBearish; + + // + bool isKISwitchedToBullish; + bool isKISwitchedToBearish; + + // + // SAR ... + + // + bool isSarBullish; + bool isSarBearish; + + // + bool isSarSwitchedToBullish; + bool isSarSwitchedToBearish; + + // + // PEAK ... + + // + bool isPeakSameLast; + bool isPeakOverLast; + bool isPeakUnderLast; + + // + // VALE ... + + // + bool isValeSameLast; + bool isValeOverLast; + bool isValeUnderLast; + + // + // TREND ... + + // + bool isTrendRejectUp; + bool isTrendRejectDown; + + // + bool isTrendBullish; + bool isTrendBearish; + + // + bool isTrendSwitchedToBullish; + bool isTrendSwitchedToBearish; + + // + // SUPPORT ... + + // + bool isSupportSameLast; + bool isSupportOverLast; + bool isSupportUnderLast; + + // + bool isLastSupportBreaked; + bool isLastSupportRejected; + + // + // RESISTANCE ... + + // + bool isResistanceSameLast; + bool isResistanceOverLast; + bool isResistanceUnderLast; + + // + bool isLastResistanceBreaked; + bool isLastResistanceRejected; + + // + // SWING Low ... + + // + bool isSwingLowSameLast; + bool isSwingLowOverLast; + bool isSwingLowUnderLast; + + // + bool isLastSwingLowBreaked; + bool isLastSwingLowRejected; + + // + // SWING High ... + + // + bool isSwingHighSameLast; + bool isSwingHighOverLast; + bool isSwingHighUnderLast; + + // + bool isLastSwingHighBreaked; + bool isLastSwingHighRejected; + + // + // COMPLEX Conditions ... + + // + bool isPeakIsPivot; + bool isValeIsPivot; + + // + bool isSwingLowSameAsVale; + bool isSwingHighSameAsPeak; + + // + bool isSupportSameAsVale; + bool isResistanceSameAsPeak; + + // + bool isSupportSameAsSwingLow; + bool isResistanceSameAsSwingHigh; + + // + // Constructor ... + X121XCAConditions() + { + Clean(); + } + + // + // Tools ... + + /** + * Cleaning Up ... + */ + void Clean() + { + // + // Commons ... + symbol = NULL; + period = NULL; + time = NULL; + + // + // Buffers ... + + // + Clean(kiBuffer); + Clean(sHHBuffer); + Clean(sLLBuffer); + Clean(mHHBuffer); + Clean(mLLBuffer); + Clean(lHHBuffer); + Clean(lLLBuffer); + Clean(hHHBuffer); + Clean(hLLBuffer); + Clean(sarBuffer); + Clean(peakBuffer); + Clean(valeBuffer); + Clean(trendBuffer); + Clean(kiStateBuffer); + Clean(supportBuffer); + Clean(swingLowBuffer); + Clean(swingHighBuffer); + Clean(resistanceBuffer); + Clean(peakGoldenBuffer); + Clean(valeGoldenBuffer); + Clean(fiboLevel1Buffer); + Clean(fiboLevel2Buffer); + Clean(fiboLevel3Buffer); + Clean(trendStateBuffer); + + // + ArraySetAsSeries(kiBuffer, true); + ArraySetAsSeries(sHHBuffer, true); + ArraySetAsSeries(sLLBuffer, true); + ArraySetAsSeries(mHHBuffer, true); + ArraySetAsSeries(mLLBuffer, true); + ArraySetAsSeries(lHHBuffer, true); + ArraySetAsSeries(lLLBuffer, true); + ArraySetAsSeries(hHHBuffer, true); + ArraySetAsSeries(hLLBuffer, true); + ArraySetAsSeries(sarBuffer, true); + ArraySetAsSeries(peakBuffer, true); + ArraySetAsSeries(valeBuffer, true); + ArraySetAsSeries(trendBuffer, true); + ArraySetAsSeries(kiStateBuffer, true); + ArraySetAsSeries(supportBuffer, true); + ArraySetAsSeries(swingLowBuffer, true); + ArraySetAsSeries(swingHighBuffer, true); + ArraySetAsSeries(resistanceBuffer, true); + ArraySetAsSeries(peakGoldenBuffer, true); + ArraySetAsSeries(valeGoldenBuffer, true); + ArraySetAsSeries(fiboLevel1Buffer, true); + ArraySetAsSeries(fiboLevel2Buffer, true); + ArraySetAsSeries(fiboLevel3Buffer, true); + ArraySetAsSeries(trendStateBuffer, true); + + // + // Conditions ... + + // + // KI ... + + // + isKIRejectUp = false; + isKIRejectDown = false; + + // + isKIBullish = false; + isKIBearish = false; + + // + isKISwitchedToBullish = false; + isKISwitchedToBearish = false; + + // + // SAR ... + + // + isSarBullish = false; + isSarBearish = false; + + // + isSarSwitchedToBullish = false; + isSarSwitchedToBearish = false; + + // + // PEAK ... + + // + isPeakSameLast = false; + isPeakOverLast = false; + isPeakUnderLast = false; + + // + // VALE ... + + // + isValeSameLast = false; + isValeOverLast = false; + isValeUnderLast = false; + + // + // TREND ... + + // + isTrendRejectUp = false; + isTrendRejectDown = false; + + // + isTrendBullish = false; + isTrendBearish = false; + + // + isTrendSwitchedToBullish = false; + isTrendSwitchedToBearish = false; + + // + // SUPPORT ... + + // + isSupportSameLast = false; + isSupportOverLast = false; + isSupportUnderLast = false; + + // + isLastSupportBreaked = false; + isLastSupportRejected = false; + + // + // RESISTANCE ... + + // + isResistanceSameLast = false; + isResistanceOverLast = false; + isResistanceUnderLast = false; + + // + isLastResistanceBreaked = false; + isLastResistanceRejected = false; + + // + // SWING Low ... + + // + isSwingLowSameLast = false; + isSwingLowOverLast = false; + isSwingLowUnderLast = false; + + // + isLastSwingLowBreaked = false; + isLastSwingLowRejected = false; + + // + // SWING High ... + + // + isSwingHighSameLast = false; + isSwingHighOverLast = false; + isSwingHighUnderLast = false; + + // + isLastSwingHighBreaked = false; + isLastSwingHighRejected = false; + + // + // COMPLEX Conditions ... + + // + isPeakIsPivot = false; + isValeIsPivot = false; + + // + isSwingLowSameAsVale = false; + isSwingHighSameAsPeak = false; + + // + isSupportSameAsVale = false; + isResistanceSameAsPeak = false; + + // + isSupportSameAsSwingLow = false; + isResistanceSameAsSwingHigh = false; + + // + ZeroMemory(this); + } + + /** + * Generate Conditions Scores ... + * + * @param bullishScore: Double, Directional Scores Reference ... + * @param bearishScore: Double, Directional Scores Reference ... + */ + void GenerateScore( + double &bullishScore, + double &bearishScore // + ) + { + // + bullishScore = 0; + bearishScore = 0; + + // + double score = 1; + double minScore = 0.5; + double highScore = 1.5; + + // + // KI ... + + // + if (isKIBullish) + { + bullishScore += minScore; + } + if (isKIRejectUp) + { + bullishScore += minScore; + } + if (isKISwitchedToBullish) + { + bullishScore += minScore; + } + + // + if (isKIBearish) + { + bearishScore += minScore; + } + if (isKIRejectDown) + { + bearishScore += minScore; + } + if (isKISwitchedToBearish) + { + bearishScore += minScore; + } + + // + // SAR ... + + // + if (isSarBullish) + { + bullishScore += minScore; + } + if (isSarSwitchedToBullish) + { + bullishScore += minScore; + } + + // + if (isSarBearish) + { + bearishScore += minScore; + } + if (isSarSwitchedToBearish) + { + bearishScore += minScore; + } + + // + // TREND ... + + // + if (isTrendBullish) + { + bullishScore += minScore; + } + if (isTrendRejectUp) + { + bullishScore += minScore; + } + if (isTrendSwitchedToBullish) + { + bullishScore += minScore; + } + + // + if (isTrendBearish) + { + bearishScore += minScore; + } + if (isTrendRejectDown) + { + bearishScore += minScore; + } + if (isTrendSwitchedToBearish) + { + bearishScore += minScore; + } + + // + // SUPPORT ... + + // + if (isSupportSameLast) + { + bullishScore += minScore; + } + if (isSupportOverLast) + { + bullishScore += minScore; + } + if (isLastSupportRejected) + { + bullishScore += minScore; + } + + // + if (isSupportUnderLast) + { + bearishScore += minScore; + } + if (isLastSupportBreaked) + { + bearishScore += minScore; + } + + // + // RESISTANCE ... + + // + if (isResistanceOverLast) + { + bullishScore += minScore; + } + if (isLastResistanceBreaked) + { + bullishScore += minScore; + } + + // + if (isResistanceSameLast) + { + bearishScore += minScore; + } + if (isResistanceUnderLast) + { + bearishScore += minScore; + } + if (isLastResistanceRejected) + { + bearishScore += minScore; + } + + // + // SWING Low ... + + // + if (isSwingLowSameLast) + { + bullishScore += minScore; + } + if (isSwingLowOverLast) + { + bullishScore += minScore; + } + if (isLastSwingLowRejected) + { + bullishScore += minScore; + } + + // + if (isSwingLowUnderLast) + { + bearishScore += minScore; + } + if (isLastSwingLowBreaked) + { + bearishScore += minScore; + } + + // + // SWING High ... + + // + if (isSwingHighOverLast) + { + bullishScore += minScore; + } + if (isLastSwingHighBreaked) + { + bullishScore += minScore; + } + + // + if (isSwingHighSameLast) + { + bearishScore += minScore; + } + if (isSwingHighUnderLast) + { + bearishScore += minScore; + } + if (isLastSwingHighRejected) + { + bearishScore += minScore; + } + + // + // COMPLEX Conditions ... + + // + if (isValeIsPivot) + { + bullishScore += score; + } + if (isSupportSameAsVale) + { + bullishScore += score; + } + if (isSwingLowSameAsVale) + { + bullishScore += score; + } + if (isSupportSameAsSwingLow) + { + bullishScore += score; + } + + // + if (isPeakIsPivot) + { + bearishScore += score; + } + if (isSwingHighSameAsPeak) + { + bearishScore += score; + } + if (isResistanceSameAsPeak) + { + bearishScore += score; + } + if (isResistanceSameAsSwingHigh) + { + bearishScore += score; + } + + // + } + + /** + * Generate Summary String for Represent Conditions State ... + * + * @param onlyCommons: Boolean, Just Generate Only Commons Conditions ... + * @param onlyConditions: Boolean, Just Generate Only Conditions ... + * @param includeScores: Boolean, Attach Scores Representations on Result ... + * @param ignoreFalseConditions: Boolean, Ignore False Conditions on Result ... + * @param separator: String, Separate Lines ... + * + * @return ( string ) + */ + string GenerateSummary( + bool onlyCommons = false, + bool onlyConditions = false, + bool includeScores = true, + bool ignoreFalseConditions = true, + string separator = "\n" // + ) + { + // + string result = NULL; + + // + double bullishScore = 0; + double bearishScore = 0; + GenerateScore( + bullishScore, + bearishScore // + ); + + // + string scoresStr = + // + "Scores: " + separator + + "---------------" + separator + + "Bullish: " + ToString(bullishScore) + separator + + "Bearish: " + ToString(bearishScore) + separator + + "" + // + ; + + // + string commonStr = GenerateSpecifiedCommonSummary( + this, + separator, + includeScores // + ); + + // + string conditionsStr = + // + "-----------------------" + separator + + "XCA: " + separator + + "-----------------------" + separator + + ToString("isKIRejectUp", isKIRejectUp, ignoreFalseConditions, separator) + + ToString("isKIRejectDown", isKIRejectDown, ignoreFalseConditions, separator) + + ToString("isKIBullish", isKIBullish, ignoreFalseConditions, separator) + + ToString("isKIBearish", isKIBearish, ignoreFalseConditions, separator) + + ToString("isKISwitchedToBullish", isKISwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isKISwitchedToBearish", isKISwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isSarBullish", isSarBullish, ignoreFalseConditions, separator) + + ToString("isSarBearish", isSarBearish, ignoreFalseConditions, separator) + + ToString("isSarSwitchedToBullish", isSarSwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isSarSwitchedToBearish", isSarSwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isPeakSameLast", isPeakSameLast, ignoreFalseConditions, separator) + + ToString("isPeakOverLast", isPeakOverLast, ignoreFalseConditions, separator) + + ToString("isPeakUnderLast", isPeakUnderLast, ignoreFalseConditions, separator) + + ToString("isValeSameLast", isValeSameLast, ignoreFalseConditions, separator) + + ToString("isValeOverLast", isValeOverLast, ignoreFalseConditions, separator) + + ToString("isValeUnderLast", isValeUnderLast, ignoreFalseConditions, separator) + + ToString("isTrendRejectUp", isTrendRejectUp, ignoreFalseConditions, separator) + + ToString("isTrendRejectDown", isTrendRejectDown, ignoreFalseConditions, separator) + + ToString("isTrendBullish", isTrendBullish, ignoreFalseConditions, separator) + + ToString("isTrendBearish", isTrendBearish, ignoreFalseConditions, separator) + + ToString("isTrendSwitchedToBullish", isTrendSwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isTrendSwitchedToBearish", isTrendSwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isSupportSameLast", isSupportSameLast, ignoreFalseConditions, separator) + + ToString("isSupportOverLast", isSupportOverLast, ignoreFalseConditions, separator) + + ToString("isSupportUnderLast", isSupportUnderLast, ignoreFalseConditions, separator) + + ToString("isLastSupportBreaked", isLastSupportBreaked, ignoreFalseConditions, separator) + + ToString("isLastSupportRejected", isLastSupportRejected, ignoreFalseConditions, separator) + + ToString("isResistanceSameLast", isResistanceSameLast, ignoreFalseConditions, separator) + + ToString("isResistanceOverLast", isResistanceOverLast, ignoreFalseConditions, separator) + + ToString("isResistanceUnderLast", isResistanceUnderLast, ignoreFalseConditions, separator) + + ToString("isLastResistanceBreaked", isLastResistanceBreaked, ignoreFalseConditions, separator) + + ToString("isLastResistanceRejected", isLastResistanceRejected, ignoreFalseConditions, separator) + + ToString("isSwingLowSameLast", isSwingLowSameLast, ignoreFalseConditions, separator) + + ToString("isSwingLowOverLast", isSwingLowOverLast, ignoreFalseConditions, separator) + + ToString("isSwingLowUnderLast", isSwingLowUnderLast, ignoreFalseConditions, separator) + + ToString("isLastSwingLowBreaked", isLastSwingLowBreaked, ignoreFalseConditions, separator) + + ToString("isLastSwingLowRejected", isLastSwingLowRejected, ignoreFalseConditions, separator) + + ToString("isSwingHighSameLast", isSwingHighSameLast, ignoreFalseConditions, separator) + + ToString("isSwingHighOverLast", isSwingHighOverLast, ignoreFalseConditions, separator) + + ToString("isSwingHighUnderLast", isSwingHighUnderLast, ignoreFalseConditions, separator) + + ToString("isLastSwingHighBreaked", isLastSwingHighBreaked, ignoreFalseConditions, separator) + + ToString("isLastSwingHighRejected", isLastSwingHighRejected, ignoreFalseConditions, separator) + + ToString("isPeakIsPivot", isPeakIsPivot, ignoreFalseConditions, separator) + + ToString("isValeIsPivot", isValeIsPivot, ignoreFalseConditions, separator) + + ToString("isSwingLowSameAsVale", isSwingLowSameAsVale, ignoreFalseConditions, separator) + + ToString("isSwingHighSameAsPeak", isSwingHighSameAsPeak, ignoreFalseConditions, separator) + + ToString("isSupportSameAsVale", isSupportSameAsVale, ignoreFalseConditions, separator) + + ToString("isResistanceSameAsPeak", isResistanceSameAsPeak, ignoreFalseConditions, separator) + + ToString("isSupportSameAsSwingLow", isSupportSameAsSwingLow, ignoreFalseConditions, separator) + + ToString("isResistanceSameAsSwingHigh", isResistanceSameAsSwingHigh, ignoreFalseConditions, separator) + + // + "" + // + ; + + // + result = + // + "[" + GetTag() + "]" + separator + + (onlyConditions + ? "" + : commonStr) + + (!includeScores + ? "" + : scoresStr) + + " " + separator + + (onlyCommons + ? "" + : conditionsStr) + + "" + // + ; + + // + return result; + } + + /** + * Retrieve nique Tag Identifier ... + * + * @return ( string ) + */ + string GetTag() + { + return GetTypeName(this); + } + + // +}; + +// +// Class ... +class XCX121XCAHelper : public XCBaseHelper +{ + // + // Public ... + public: + // + // Props ... + + // + // Constructors ... + XCX121XCAHelper() + : XCBaseHelper(_Symbol, _Period) + { + } + + // + // Deconstructor ... + ~XCX121XCAHelper() + { + // + mInputs.Clean(); + + // + Clean(kiBuffer); + Clean(sHHBuffer); + Clean(sLLBuffer); + Clean(mHHBuffer); + Clean(mLLBuffer); + Clean(lHHBuffer); + Clean(lLLBuffer); + Clean(hHHBuffer); + Clean(hLLBuffer); + Clean(sarBuffer); + Clean(peakBuffer); + Clean(valeBuffer); + Clean(trendBuffer); + Clean(kiStateBuffer); + Clean(supportBuffer); + Clean(swingLowBuffer); + Clean(swingHighBuffer); + Clean(resistanceBuffer); + Clean(peakGoldenBuffer); + Clean(valeGoldenBuffer); + Clean(fiboLevel1Buffer); + Clean(fiboLevel2Buffer); + Clean(fiboLevel3Buffer); + Clean(trendStateBuffer); + } + + // + // Tools ... + bool Init( + string symbol, // Trading Symbol + ENUM_TIMEFRAMES period, // Trading Period + X121XCAInputs &inputs // Inputs + ) + { + // + bool result = false; + + // + mSymbol = symbol; + mPeriod = period; + + // + result = inputs.IsValid(); + if (!result) + { + return result; + } + + // + ArraySetAsSeries(kiBuffer, true); + ArraySetAsSeries(sHHBuffer, true); + ArraySetAsSeries(sLLBuffer, true); + ArraySetAsSeries(mHHBuffer, true); + ArraySetAsSeries(mLLBuffer, true); + ArraySetAsSeries(lHHBuffer, true); + ArraySetAsSeries(lLLBuffer, true); + ArraySetAsSeries(hHHBuffer, true); + ArraySetAsSeries(hLLBuffer, true); + ArraySetAsSeries(sarBuffer, true); + ArraySetAsSeries(peakBuffer, true); + ArraySetAsSeries(valeBuffer, true); + ArraySetAsSeries(trendBuffer, true); + ArraySetAsSeries(kiStateBuffer, true); + ArraySetAsSeries(supportBuffer, true); + ArraySetAsSeries(swingLowBuffer, true); + ArraySetAsSeries(swingHighBuffer, true); + ArraySetAsSeries(resistanceBuffer, true); + ArraySetAsSeries(peakGoldenBuffer, true); + ArraySetAsSeries(valeGoldenBuffer, true); + ArraySetAsSeries(fiboLevel1Buffer, true); + ArraySetAsSeries(fiboLevel2Buffer, true); + ArraySetAsSeries(fiboLevel3Buffer, true); + ArraySetAsSeries(trendStateBuffer, true); + + // + mInputs = inputs; + + // + mHandler = iCustom( + mSymbol, + mPeriod, + "x-saherelm.x121.xca", + "", // Market ... + "", // Short ... + mInputs.scMethod, + mInputs.scPeriod, + "", // Medium ... + mInputs.mcMethod, + mInputs.mcPeriod, + "", // Long ... + mInputs.lcMethod, + mInputs.lcPeriod, + "", // Hind ... + mInputs.hcMethod, + mInputs.hcPeriod, + "", // Boundary Detection ... + mInputs.hhMode, + mInputs.llMode, + "", // Fibo Levels ... + mInputs.fiboLevel1, + mInputs.fiboLevel2, + mInputs.fiboLevel3, + "", // Sar Detection ... + mInputs.sarStep, + mInputs.sarMax, + "", // KI ... + mInputs.kiLength, + "", // Swing Detection ... + mInputs.swingLength, + "", // Support and Resistance ... + mInputs.supResSmoothingLength, + mInputs.supResSmoothingMode, + "", // Presentation ... + mInputs.startCalculationForLastBars, + mInputs.showSar, + mInputs.showKI, + mInputs.showTrend, + mInputs.showSwings, + mInputs.showFiboLevel1, + mInputs.showFiboLevel2, + mInputs.showFiboLevel3, + mInputs.showPeaksAndVales, + mInputs.showPeakAndValeGolden, + mInputs.showSupportAndResistance, + mInputs.showShortCycle, + mInputs.showMediumCycle, + mInputs.showLongCycle, + mInputs.showHindCycle, + // + mInputs.sarArrowCode, + mInputs.peakArrowCode, + mInputs.valeArrowCode, + mInputs.swingLowArrowCode, + mInputs.swingHighArrowCode + // + ); + result = mHandler != INVALID_HANDLE; + if (!result) + { + return result; + } + + // + return result; + } + + // + // Inputs ... + + // + X121XCAInputs GetInputs() + { + return mInputs; + } + + // + bool SetInputs( + X121XCAInputs &inputs // Configs + ) + { + // + return Init( + mSymbol, + mPeriod, + inputs + // + ); + } + + // + // Readers ... + + // + // KI ... + + // + double GetKI( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(barIndex); + + // + int count = ArraySize(kiBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return kiBuffer[barIndex]; + } + + // + int CopyKI( + 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, + kiBuffer, + buffer, + forceClean + // + ); + } + + // + // KI STATE ... + + // + double GetKIState( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(barIndex); + + // + int count = ArraySize(kiStateBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return kiStateBuffer[barIndex]; + } + + // + int CopyKIState( + 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, + kiStateBuffer, + buffer, + forceClean + // + ); + } + + // + // SHORT ... + + // + // HH ... + + // + double GetSHH( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(barIndex); + + // + int count = ArraySize(sHHBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return sHHBuffer[barIndex]; + } + + // + int CopySHH( + 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, + sHHBuffer, + buffer, + forceClean + // + ); + } + + // + // LL ... + + // + double GetSLL( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(barIndex); + + // + int count = ArraySize(sLLBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return sLLBuffer[barIndex]; + } + + // + int CopySLL( + 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, + sLLBuffer, + buffer, + forceClean + // + ); + } + + // + // MEDIUM ... + + // + // HH ... + + // + double GetMHH( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(barIndex); + + // + int count = ArraySize(mHHBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return mHHBuffer[barIndex]; + } + + // + int CopyMHH( + 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, + mHHBuffer, + buffer, + forceClean + // + ); + } + + // + // LL ... + + // + double GetMLL( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(barIndex); + + // + int count = ArraySize(mLLBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return mLLBuffer[barIndex]; + } + + // + int CopyMLL( + 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, + mLLBuffer, + buffer, + forceClean + // + ); + } + + // + // LONG ... + + // + // HH ... + + // + double GetLHH( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(barIndex); + + // + int count = ArraySize(lHHBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return lHHBuffer[barIndex]; + } + + // + int CopyLHH( + 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, + lHHBuffer, + buffer, + forceClean + // + ); + } + + // + // LL ... + + // + double GetLLL( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(barIndex); + + // + int count = ArraySize(lLLBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return lLLBuffer[barIndex]; + } + + // + int CopyLLL( + 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, + lLLBuffer, + buffer, + forceClean + // + ); + } + + // + // HIND ... + + // + // HH ... + + // + double GetHHH( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(barIndex); + + // + int count = ArraySize(hHHBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return hHHBuffer[barIndex]; + } + + // + int CopyHHH( + 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, + hHHBuffer, + buffer, + forceClean + // + ); + } + + // + // LL ... + + // + double GetHLL( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(barIndex); + + // + int count = ArraySize(hLLBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return hLLBuffer[barIndex]; + } + + // + int CopyHLL( + 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, + hLLBuffer, + buffer, + forceClean + // + ); + } + + // + // SAR ... + + // + double GetSar( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(barIndex); + + // + int count = ArraySize(sarBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return sarBuffer[barIndex]; + } + + // + int CopySar( + 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, + sarBuffer, + buffer, + forceClean + // + ); + } + + // + // PEAK ... + + // + double GetPeak( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(barIndex); + + // + int count = ArraySize(peakBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return peakBuffer[barIndex]; + } + + // + int CopyPeak( + 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, + peakBuffer, + buffer, + forceClean + // + ); + } + + // + // PEAK Golden ... + + // + double GetPeakGolden( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(barIndex); + + // + int count = ArraySize(peakGoldenBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return peakGoldenBuffer[barIndex]; + } + + // + int CopyPeakGolden( + 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, + peakGoldenBuffer, + buffer, + forceClean + // + ); + } + + // + // VALE ... + + // + double GetVale( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(barIndex); + + // + int count = ArraySize(valeBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return valeBuffer[barIndex]; + } + + // + int CopyVale( + 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, + valeBuffer, + buffer, + forceClean + // + ); + } + + // + // VALE Golden ... + + // + double GetValeGolden( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(barIndex); + + // + int count = ArraySize(valeGoldenBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return valeGoldenBuffer[barIndex]; + } + + // + int CopyValeGolden( + 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, + valeGoldenBuffer, + buffer, + forceClean + // + ); + } + + // + // TREND ... + + // + double GetTrend( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(barIndex); + + // + int count = ArraySize(trendBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return trendBuffer[barIndex]; + } + + // + int CopyTrend( + 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, + trendBuffer, + buffer, + forceClean + // + ); + } + + // + // TREND ... + + // + double GetTrendState( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(barIndex); + + // + int count = ArraySize(trendStateBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return trendStateBuffer[barIndex]; + } + + // + int CopyTrendState( + 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, + trendStateBuffer, + buffer, + forceClean + // + ); + } + + // + // SUPPORT ... + + // + double GetSupport( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(barIndex); + + // + int count = ArraySize(supportBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return supportBuffer[barIndex]; + } + + // + int CopySupport( + 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, + supportBuffer, + buffer, + forceClean + // + ); + } + + // + // RESISTANCE ... + + // + double GetResistance( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(barIndex); + + // + int count = ArraySize(resistanceBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return resistanceBuffer[barIndex]; + } + + // + int CopyResistance( + 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, + resistanceBuffer, + buffer, + forceClean + // + ); + } + + // + // SWING Low ... + + // + double GetSwingLow( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(barIndex); + + // + int count = ArraySize(swingLowBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return swingLowBuffer[barIndex]; + } + + // + int CopySwingLow( + 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, + swingLowBuffer, + buffer, + forceClean + // + ); + } + + // + // SWING High ... + + // + double GetSwingHigh( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(barIndex); + + // + int count = ArraySize(swingHighBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return swingHighBuffer[barIndex]; + } + + // + int CopySwingHigh( + 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, + swingHighBuffer, + buffer, + forceClean + // + ); + } + + // + // FIBO Level 1 ... + + // + double GetFiboLevel1( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(barIndex); + + // + int count = ArraySize(fiboLevel1Buffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return fiboLevel1Buffer[barIndex]; + } + + // + int CopyFiboLevel1( + 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, + fiboLevel1Buffer, + buffer, + forceClean + // + ); + } + + // + // FIBO Level 2 ... + + // + double GetFiboLevel2( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(barIndex); + + // + int count = ArraySize(fiboLevel2Buffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return fiboLevel2Buffer[barIndex]; + } + + // + int CopyFiboLevel2( + 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, + fiboLevel2Buffer, + buffer, + forceClean + // + ); + } + + // + // FIBO Level 3 ... + + // + double GetFiboLevel3( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(barIndex); + + // + int count = ArraySize(fiboLevel3Buffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return fiboLevel3Buffer[barIndex]; + } + + // + int CopyFiboLevel3( + 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, + fiboLevel3Buffer, + buffer, + forceClean + // + ); + } + + // + void Free() override + { + Cleanup(10); + } + + // + bool GetConditions( + X121XCAConditions &conditions, // + int barIndex = 0, // + int loopback = 5 // + ) + { + // + bool result = true; + + // + if (loopback < 5) + { + loopback = 5; + } + + // + conditions.Clean(); + + // + conditions.symbol = mSymbol; + conditions.period = mPeriod; + conditions.time = TimeCurrent(); + + // + int zIndex = barIndex; + int cIndex = zIndex + 1; + int pIndex = cIndex + 1; + int ppIndex = pIndex + 1; + + // + XOHCL zBar; + result = zBar.Init( + mSymbol, + mPeriod, + zIndex // + ); + if (!result) + { + return result; + } + + // + XOHCL cBar; + result = cBar.Init( + mSymbol, + mPeriod, + cIndex // + ); + if (!result) + { + return result; + } + + // + XOHCL pBar; + result = pBar.Init( + mSymbol, + mPeriod, + pIndex // + ); + if (!result) + { + return result; + } + + // + // Buffers ... + + // + CopyKI( + zIndex, + loopback, + conditions.kiBuffer // + ); + + // + CopyKIState( + zIndex, + loopback, + conditions.kiStateBuffer // + ); + + // + CopySHH( + zIndex, + loopback, + conditions.sHHBuffer // + ); + + // + CopySLL( + zIndex, + loopback, + conditions.sLLBuffer // + ); + + // + CopyMHH( + zIndex, + loopback, + conditions.mHHBuffer // + ); + + // + CopyMLL( + zIndex, + loopback, + conditions.mLLBuffer // + ); + + // + CopyLHH( + zIndex, + loopback, + conditions.lHHBuffer // + ); + + // + CopyLLL( + zIndex, + loopback, + conditions.lLLBuffer // + ); + + // + CopyHHH( + zIndex, + loopback, + conditions.hHHBuffer // + ); + + // + CopyHLL( + zIndex, + loopback, + conditions.hLLBuffer // + ); + + // + CopySar( + zIndex, + loopback, + conditions.sarBuffer // + ); + + // + CopyPeak( + zIndex, + loopback, + conditions.peakBuffer // + ); + + // + CopyPeakGolden( + zIndex, + loopback, + conditions.peakGoldenBuffer // + ); + + // + CopyVale( + zIndex, + loopback, + conditions.valeBuffer // + ); + + // + CopyValeGolden( + zIndex, + loopback, + conditions.valeGoldenBuffer // + ); + + // + CopyTrend( + zIndex, + loopback, + conditions.trendBuffer // + ); + + // + CopyTrendState( + zIndex, + loopback, + conditions.trendStateBuffer // + ); + + // + CopySupport( + zIndex, + loopback, + conditions.supportBuffer // + ); + + // + CopyResistance( + zIndex, + loopback, + conditions.resistanceBuffer // + ); + + // + CopySwingLow( + zIndex, + loopback, + conditions.swingLowBuffer // + ); + + // + CopySwingHigh( + zIndex, + loopback, + conditions.swingHighBuffer // + ); + + // + CopyFiboLevel1( + zIndex, + loopback, + conditions.fiboLevel1Buffer // + ); + + // + CopyFiboLevel2( + zIndex, + loopback, + conditions.fiboLevel2Buffer // + ); + + // + CopyFiboLevel3( + zIndex, + loopback, + conditions.fiboLevel3Buffer // + ); + + // + // Conditions ... + + // + int zIDX = 0; + int cIDX = 1; + int pIDX = cIDX + 1; + int p2IDX = pIDX + 1; + int p3IDX = p2IDX + 1; + int p4IDX = p3IDX + 1; + + // + // Calculate ... + + // + // KI ... + + // + double cKI = conditions.kiBuffer[cIDX]; + double pKI = conditions.kiBuffer[pIDX]; + double p2KI = conditions.kiBuffer[p2IDX]; + + // + double cKIState = conditions.kiStateBuffer[cIDX]; + double pKIState = conditions.kiStateBuffer[pIDX]; + double p2KIState = conditions.kiStateBuffer[p2IDX]; + + // + bool isKIRejectUp = cBar.IsRejected( + cKI, + X_DIRECTION_BULLISH, + false, + false // + ); + bool isKIRejectDown = cBar.IsRejected( + cKI, + X_DIRECTION_BEARISH, + false, + false // + ); + + // + bool isKIBullish = cKIState > 0; + bool isKIBullishPrev = pKIState > 0; + + // + bool isKIBearish = cKIState < 0; + bool isKIBearishPrev = pKIState < 0; + + // + bool isKISwitchedToBullish = isKIBullish && + !isKIBullishPrev; + bool isKISwitchedToBearish = isKIBearish && + !isKIBearishPrev; + + // + // SAR ... + + // + double cSar = conditions.sarBuffer[cIDX]; + double pSar = conditions.sarBuffer[pIDX]; + + // + bool isSarBullish = cBar.low > cSar; + bool isSarBullishPrev = pBar.low > pSar; + + // + bool isSarBearish = cBar.high < cSar; + bool isSarBearishPrev = pBar.high < pSar; + + // + bool isSarSwitchedToBullish = isSarBullish && + !isSarBullishPrev; + bool isSarSwitchedToBearish = isSarBearish && + !isSarBearishPrev; + + // + // PEAK ... + + // + double cPeak = conditions.peakBuffer[cIDX]; + double pPeak = conditions.peakBuffer[pIDX]; + + // + bool isPeakSameLast = cPeak == pPeak; + bool isPeakOverLast = cPeak > pPeak; + bool isPeakUnderLast = cPeak < pPeak; + + // + // VALE ... + + // + double cVale = conditions.valeBuffer[cIDX]; + double pVale = conditions.valeBuffer[pIDX]; + + // + bool isValeSameLast = cVale == pVale; + bool isValeOverLast = cVale > pVale; + bool isValeUnderLast = cVale < pVale; + + // + // TREND ... + + // + double cTrend = conditions.trendBuffer[cIDX]; + double pTrend = conditions.trendBuffer[pIDX]; + + // + double cTrendState = conditions.trendStateBuffer[cIDX]; + double pTrendState = conditions.trendStateBuffer[pIDX]; + + // + bool isTrendRejectUp = cBar.IsRejected( + cTrend, + X_DIRECTION_BULLISH, + false, + false // + ); + bool isTrendRejectDown = cBar.IsRejected( + cTrend, + X_DIRECTION_BEARISH, + false, + false // + ); + + // + bool isTrendBullish = cTrendState > 0; + bool isTrendBullishPrev = pTrendState > 0; + + // + bool isTrendBearish = cTrendState < 0; + bool isTrendBearishPrev = pTrendState < 0; + + // + bool isTrendSwitchedToBullish = isTrendBullish && + !isTrendBullishPrev; + bool isTrendSwitchedToBearish = isTrendBearish && + !isTrendBearishPrev; + + // + // SUPPORT ... + + // + double cSupport = conditions.supportBuffer[cIDX]; + double pSupport = conditions.supportBuffer[pIDX]; + + // + bool isSupportSameLast = cSupport == pSupport; + bool isSupportOverLast = cSupport > pSupport; + bool isSupportUnderLast = cSupport < pSupport; + + // + bool isLastSupportBreaked = cBar.IsBreaked( + pSupport, + X_DIRECTION_BEARISH // + ); + bool isLastSupportRejected = cBar.IsRejected( + pSupport, + X_DIRECTION_BULLISH, + false, + false // + ); + + // + // RESISTANCE ... + + // + double cResistance = conditions.resistanceBuffer[cIDX]; + double pResistance = conditions.resistanceBuffer[pIDX]; + + // + bool isResistanceSameLast = cResistance == pResistance; + bool isResistanceOverLast = cResistance > pResistance; + bool isResistanceUnderLast = cResistance < pResistance; + + // + bool isLastResistanceBreaked = cBar.IsBreaked( + pResistance, + X_DIRECTION_BULLISH // + ); + bool isLastResistanceRejected = cBar.IsRejected( + pResistance, + X_DIRECTION_BEARISH, + false, + false // + ); + + // + // SWING Low ... + + // + double cSwingLow = conditions.swingLowBuffer[cIDX]; + double pSwingLow = conditions.swingLowBuffer[pIDX]; + + // + bool isSwingLowSameLast = cSwingLow == pSwingLow; + bool isSwingLowOverLast = cSwingLow > pSwingLow; + bool isSwingLowUnderLast = cSwingLow < pSwingLow; + + // + bool isLastSwingLowBreaked = cBar.IsBreaked( + pSwingLow, + X_DIRECTION_BEARISH // + ); + bool isLastSwingLowRejected = cBar.IsRejected( + pSwingLow, + X_DIRECTION_BULLISH, + false, + false // + ); + + // + // SWING High ... + + // + double cSwingHigh = conditions.swingHighBuffer[cIDX]; + double pSwingHigh = conditions.swingHighBuffer[pIDX]; + + // + bool isSwingHighSameLast = cSwingHigh == pSwingHigh; + bool isSwingHighOverLast = cSwingHigh > pSwingHigh; + bool isSwingHighUnderLast = cSwingHigh < pSwingHigh; + + // + bool isLastSwingHighBreaked = cBar.IsBreaked( + pSwingHigh, + X_DIRECTION_BULLISH // + ); + bool isLastSwingHighRejected = cBar.IsRejected( + pSwingHigh, + X_DIRECTION_BEARISH, + false, + false // + ); + + // + // COMPLEX Conditions ... + + // + bool isSwingLowSameAsVale = cSwingLow == cVale; + bool isSwingHighSameAsPeak = cSwingHigh == cPeak; + + // + bool isSupportSameAsVale = cSupport == cVale; + bool isResistanceSameAsPeak = cResistance == cPeak; + + // + bool isSupportSameAsSwingLow = cSupport == cSwingLow; + bool isResistanceSameAsSwingHigh = cResistance == cSwingHigh; + + // + bool isPeakIsPivot = isSwingHighSameAsPeak && + isResistanceSameAsPeak && + isResistanceSameAsSwingHigh; + bool isValeIsPivot = isSwingLowSameAsVale && + isSupportSameAsVale && + isSupportSameAsSwingLow; + + // + // Attached ... + + // + conditions.isKIBullish = isKIBullish; + conditions.isKIBearish = isKIBearish; + conditions.isKIRejectUp = isKIRejectUp; + conditions.isSarBullish = isSarBullish; + conditions.isSarBearish = isSarBearish; + conditions.isPeakIsPivot = isPeakIsPivot; + conditions.isValeIsPivot = isValeIsPivot; + conditions.isKIRejectDown = isKIRejectDown; + conditions.isPeakSameLast = isPeakSameLast; + conditions.isPeakOverLast = isPeakOverLast; + conditions.isValeSameLast = isValeSameLast; + conditions.isValeOverLast = isValeOverLast; + conditions.isTrendBullish = isTrendBullish; + conditions.isTrendBearish = isTrendBearish; + conditions.isPeakUnderLast = isPeakUnderLast; + conditions.isValeUnderLast = isValeUnderLast; + conditions.isTrendRejectUp = isTrendRejectUp; + conditions.isTrendRejectDown = isTrendRejectDown; + conditions.isSupportSameLast = isSupportSameLast; + conditions.isSupportOverLast = isSupportOverLast; + conditions.isSupportUnderLast = isSupportUnderLast; + conditions.isSwingLowSameLast = isSwingLowSameLast; + conditions.isSwingLowOverLast = isSwingLowOverLast; + conditions.isSwingLowUnderLast = isSwingLowUnderLast; + conditions.isSwingHighSameLast = isSwingHighSameLast; + conditions.isSwingHighOverLast = isSwingHighOverLast; + conditions.isSupportSameAsVale = isSupportSameAsVale; + conditions.isLastSupportBreaked = isLastSupportBreaked; + conditions.isResistanceSameLast = isResistanceSameLast; + conditions.isResistanceOverLast = isResistanceOverLast; + conditions.isSwingHighUnderLast = isSwingHighUnderLast; + conditions.isSwingLowSameAsVale = isSwingLowSameAsVale; + conditions.isLastSupportRejected = isLastSupportRejected; + conditions.isResistanceUnderLast = isResistanceUnderLast; + conditions.isKISwitchedToBullish = isKISwitchedToBullish; + conditions.isKISwitchedToBearish = isKISwitchedToBearish; + conditions.isLastSwingLowBreaked = isLastSwingLowBreaked; + conditions.isSwingHighSameAsPeak = isSwingHighSameAsPeak; + conditions.isLastSwingLowRejected = isLastSwingLowRejected; + conditions.isSarSwitchedToBullish = isSarSwitchedToBullish; + conditions.isSarSwitchedToBearish = isSarSwitchedToBearish; + conditions.isLastSwingHighBreaked = isLastSwingHighBreaked; + conditions.isResistanceSameAsPeak = isResistanceSameAsPeak; + conditions.isLastSwingHighRejected = isLastSwingHighRejected; + conditions.isLastResistanceBreaked = isLastResistanceBreaked; + conditions.isSupportSameAsSwingLow = isSupportSameAsSwingLow; + conditions.isLastResistanceRejected = isLastResistanceRejected; + conditions.isTrendSwitchedToBullish = isTrendSwitchedToBullish; + conditions.isTrendSwitchedToBearish = isTrendSwitchedToBearish; + conditions.isResistanceSameAsSwingHigh = isResistanceSameAsSwingHigh; + + // + Cleanup(); + + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + + // + return result; + } + + // + // Protected ... + protected: + // + // Private ... + private: + // + // Props ... + X121XCAInputs mInputs; // Inputs ... + + // + // Buffers ... + double kiBuffer[]; + double sHHBuffer[]; + double sLLBuffer[]; + double mHHBuffer[]; + double mLLBuffer[]; + double lHHBuffer[]; + double lLLBuffer[]; + double hHHBuffer[]; + double hLLBuffer[]; + double sarBuffer[]; + double peakBuffer[]; + double valeBuffer[]; + double trendBuffer[]; + double kiStateBuffer[]; + double supportBuffer[]; + double swingLowBuffer[]; + double swingHighBuffer[]; + double resistanceBuffer[]; + double peakGoldenBuffer[]; + double valeGoldenBuffer[]; + double fiboLevel1Buffer[]; + double fiboLevel2Buffer[]; + double fiboLevel3Buffer[]; + double trendStateBuffer[]; + + // + void Calculate( + int barIndex = 0, + int maxRequiredBars = 100 // + ) + { + // + // Buffers ... + if (barIndex < 0) + { + barIndex = 0; + } + + // + CopyBuffer( + mHandler, + X121_XCA_KI_LINE, + barIndex, + maxRequiredBars, + kiBuffer // + ); + + // + CopyBuffer( + mHandler, + X121_XCA_S_HH_LINE, + barIndex, + maxRequiredBars, + sHHBuffer // + ); + + // + CopyBuffer( + mHandler, + X121_XCA_S_LL_LINE, + barIndex, + maxRequiredBars, + sLLBuffer // + ); + + // + CopyBuffer( + mHandler, + X121_XCA_M_HH_LINE, + barIndex, + maxRequiredBars, + mHHBuffer // + ); + + // + CopyBuffer( + mHandler, + X121_XCA_M_LL_LINE, + barIndex, + maxRequiredBars, + mLLBuffer // + ); + + // + CopyBuffer( + mHandler, + X121_XCA_L_HH_LINE, + barIndex, + maxRequiredBars, + lHHBuffer // + ); + + // + CopyBuffer( + mHandler, + X121_XCA_L_LL_LINE, + barIndex, + maxRequiredBars, + lLLBuffer // + ); + + // + CopyBuffer( + mHandler, + X121_XCA_H_HH_LINE, + barIndex, + maxRequiredBars, + hHHBuffer // + ); + + // + CopyBuffer( + mHandler, + X121_XCA_H_LL_LINE, + barIndex, + maxRequiredBars, + hLLBuffer // + ); + + // + CopyBuffer( + mHandler, + X121_XCA_SAR_LINE, + barIndex, + maxRequiredBars, + sarBuffer // + ); + + // + CopyBuffer( + mHandler, + X121_XCA_PEAK_LINE, + barIndex, + maxRequiredBars, + peakBuffer // + ); + + // + CopyBuffer( + mHandler, + X121_XCA_VALE_LINE, + barIndex, + maxRequiredBars, + valeBuffer // + ); + + // + CopyBuffer( + mHandler, + X121_XCA_TREND_LINE, + barIndex, + maxRequiredBars, + trendBuffer // + ); + + // + CopyBuffer( + mHandler, + X121_XCA_KI_STATE_LINE, + barIndex, + maxRequiredBars, + kiStateBuffer // + ); + + // + CopyBuffer( + mHandler, + X121_XCA_SUPPORT_LINE, + barIndex, + maxRequiredBars, + supportBuffer // + ); + + // + CopyBuffer( + mHandler, + X121_XCA_SWING_LOW_LINE, + barIndex, + maxRequiredBars, + swingLowBuffer // + ); + + // + CopyBuffer( + mHandler, + X121_XCA_SWING_HIGH_LINE, + barIndex, + maxRequiredBars, + swingHighBuffer // + ); + + // + CopyBuffer( + mHandler, + X121_XCA_RESISTANCE_LINE, + barIndex, + maxRequiredBars, + resistanceBuffer // + ); + + // + CopyBuffer( + mHandler, + X121_XCA_PEAK_GOLDEN_LINE, + barIndex, + maxRequiredBars, + peakGoldenBuffer // + ); + + // + CopyBuffer( + mHandler, + X121_XCA_VALE_GOLDEN_LINE, + barIndex, + maxRequiredBars, + valeGoldenBuffer // + ); + + // + CopyBuffer( + mHandler, + X121_XCA_FIBO_L1_LINE, + barIndex, + maxRequiredBars, + fiboLevel1Buffer // + ); + + // + CopyBuffer( + mHandler, + X121_XCA_FIBO_L2_LINE, + barIndex, + maxRequiredBars, + fiboLevel2Buffer // + ); + + // + CopyBuffer( + mHandler, + X121_XCA_FIBO_L3_LINE, + barIndex, + maxRequiredBars, + fiboLevel3Buffer // + ); + + // + CopyBuffer( + mHandler, + X121_XCA_TREND_STATE_LINE, + barIndex, + maxRequiredBars, + trendStateBuffer // + ); + } + + // + void Cleanup( + int maxAllowed = 100 // + ) + { + // + CleanupArray( + kiBuffer, + maxAllowed // + ); + + // + CleanupArray( + sHHBuffer, + maxAllowed // + ); + + // + CleanupArray( + sLLBuffer, + maxAllowed // + ); + + // + CleanupArray( + mHHBuffer, + maxAllowed // + ); + + // + CleanupArray( + mLLBuffer, + maxAllowed // + ); + + // + CleanupArray( + lHHBuffer, + maxAllowed // + ); + + // + CleanupArray( + lLLBuffer, + maxAllowed // + ); + + // + CleanupArray( + hHHBuffer, + maxAllowed // + ); + + // + CleanupArray( + hLLBuffer, + maxAllowed // + ); + + // + CleanupArray( + sarBuffer, + maxAllowed // + ); + + // + CleanupArray( + peakBuffer, + maxAllowed // + ); + + // + CleanupArray( + valeBuffer, + maxAllowed // + ); + + // + CleanupArray( + trendBuffer, + maxAllowed // + ); + + // + CleanupArray( + kiStateBuffer, + maxAllowed // + ); + + // + CleanupArray( + supportBuffer, + maxAllowed // + ); + + // + CleanupArray( + swingLowBuffer, + maxAllowed // + ); + + // + CleanupArray( + swingHighBuffer, + maxAllowed // + ); + + // + CleanupArray( + resistanceBuffer, + maxAllowed // + ); + + // + CleanupArray( + peakGoldenBuffer, + maxAllowed // + ); + + // + CleanupArray( + valeGoldenBuffer, + maxAllowed // + ); + + // + CleanupArray( + fiboLevel1Buffer, + maxAllowed // + ); + + // + CleanupArray( + fiboLevel2Buffer, + maxAllowed // + ); + + // + CleanupArray( + fiboLevel3Buffer, + maxAllowed // + ); + + // + CleanupArray( + trendStateBuffer, + maxAllowed // + ); + } + + // +}; + +// +// Tools ... \ No newline at end of file diff --git a/Indicators/x-saherelm.x121.xca.mq5 b/Indicators/x-saherelm.x121.xca.mq5 new file mode 100644 index 00000000..21bea53b --- /dev/null +++ b/Indicators/x-saherelm.x121.xca.mq5 @@ -0,0 +1,1942 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 Indicator +// ------------------------------------------------- +// Name: X121 XCA +// Description: XCA ... +// +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// +// +// Global Properties ... +#property copyright "Copyright 2023, SaherElm IT Center" +#property link "https://saherelm.ir" +#property version "1.00" +#property description "SaherElm X121 XCA Indicator" +#property strict + +// +// Definitions ... + +// +#define ShortName "X121 XCA" + +// +// Includes Common Library ... +#include "../Libraries/x-saherelm.common.lib.mq5" + +// +// Inputs ... + +// +input group "Market"; + +// +input group "Short"; +input ENUM_X_PERIOD_METHOD scMethod = X_PERIOD_AUTO; // How to Find Period +input ENUM_TIMEFRAMES scPeriod = NULL; // Time Period + +// +input group "Medium"; +input ENUM_X_PERIOD_METHOD mcMethod = X_PERIOD_AUTO; // How to Find Period +input ENUM_TIMEFRAMES mcPeriod = NULL; // Time Period + +// +input group "Long"; +input ENUM_X_PERIOD_METHOD lcMethod = X_PERIOD_AUTO; // How to Find Period +input ENUM_TIMEFRAMES lcPeriod = NULL; // Time Period + +// +input group "Hind"; +input ENUM_X_PERIOD_METHOD hcMethod = X_PERIOD_AUTO; // How to Find Period +input ENUM_TIMEFRAMES hcPeriod = NULL; // Time Period + +// +input group "Boundary Detection"; +input ENUM_SERIESMODE hhMode = MODE_HIGH; // Highest High Calculation Method +input ENUM_SERIESMODE llMode = MODE_LOW; // Lowest Low Calculation Method + +// +input group "Fibo Levels"; +input ENUM_X_FIBO_LEVELS fiboLevel1 = X_FIBO_LEVEL_236; // Fibo Level 1 +input ENUM_X_FIBO_LEVELS fiboLevel2 = X_FIBO_LEVEL_500; // Fibo Level 2 +input ENUM_X_FIBO_LEVELS fiboLevel3 = X_FIBO_LEVEL_764; // Fibo Level 3 + +// +input group "Sar Detection"; +input double sarStep = 0.02; // Step +input double sarMax = 0.2; // Maximum + +// +// KI ... +input group "KI"; +input int kiLength = 26; // KI Length + +// +input group "Swing Detection"; +input int swingLength = 5; // Length + +// +input group "Support and Resistance"; +input int supResSmoothingLength = 7; // Smoothing Length +input ENUM_X_MA_METHOD supResSmoothingMode = X_MA_MODE_SMA; // Smoothing Method + +// +// Presentation ... +input group "Presentation"; + +// +input int startCalculationForLastBars = 1000; // Calculate Last n Bars + +// +input bool showSar = true; // Show Sar +input bool showKI = true; // Show KI +input bool showTrend = true; // Show Trend +input bool showSwings = true; // Show Swings +input bool showFiboLevel1 = true; // Show Fibo Level 1 +input bool showFiboLevel2 = true; // Show Fibo Level 2 +input bool showFiboLevel3 = true; // Show Fibo Level 3 +input bool showPeaksAndVales = true; // Show Peaks And Vales +input bool showPeakAndValeGolden = true; // Show Peak and Vale Golden +input bool showSupportAndResistance = true; // Show Support and Resistance +input bool showShortCycle = true; // Show Short Cycle +input bool showMediumCycle = true; // Show Medium Cycle +input bool showLongCycle = true; // Show Long Cycle +input bool showHindCycle = true; // Show Hind Cycle + +// +input int sarArrowCode = 159; // Parabolic Sar Arrow Code +input int peakArrowCode = 159; // Peaks Arrow Code +input int valeArrowCode = 159; // Vales Arrow Code +input int swingLowArrowCode = 225; // Swing Low Arrow Code +input int swingHighArrowCode = 226; // Swing High Arrow Code + +// +// Buffers ... + +// +#define hideColorIDX 0 +#define bullishColorIDX 1 +#define bearishColorIDX 2 +#define neuturalColorIDX 3 + +// +#define emptyValue 0.0 + +// +#property indicator_chart_window + +// +#property indicator_buffers 28 +#property indicator_plots 22 + +// +// Plot Buffers ... + +// +// SHORT ... + +// +#define sHHBufferIndex 0 +double sHHBuffer[]; + +// +#property indicator_label1 "SH" +#property indicator_type1 DRAW_LINE +#property indicator_color1 clrGray +#property indicator_style1 STYLE_DOT +#property indicator_width1 1 + +// +#define sLLBufferIndex 1 +double sLLBuffer[]; + +// +#property indicator_label2 "SL" +#property indicator_type2 DRAW_LINE +#property indicator_color2 clrGray +#property indicator_style2 STYLE_DOT +#property indicator_width2 1 + +// +// MEDIUM ... + +// +#define mHHBufferIndex 2 +double mHHBuffer[]; + +// +#property indicator_label3 "MH" +#property indicator_type3 DRAW_LINE +#property indicator_color3 clrIndigo +#property indicator_style3 STYLE_DOT +#property indicator_width3 1 + +// +#define mLLBufferIndex 3 +double mLLBuffer[]; + +// +#property indicator_label4 "ML" +#property indicator_type4 DRAW_LINE +#property indicator_color4 clrIndigo +#property indicator_style4 STYLE_DOT +#property indicator_width4 1 + +// +// LONG ... + +// +#define lHHBufferIndex 4 +double lHHBuffer[]; + +// +#property indicator_label5 "LH" +#property indicator_type5 DRAW_LINE +#property indicator_color5 clrGoldenrod +#property indicator_style5 STYLE_DOT +#property indicator_width5 1 + +// +#define lLLBufferIndex 5 +double lLLBuffer[]; + +// +#property indicator_label6 "LL" +#property indicator_type6 DRAW_LINE +#property indicator_color6 clrGoldenrod +#property indicator_style6 STYLE_DOT +#property indicator_width6 1 + +// +// HIND ... + +// +#define hHHBufferIndex 6 +double hHHBuffer[]; + +// +#property indicator_label7 "HH" +#property indicator_type7 DRAW_LINE +#property indicator_color7 clrBrown +#property indicator_style7 STYLE_DOT +#property indicator_width7 1 + +// +#define hLLBufferIndex 7 +double hLLBuffer[]; + +// +#property indicator_label8 "HL" +#property indicator_type8 DRAW_LINE +#property indicator_color8 clrBrown +#property indicator_style8 STYLE_DOT +#property indicator_width8 1 + +// +// SUPPORT ... + +// +#define supportBufferIndex 8 +double supportBuffer[]; + +// +#property indicator_label9 "SUPPORT" +#property indicator_type9 DRAW_LINE +#property indicator_color9 clrLime +#property indicator_style9 STYLE_SOLID +#property indicator_width9 1 + +// +// RESISTANCE ... + +// +#define resistanceBufferIndex 9 +double resistanceBuffer[]; + +// +#property indicator_label10 "RESISTANCE" +#property indicator_type10 DRAW_LINE +#property indicator_color10 clrRed +#property indicator_style10 STYLE_SOLID +#property indicator_width10 1 + +// +// PEAKS ... + +// +#define peakBufferIndex 10 +double peakBuffer[]; + +// +#property indicator_label11 "PEAK" +#property indicator_type11 DRAW_ARROW +#property indicator_color11 clrMagenta +#property indicator_width11 1 + +// +// PEAKS Golden ... + +// +#define peakGoldenBufferIndex 11 +double peakGoldenBuffer[]; + +// +#property indicator_label12 "PEAK Golden" +#property indicator_type12 DRAW_LINE +#property indicator_color12 clrMagenta +#property indicator_style2 STYLE_DOT +#property indicator_width12 1 + +// +// VALES ... + +// +#define valeBufferIndex 12 +double valeBuffer[]; + +// +#property indicator_label13 "VALE" +#property indicator_type13 DRAW_ARROW +#property indicator_color13 clrAqua +#property indicator_width13 1 + +// +// VALE Golden ... + +// +#define valeGoldenBufferIndex 13 +double valeGoldenBuffer[]; + +// +#property indicator_label14 "VALES Golden" +#property indicator_type14 DRAW_LINE +#property indicator_color14 clrAqua +#property indicator_style4 STYLE_DOT +#property indicator_width14 1 + +// +// FIBO Level 1 + +// +#define fiboLevel1BufferIndex 14 +double fiboLevel1Buffer[]; + +// +#property indicator_label15 "Fibo L1" +#property indicator_type15 DRAW_LINE +#property indicator_color15 clrGold +#property indicator_style15 STYLE_DOT +#property indicator_width15 1 + +// +// FIBO Level 2 + +// +#define fiboLevel2BufferIndex 15 +double fiboLevel2Buffer[]; + +// +#property indicator_label16 "Fibo L2" +#property indicator_type16 DRAW_LINE +#property indicator_color16 clrYellow +#property indicator_style16 STYLE_DASH +#property indicator_width16 1 + +// +// FIBO Level 3 + +// +#define fiboLevel3BufferIndex 16 +double fiboLevel3Buffer[]; + +// +#property indicator_label17 "Fibo L3" +#property indicator_type17 DRAW_LINE +#property indicator_color17 clrGold +#property indicator_style17 STYLE_DOT +#property indicator_width17 1 + +// +// SAR ... + +// +#define sarBufferIndex 17 +double sarBuffer[]; + +// +#property indicator_label18 "SAR" +#property indicator_type18 DRAW_ARROW +#property indicator_color18 clrYellow +#property indicator_width18 1 + +// +// TREND ... + +// +#define trendBufferIndex 18 +#define trendBufferPlotIndex 18 +double trendBuffer[]; + +// +#define trendColorBufferIndex 19 +double trendColorBuffer[]; + +// +#property indicator_label19 "TRND" +#property indicator_type19 DRAW_COLOR_LINE +#property indicator_color19 CLR_NONE, clrAqua, clrMagenta, clrGray +#property indicator_style19 STYLE_DASH +#property indicator_width19 2 + +// +// KI ... + +// +#define kiBufferIndex 20 +#define kiBufferPlotIndex 19 +double kiBuffer[]; + +// +#define kiColorBufferIndex 21 +double kiColorBuffer[]; + +// +#property indicator_label20 "KI" +#property indicator_type20 DRAW_COLOR_LINE +#property indicator_color20 CLR_NONE, clrGreen, clrRed, clrGray +#property indicator_style20 STYLE_DASHDOTDOT +#property indicator_width20 2 + +// +// SWING Low ... + +// +#define swingLowBufferIndex 22 +#define swingLowBufferPlotIndex 20 +double swingLowBuffer[]; + +// +#property indicator_label21 "SWL" +#property indicator_type21 DRAW_ARROW +#property indicator_color21 clrGreen +#property indicator_width21 1 + +// +// SWING High ... + +// +#define swingHighBufferIndex 23 +#define swingHighBufferPlotIndex 21 +double swingHighBuffer[]; + +// +#property indicator_label22 "SWH" +#property indicator_type22 DRAW_ARROW +#property indicator_color22 clrRed +#property indicator_width22 1 + +// +// Data Buffers ... + +#define mLastBufferIndex 23 + +// +#define trendStateBufferIndex mLastBufferIndex + 1 +double trendStateBuffer[]; + +// +#define kiStateBufferIndex mLastBufferIndex + 2 +double kiStateBuffer[]; + +// +#define supBufferIndex mLastBufferIndex + 3 +double supBuffer[]; + +// +#define resBufferIndex mLastBufferIndex + 4 +double resBuffer[]; + +// +// Variables, Properties and etc ... + +// +// this counts Available Bars ... +int limit; + +// +int maxLength; + +// +// SAR Handler ... +int sarHandler = INVALID_HANDLE; + +// +// TREND Handler ... +int trendHandler = INVALID_HANDLE; + +// +// XMarketCycle sc; +int mSCLength = 0; +ENUM_TIMEFRAMES mSCPeriod = NULL; + +// +// XMarketCycle mc; +int mMCLength = 0; +ENUM_TIMEFRAMES mMCPeriod = NULL; + +// +// XMarketCycle lc; +int mLCLength = 0; +ENUM_TIMEFRAMES mLCPeriod = NULL; + +// +// XMarketCycle hc; +int mHCLength = 0; +ENUM_TIMEFRAMES mHCPeriod = NULL; + +// +// Event Handlers ... + +/** + * Initialize Indicator ... + * + * @return ( int ) + */ +int OnInit() +{ + // + // Validate Inputs ... + if (!ValidateInputs()) + { + return INIT_PARAMETERS_INCORRECT; + } + + // + if (!InitMarketCycles()) + { + return INIT_PARAMETERS_INCORRECT; + } + + // + // Initialize Indicator Handlers ... + + // + // SAR ... + sarHandler = iSAR( + _Symbol, + _Period, + sarStep, + sarMax // + ); + bool isInited = sarHandler != INVALID_HANDLE; + if (!isInited) + { + return INIT_FAILED; + } + + // + // TREND ... + trendHandler = iMA( + _Symbol, + _Period, + mHCLength, + 0, + MODE_EMA, + PRICE_CLOSE // + ); + isInited = trendHandler != INVALID_HANDLE; + if (!isInited) + { + return INIT_FAILED; + } + + // + // because in some cases we may have more than one input for + // calculation and we must prevent any calculation + // untill we pass the biggest input length, here we get max Input length + // and then wait until pass it ... + maxLength = ExtractMaxLengthOfInputs(); + + // + // Define Index Buffers ... + DefineBuffers(); + + // + // Set Indicator ShortName ... + SetIndicatorName(); + + // + // Init Succeed ... + return INIT_SUCCEEDED; +} + +/** + * De Initialize Indicator ... + * + * @param reason: Integer, De Initialization Reason ... + */ +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 + + // + IndicatorRelease(sarHandler); + IndicatorRelease(trendHandler); +} + +/** + * Calculate Bars ... + * + * @param rates_total: Integer, Total Bars on Chart ... + * @param prev_calculated: Integer, Total Calculated Bars on Charts ... + * @param time: DateTime Array, History of Open Time ... + * @param open: Double Array, History of Open Prices ... + * @param high: Double Array, History of High Prices ... + * @param low: Double Array, History of Low Prices ... + * @param close: Double Array, History of Close Prices ... + * @param tick_volume: Long, History of Tick Volumes on Bar ... + * @param volume: Long, History of Trade Volumes ... + * @param spread: Double, History of Spread Price ... + * + * @return ( int ) + */ +int OnCalculate( + const int rates_total, + const int prev_calculated, + const datetime &time[], + const double &open[], + const double &high[], + const double &low[], + const double &close[], + const long &tick_volume[], + const long &volume[], + const int &spread[] // +) +{ + // + // Prepare Buffers ... + ArraySetAsSeries(time, true); + ArraySetAsSeries(open, true); + ArraySetAsSeries(high, true); + ArraySetAsSeries(low, true); + ArraySetAsSeries(close, true); + ArraySetAsSeries(tick_volume, true); + ArraySetAsSeries(volume, true); + ArraySetAsSeries(spread, true); + + // + // Validate Calculated Bars ... + + // + // SAR ... + int sarCalculatedBars = BarsCalculated(sarHandler); + + // + // TREND ... + int trendCalculatedBars = BarsCalculated(trendHandler); + + // + bool isPassedRequiredCalculatedBars = + // + // SAR ... + sarCalculatedBars >= maxLength && + // + // TREND ... + trendCalculatedBars >= maxLength + // + ; + if (!isPassedRequiredCalculatedBars) + { + return prev_calculated; + } + + // + limit = (prev_calculated > rates_total || prev_calculated <= 0) + ? rates_total + : (rates_total - prev_calculated) + 1; + + // + // Buffers Copy ... + + // + // SAR ... + int copiedSars = CopyBuffer(sarHandler, 0, 0, limit, sarBuffer); + + // + // TREND ... + int copiedTrends = CopyBuffer(trendHandler, MAIN_LINE, 0, limit + 1, trendBuffer); + + // + // Validate Copied Items ... + bool isPassedRequiredCopiedItems = + // + // SAR ... + copiedSars >= limit && + // + // TREND ... + copiedTrends >= limit + // + ; + if (!isPassedRequiredCopiedItems) + { + return prev_calculated; + } + + // + // Main Loop ... + for (int i = limit - 1; i >= 0 && !IsStopped(); i--) + { + // + CalculateBuffers( + i, + prev_calculated, + rates_total, + // + open, + high, + close, + low, + tick_volume // + ); + } + + // + return rates_total; +} + +// +// Functions ... + +/** + * Validate Input Args for Initialization ... + * + * @return ( bool ) + */ +bool ValidateInputs() +{ + // + bool result = false; + + // + result = + // + // SAR ... + sarMax > 0 && + sarStep > 0 && + kiLength > 0 && + swingLength > 0 && + sarMax > sarStep && + // + // XCA ... + (IsValid(scMethod, scPeriod) && + IsValid(mcMethod, mcPeriod) && + IsValid(lcMethod, lcPeriod) && + IsValid(hcMethod, hcPeriod)) + // + ; + + // + return result; +} + +/** + * Extract Max Length of Inputs ... + * + * @return ( int ) + */ +int ExtractMaxLengthOfInputs() +{ + // + int result = 0; + + // + result = MathMax(kiLength, swingLength); + + // + return result; +} + +/** + * Define Required Buffers ... + */ +void DefineBuffers() +{ + // + // Plot Buffers ... + + // + // SHORT ... + + // + ENUM_DRAW_TYPE sDrawType = showShortCycle ? DRAW_LINE : DRAW_NONE; + + // + // HH ... + + // + ArraySetAsSeries(sHHBuffer, true); + SetIndexBuffer(sHHBufferIndex, sHHBuffer, INDICATOR_DATA); + + // + PlotIndexSetInteger(sHHBufferIndex, PLOT_SHOW_DATA, showShortCycle); + PlotIndexSetInteger(sHHBufferIndex, PLOT_DRAW_TYPE, sDrawType); + + // + PlotIndexSetDouble(sHHBufferIndex, PLOT_EMPTY_VALUE, emptyValue); + + // + // LL ... + + // + ArraySetAsSeries(sLLBuffer, true); + SetIndexBuffer(sLLBufferIndex, sLLBuffer, INDICATOR_DATA); + + // + PlotIndexSetInteger(sLLBufferIndex, PLOT_SHOW_DATA, showShortCycle); + PlotIndexSetInteger(sLLBufferIndex, PLOT_DRAW_TYPE, sDrawType); + + // + PlotIndexSetDouble(sLLBufferIndex, PLOT_EMPTY_VALUE, emptyValue); + + // + // MEDIUM ... + + // + ENUM_DRAW_TYPE mDrawType = showMediumCycle ? DRAW_LINE : DRAW_NONE; + + // + // HH ... + + // + ArraySetAsSeries(mHHBuffer, true); + SetIndexBuffer(mHHBufferIndex, mHHBuffer, INDICATOR_DATA); + + // + PlotIndexSetInteger(mHHBufferIndex, PLOT_SHOW_DATA, showMediumCycle); + PlotIndexSetInteger(mHHBufferIndex, PLOT_DRAW_TYPE, mDrawType); + + // + PlotIndexSetDouble(mHHBufferIndex, PLOT_EMPTY_VALUE, emptyValue); + + // + // LL ... + + // + ArraySetAsSeries(mLLBuffer, true); + SetIndexBuffer(mLLBufferIndex, mLLBuffer, INDICATOR_DATA); + + // + PlotIndexSetInteger(mLLBufferIndex, PLOT_SHOW_DATA, showMediumCycle); + PlotIndexSetInteger(mLLBufferIndex, PLOT_DRAW_TYPE, mDrawType); + + // + PlotIndexSetDouble(mLLBufferIndex, PLOT_EMPTY_VALUE, emptyValue); + + // + // LONG ... + + // + ENUM_DRAW_TYPE lDrawType = showLongCycle ? DRAW_LINE : DRAW_NONE; + + // + // HH ... + + // + ArraySetAsSeries(lHHBuffer, true); + SetIndexBuffer(lHHBufferIndex, lHHBuffer, INDICATOR_DATA); + + // + PlotIndexSetInteger(lHHBufferIndex, PLOT_SHOW_DATA, showLongCycle); + PlotIndexSetInteger(lHHBufferIndex, PLOT_DRAW_TYPE, lDrawType); + + // + PlotIndexSetDouble(lHHBufferIndex, PLOT_EMPTY_VALUE, emptyValue); + + // + // LL ... + + // + ArraySetAsSeries(lLLBuffer, true); + SetIndexBuffer(lLLBufferIndex, lLLBuffer, INDICATOR_DATA); + + // + PlotIndexSetInteger(lLLBufferIndex, PLOT_SHOW_DATA, showLongCycle); + PlotIndexSetInteger(lLLBufferIndex, PLOT_DRAW_TYPE, lDrawType); + + // + PlotIndexSetDouble(lLLBufferIndex, PLOT_EMPTY_VALUE, emptyValue); + + // + // HIND ... + + // + ENUM_DRAW_TYPE hDrawType = showHindCycle ? DRAW_LINE : DRAW_NONE; + + // + // HH ... + + // + ArraySetAsSeries(hHHBuffer, true); + SetIndexBuffer(hHHBufferIndex, hHHBuffer, INDICATOR_DATA); + + // + PlotIndexSetInteger(hHHBufferIndex, PLOT_SHOW_DATA, showHindCycle); + PlotIndexSetInteger(hHHBufferIndex, PLOT_DRAW_TYPE, hDrawType); + + // + PlotIndexSetDouble(hHHBufferIndex, PLOT_EMPTY_VALUE, emptyValue); + + // + // LL ... + + // + ArraySetAsSeries(hLLBuffer, true); + SetIndexBuffer(hLLBufferIndex, hLLBuffer, INDICATOR_DATA); + + // + PlotIndexSetInteger(hLLBufferIndex, PLOT_SHOW_DATA, showHindCycle); + PlotIndexSetInteger(hLLBufferIndex, PLOT_DRAW_TYPE, hDrawType); + + // + PlotIndexSetDouble(hLLBufferIndex, PLOT_EMPTY_VALUE, emptyValue); + + // + // SUPPORT / RESISTANCE ... + + // + ENUM_DRAW_TYPE supResDrawType = showSupportAndResistance ? DRAW_LINE : DRAW_NONE; + + // + // SUPPORT ... + + // + ArraySetAsSeries(supportBuffer, true); + SetIndexBuffer(supportBufferIndex, supportBuffer, INDICATOR_DATA); + + // + PlotIndexSetInteger(supportBufferIndex, PLOT_SHOW_DATA, showSupportAndResistance); + PlotIndexSetInteger(supportBufferIndex, PLOT_DRAW_TYPE, supResDrawType); + + // + PlotIndexSetDouble(supportBufferIndex, PLOT_EMPTY_VALUE, emptyValue); + + // + // RESISTANCE ... + + // + ArraySetAsSeries(resistanceBuffer, true); + SetIndexBuffer(resistanceBufferIndex, resistanceBuffer, INDICATOR_DATA); + + // + PlotIndexSetInteger(resistanceBufferIndex, PLOT_SHOW_DATA, showSupportAndResistance); + PlotIndexSetInteger(resistanceBufferIndex, PLOT_DRAW_TYPE, supResDrawType); + + // + PlotIndexSetDouble(resistanceBufferIndex, PLOT_EMPTY_VALUE, emptyValue); + + // + // PEAK / VALE ... + + // + ENUM_DRAW_TYPE pvDrawType = showPeaksAndVales ? DRAW_ARROW : DRAW_NONE; + + // + // PEAK ... + + // + ArraySetAsSeries(peakBuffer, true); + SetIndexBuffer(peakBufferIndex, peakBuffer, INDICATOR_DATA); + + // + PlotIndexSetInteger(peakBufferIndex, PLOT_SHOW_DATA, showPeaksAndVales); + PlotIndexSetInteger(peakBufferIndex, PLOT_DRAW_TYPE, pvDrawType); + + // + PlotIndexSetDouble(peakBufferIndex, PLOT_EMPTY_VALUE, emptyValue); + PlotIndexSetInteger(peakBufferIndex, PLOT_ARROW, peakArrowCode); + + // + // VALE ... + + // + ArraySetAsSeries(valeBuffer, true); + SetIndexBuffer(valeBufferIndex, valeBuffer, INDICATOR_DATA); + + // + PlotIndexSetInteger(valeBufferIndex, PLOT_SHOW_DATA, showPeaksAndVales); + PlotIndexSetInteger(valeBufferIndex, PLOT_DRAW_TYPE, pvDrawType); + + // + PlotIndexSetDouble(valeBufferIndex, PLOT_EMPTY_VALUE, emptyValue); + PlotIndexSetInteger(valeBufferIndex, PLOT_ARROW, valeArrowCode); + + // + // PV GOLDEN ... + + // + ENUM_DRAW_TYPE pvGoldenDrawType = showPeakAndValeGolden ? DRAW_LINE : DRAW_NONE; + + // + // PEAK Golden ... + + // + ArraySetAsSeries(peakGoldenBuffer, true); + SetIndexBuffer(peakGoldenBufferIndex, peakGoldenBuffer, INDICATOR_DATA); + + // + PlotIndexSetInteger(peakGoldenBufferIndex, PLOT_SHOW_DATA, showPeakAndValeGolden); + PlotIndexSetInteger(peakGoldenBufferIndex, PLOT_DRAW_TYPE, pvGoldenDrawType); + + // + PlotIndexSetDouble(peakGoldenBufferIndex, PLOT_EMPTY_VALUE, emptyValue); + + // + // VALE Golden ... + + // + ArraySetAsSeries(valeGoldenBuffer, true); + SetIndexBuffer(valeGoldenBufferIndex, valeGoldenBuffer, INDICATOR_DATA); + + // + PlotIndexSetInteger(valeGoldenBufferIndex, PLOT_SHOW_DATA, showPeakAndValeGolden); + PlotIndexSetInteger(valeGoldenBufferIndex, PLOT_DRAW_TYPE, pvGoldenDrawType); + + // + PlotIndexSetDouble(valeGoldenBufferIndex, PLOT_EMPTY_VALUE, emptyValue); + + // + // FIBO L1 ... + + // + ENUM_DRAW_TYPE fiboL1DrawType = showFiboLevel1 ? DRAW_LINE : DRAW_NONE; + + // + ArraySetAsSeries(fiboLevel1Buffer, true); + SetIndexBuffer(fiboLevel1BufferIndex, fiboLevel1Buffer, INDICATOR_DATA); + + // + PlotIndexSetInteger(fiboLevel1BufferIndex, PLOT_SHOW_DATA, showFiboLevel1); + PlotIndexSetInteger(fiboLevel1BufferIndex, PLOT_DRAW_TYPE, fiboL1DrawType); + + // + PlotIndexSetDouble(fiboLevel1BufferIndex, PLOT_EMPTY_VALUE, emptyValue); + + // + // FIBO L2 ... + + // + ENUM_DRAW_TYPE fiboL2DrawType = showFiboLevel2 ? DRAW_LINE : DRAW_NONE; + + // + ArraySetAsSeries(fiboLevel2Buffer, true); + SetIndexBuffer(fiboLevel2BufferIndex, fiboLevel2Buffer, INDICATOR_DATA); + + // + PlotIndexSetInteger(fiboLevel2BufferIndex, PLOT_SHOW_DATA, showFiboLevel2); + PlotIndexSetInteger(fiboLevel2BufferIndex, PLOT_DRAW_TYPE, fiboL2DrawType); + + // + PlotIndexSetDouble(fiboLevel2BufferIndex, PLOT_EMPTY_VALUE, emptyValue); + + // + // FIBO L3 ... + + // + ENUM_DRAW_TYPE fiboL3DrawType = showFiboLevel3 ? DRAW_LINE : DRAW_NONE; + + // + ArraySetAsSeries(fiboLevel3Buffer, true); + SetIndexBuffer(fiboLevel3BufferIndex, fiboLevel3Buffer, INDICATOR_DATA); + + // + PlotIndexSetInteger(fiboLevel3BufferIndex, PLOT_SHOW_DATA, showFiboLevel3); + PlotIndexSetInteger(fiboLevel3BufferIndex, PLOT_DRAW_TYPE, fiboL3DrawType); + + // + PlotIndexSetDouble(fiboLevel3BufferIndex, PLOT_EMPTY_VALUE, emptyValue); + + // + // SAR ... + + // + ENUM_DRAW_TYPE sarDrawType = showSar ? DRAW_ARROW : DRAW_NONE; + + // + ArraySetAsSeries(sarBuffer, true); + SetIndexBuffer(sarBufferIndex, sarBuffer, INDICATOR_DATA); + + // + PlotIndexSetInteger(sarBufferIndex, PLOT_SHOW_DATA, showSar); + PlotIndexSetInteger(sarBufferIndex, PLOT_DRAW_TYPE, sarDrawType); + + // + PlotIndexSetDouble(sarBufferIndex, PLOT_EMPTY_VALUE, emptyValue); + PlotIndexSetInteger(sarBufferIndex, PLOT_ARROW, sarArrowCode); + + // + // TREND ... + + // + ENUM_DRAW_TYPE trendDrawType = showTrend ? DRAW_COLOR_LINE : DRAW_NONE; + + // + ArraySetAsSeries(trendBuffer, true); + SetIndexBuffer(trendBufferIndex, trendBuffer, INDICATOR_DATA); + + // + PlotIndexSetInteger(trendBufferPlotIndex, PLOT_SHOW_DATA, showTrend); + // PlotIndexSetInteger(trendBufferPlotIndex, PLOT_DRAW_TYPE, trendDrawType); + + // + PlotIndexSetDouble(trendBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue); + + // + ArraySetAsSeries(trendColorBuffer, true); + SetIndexBuffer(trendColorBufferIndex, trendColorBuffer, INDICATOR_COLOR_INDEX); + + // + // KI ... + + // + ENUM_DRAW_TYPE kiDrawType = showKI ? DRAW_COLOR_LINE : DRAW_NONE; + + // + ArraySetAsSeries(kiBuffer, true); + SetIndexBuffer(kiBufferIndex, kiBuffer, INDICATOR_DATA); + + // + PlotIndexSetInteger(kiBufferPlotIndex, PLOT_SHOW_DATA, showKI); + // PlotIndexSetInteger(kiBufferPlotIndex, PLOT_DRAW_TYPE, kiDrawType); + + // + PlotIndexSetDouble(kiBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue); + + // + ArraySetAsSeries(kiColorBuffer, true); + SetIndexBuffer(kiColorBufferIndex, kiColorBuffer, INDICATOR_COLOR_INDEX); + + // + // SWINGS ... + + // + ENUM_DRAW_TYPE swingDrawType = showSwings ? DRAW_ARROW : DRAW_NONE; + + // + // SWING Low ... + + // + ArraySetAsSeries(swingLowBuffer, true); + SetIndexBuffer(swingLowBufferIndex, swingLowBuffer, INDICATOR_DATA); + + // + PlotIndexSetInteger(swingLowBufferPlotIndex, PLOT_SHOW_DATA, showSwings); + PlotIndexSetInteger(swingLowBufferPlotIndex, PLOT_DRAW_TYPE, swingDrawType); + + // + PlotIndexSetDouble(swingLowBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue); + PlotIndexSetInteger(swingLowBufferPlotIndex, PLOT_ARROW, swingLowArrowCode); + + // + // SWING High ... + + // + ArraySetAsSeries(swingHighBuffer, true); + SetIndexBuffer(swingHighBufferIndex, swingHighBuffer, INDICATOR_DATA); + + // + PlotIndexSetInteger(swingHighBufferPlotIndex, PLOT_SHOW_DATA, showSwings); + PlotIndexSetInteger(swingHighBufferPlotIndex, PLOT_DRAW_TYPE, swingDrawType); + + // + PlotIndexSetDouble(swingHighBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue); + PlotIndexSetInteger(swingHighBufferPlotIndex, PLOT_ARROW, swingHighArrowCode); + + // + // Data Buffers ... + + // + ArraySetAsSeries(trendStateBuffer, true); + SetIndexBuffer(trendStateBufferIndex, trendStateBuffer, INDICATOR_CALCULATIONS); + + // + ArraySetAsSeries(kiStateBuffer, true); + SetIndexBuffer(kiStateBufferIndex, kiStateBuffer, INDICATOR_CALCULATIONS); + + // + ArraySetAsSeries(supBuffer, true); + SetIndexBuffer(supBufferIndex, supBuffer, INDICATOR_CALCULATIONS); + + // + ArraySetAsSeries(resBuffer, true); + SetIndexBuffer(resBufferIndex, resBuffer, INDICATOR_CALCULATIONS); + + // +} + +/** + * Set Indicator Short Name and also we can define Buffers Labels ... + */ +void SetIndicatorName() +{ + // + IndicatorSetInteger(INDICATOR_DIGITS, _Digits); + IndicatorSetString(INDICATOR_SHORTNAME, ShortName); +} + +/** + * Calculate Custom Buffers ... + * + * @param bar_index: Integer, Represent Current Bar ... + * @param prevCalculated: Integer, Represent Previous Calculated Bars ... + * @param ratesTotal: Integer, Represents All Available Bars ... + * @param open: Double Array, History of Open Prices ... + * @param high: Double Array, History of High Prices ... + * @param close: Double Array, History of Close Prices ... + * @param low: Double Array, History of Low Prices ... + * @param tickVolume: Long, History of Tick Volumes on Bar ... + */ +void CalculateBuffers( + int bar_index, // Selected Bar Index + const int prevCalculated, + const int ratesTotal, + const double &open[], + const double &high[], + const double &close[], + const double &low[], + const long &tickVolume[] // +) +{ + // + int barsLimit = startCalculationForLastBars > 0 + ? startCalculationForLastBars + : 0; + // + // bool canCalculate = true; + bool canCalculate = + barsLimit == 0 || + bar_index <= barsLimit; + if (canCalculate) + { + // + // Calculate Cycles ... + CalculateCycles(bar_index); + + // + // Calculate Support nad Resistance ... + CalculateValues( + bar_index, + prevCalculated, + ratesTotal, + open, + high, + close, + low, + tickVolume // + ); + + // + int swingBarIndex = bar_index; + if (bar_index < swingLength) + { + swingBarIndex = bar_index + swingLength; + } + + // // + // // Calcultae Swing High and Low and Trends ... + // CalculateSwingsAndTrend( + // swingBarIndex, + // prevCalculated, + // ratesTotal, + // open, + // high, + // close, + // low, + // tickVolume // + // ); + + // + if (bar_index < swingLength) + { + // + // for (int i = bar_index; i < bar_index + swingLength; i++) + // { + // // + // trendBuffer[i] = lTrend; + // swingLowsBuffer[i] = lSwingLow; + // swingHighsBuffer[i] = lSwingHigh; + // trendStateBuffer[i] = lTrendState; + // trendColorBuffer[i] = lTrendColor; + // } + } + } + else + { + FillBuffersZero(bar_index); + } +} + +// +// Custom ... + +/** + * Initial Market Cycles ... + * + * @return ( bool ) + */ +bool InitMarketCycles() +{ + // + bool result = false; + + // + int cPeriodSeconds = PeriodSeconds(_Period); + + // + // Find Cycle Period ... + if (scMethod == X_PERIOD_AUTO) + { + // + // Select Period ... + mSCPeriod = GetCyclePeriod( + X_MARKET_CYCLE_SHORT, + _Period // + ); + } + else + { + mSCPeriod = scPeriod; + } + + // + if (IsValid(mSCPeriod)) + { + mSCLength = PeriodSeconds(mSCPeriod) / cPeriodSeconds; + } + + // + // Find Cycle Period ... + if (mcMethod == X_PERIOD_AUTO) + { + // + // Select Period ... + mMCPeriod = GetCyclePeriod( + X_MARKET_CYCLE_MEDIUM, + _Period // + ); + } + else + { + mMCPeriod = mcPeriod; + } + + // + if (IsValid(mMCPeriod)) + { + mMCLength = PeriodSeconds(mMCPeriod) / cPeriodSeconds; + } + + // + // Find Cycle Period ... + if (lcMethod == X_PERIOD_AUTO) + { + // + // Select Period ... + mLCPeriod = GetCyclePeriod( + X_MARKET_CYCLE_LONG, + _Period // + ); + } + else + { + mLCPeriod = lcPeriod; + } + + // + if (IsValid(mLCPeriod)) + { + mLCLength = PeriodSeconds(mLCPeriod) / cPeriodSeconds; + } + + // + // Find Cycle Period ... + if (hcMethod == X_PERIOD_AUTO) + { + // + // Select Period ... + mHCPeriod = GetCyclePeriod( + X_MARKET_CYCLE_HIND, + _Period // + ); + } + else + { + mHCPeriod = hcPeriod; + } + + // + if (IsValid(mHCPeriod)) + { + mHCLength = PeriodSeconds(mHCPeriod) / cPeriodSeconds; + } + + // + result = mSCLength > 0 && + mMCLength > mSCLength && + mLCLength > mMCLength && + mHCLength > mLCLength; + + // + return result; +} + +/** + * Fill All Bufers to Zero Vlue for Specified Bar Index ... + * + * @param barIndex: Integer ... + */ +void FillBuffersZero(int barIndex) +{ + // + // SHORT ... + sHHBuffer[barIndex] = emptyValue; + sLLBuffer[barIndex] = emptyValue; + + // + // MEDIUM ... + mHHBuffer[barIndex] = emptyValue; + mLLBuffer[barIndex] = emptyValue; + + // + // LONG ... + lHHBuffer[barIndex] = emptyValue; + lLLBuffer[barIndex] = emptyValue; + + // + // HIND ... + hHHBuffer[barIndex] = emptyValue; + hLLBuffer[barIndex] = emptyValue; + + // + // SUPPORT / RESISTANCE ... + supBuffer[barIndex] = emptyValue; + resBuffer[barIndex] = emptyValue; + supportBuffer[barIndex] = emptyValue; + resistanceBuffer[barIndex] = emptyValue; + + // + // PEAKS ... + peakBuffer[barIndex] = emptyValue; + peakGoldenBuffer[barIndex] = emptyValue; + + // + // VALES ... + valeBuffer[barIndex] = emptyValue; + valeGoldenBuffer[barIndex] = emptyValue; + + // + // SAR ... + sarBuffer[barIndex] = emptyValue; + + // + // TREND ... + trendBuffer[barIndex] = emptyValue; + trendColorBuffer[barIndex] = hideColorIDX; + + // + // KI ... + kiBuffer[barIndex] = emptyValue; + kiColorBuffer[barIndex] = hideColorIDX; + + // + // SWINGS ... + swingLowBuffer[barIndex] = emptyValue; + swingHighBuffer[barIndex] = emptyValue; +} + +/** + * Calculate Specified Market Cycle Info ... + * + * @param barIndex: Integer, Bar Index ... + * @param cycle: ENUM_X_MARKET_CYCLES member, Specified Cycle ... + * @param hhBuffer: Highest High Buffer Reference ... + * @param llBuffer: Lowest Low Buffer Reference ... + */ +void CalculateCycle( + int barIndex, + ENUM_X_MARKET_CYCLES cycle, + double &hhBuffer[], + double &llBuffer[] // +) +{ + // + XOHCL bar; + bool isBarInited = bar.Init( + _Symbol, + _Period, + barIndex + // + ); + if (!isBarInited) + { + return; + } + + // + int mLength = 0; + switch (cycle) + { + // + case X_MARKET_CYCLE_SHORT: + mLength = mSCLength; + break; + + // + case X_MARKET_CYCLE_MEDIUM: + mLength = mMCLength; + break; + + // + case X_MARKET_CYCLE_LONG: + mLength = mLCLength; + break; + + // + case X_MARKET_CYCLE_HIND: + mLength = mHCLength; + break; + } + + // + if (mLength == 0) + { + return; + } + + // + // Find Highest High ... + double hhValue = bar.FindHighest( + mLength, + hhMode + // + ); + hhBuffer[barIndex] = hhValue; + + // + // Find Lowest Low ... + double llValue = bar.FindLowest( + mLength, + llMode + // + ); + llBuffer[barIndex] = llValue; +} + +/** + * Claculate Cycles ... + * + * @param barIndex: Integer, Bar Index ... + */ +void CalculateCycles(int barIndex) +{ + // + // SHORT ... + CalculateCycle( + barIndex, + X_MARKET_CYCLE_SHORT, + sHHBuffer, + sLLBuffer // + ); + + // + // MEDIUM ... + CalculateCycle( + barIndex, + X_MARKET_CYCLE_MEDIUM, + mHHBuffer, + mLLBuffer // + ); + + // + // LONG ... + CalculateCycle( + barIndex, + X_MARKET_CYCLE_LONG, + lHHBuffer, + lLLBuffer // + ); + + // + // HIND ... + CalculateCycle( + barIndex, + X_MARKET_CYCLE_HIND, + hHHBuffer, + hLLBuffer // + ); +} + +/** + * Calculate Values ... + * + * @param bar_index: int, Specified Bar Index ... + * @param prevCalculated: int, Provides Previous Calculated Bars ... + * @param ratesTotal: int, Provides All Availabled Bars ... + * @param open: double Collection, Provides Open Prices Time Series ... + * @param high: double Collection, Provides High Prices Time Series ... + * @param close: double Collection, Provides Close Prices Time Series ... + * @param low: double Collection, Provides Low Prices Time Series ... + * @param tickVolume: long Collection, Provides Ticks Volume Prices Time Series ... + */ +void CalculateValues( + int bar_index, // Selected Bar Index + const int prevCalculated, + const int ratesTotal, + const double &open[], + const double &high[], + const double &close[], + const double &low[], + const long &tickVolume[] // +) +{ + // + // Check Prev Bar ... + // + int lastBarIndex = bar_index + 1; + bool isFirstBar = + startCalculationForLastBars > 0 + ? bar_index == startCalculationForLastBars + : bar_index == ratesTotal; + + XOHCL iBar; + bool isInited = iBar.Init( + _Symbol, + _Period, + bar_index // + ); + + // + double iSHH = sHHBuffer[bar_index]; + double iSLL = sLLBuffer[bar_index]; + + // + double iMHH = mHHBuffer[bar_index]; + double iMLL = mLLBuffer[bar_index]; + + // + double iLHH = lHHBuffer[bar_index]; + double iLLL = lLLBuffer[bar_index]; + + // + double iHHH = hHHBuffer[bar_index]; + double iHLL = hLLBuffer[bar_index]; + + // + // Calculate BOS ... + + // + // Calculate CHOCH ... + + // + // Calculate Support ... + double lastSupport = + isFirstBar + ? emptyValue + : supBuffer[lastBarIndex]; + bool isSupport = iSLL == iMLL; + double iSupport = + isSupport + ? iSLL + : lastSupport; + supBuffer[bar_index] = iSupport; + + // + // Calculate Vale ... + double lastVale = + isFirstBar + ? emptyValue + : valeBuffer[lastBarIndex]; + bool isVale = + isSupport && + iMLL == iLLL && + iLLL == iHLL; + double iVale = + isVale + ? iMLL + : lastVale; + valeBuffer[bar_index] = iVale; + + // + // Calculate Resistance ... + double lastResistance = + isFirstBar + ? emptyValue + : resBuffer[lastBarIndex]; + bool isResistance = iSHH == iMHH; + double iResistance = + isResistance + ? iSHH + : lastResistance; + resBuffer[bar_index] = iResistance; + + // + // Calculate Peak ... + double lastPeak = + isFirstBar + ? emptyValue + : peakBuffer[lastBarIndex]; + bool isPeak = + isResistance && + iMHH == iLHH && + iLHH == iHHH; + double iPeak = + isPeak + ? iMHH + : lastPeak; + peakBuffer[bar_index] = iPeak; + + // + bool canSmooth = + supResSmoothingLength > 0 && + supResSmoothingMode != X_MA_MODE_NONE; + if (!canSmooth) + { + // + supportBuffer[bar_index] = iSupport; + resistanceBuffer[bar_index] = iResistance; + } + else + { + // + // Support ... + iMAOnBuffer( + ratesTotal, + prevCalculated, + bar_index, + supResSmoothingLength, + supBuffer, + supportBuffer, + supResSmoothingMode // + ); + + // + // Resistance ... + iMAOnBuffer( + ratesTotal, + prevCalculated, + bar_index, + supResSmoothingLength, + resBuffer, + resistanceBuffer, + supResSmoothingMode // + ); + } + + // + // Calculate Fibo Levels ... + + // + double iFiboUpper = peakBuffer[bar_index]; + double iFiboLower = valeBuffer[bar_index]; + + // + double iFiboLevel1 = GetFibonacciLevel( + iFiboUpper, + iFiboLower, + fiboLevel1, + X_DIRECTION_BEARISH // + ); + fiboLevel1Buffer[bar_index] = iFiboLevel1; + + // + double iFiboLevel2 = GetFibonacciLevel( + iFiboUpper, + iFiboLower, + fiboLevel2, + X_DIRECTION_BEARISH // + ); + fiboLevel2Buffer[bar_index] = iFiboLevel2; + + // + double iFiboLevel3 = GetFibonacciLevel( + iFiboUpper, + iFiboLower, + fiboLevel3, + X_DIRECTION_BEARISH // + ); + fiboLevel3Buffer[bar_index] = iFiboLevel3; + + // + // Calculate Trend Color Buffer ... + double iClose = close[bar_index]; + double iTrend = trendBuffer[bar_index]; + + // + double iTrendState = + iClose > iTrend + ? bullishColorIDX + : iClose < iTrend + ? bearishColorIDX + : neuturalColorIDX; + trendStateBuffer[bar_index] = iTrendState; + + // + double iTrendColor = + showTrend + ? iTrendState + : hideColorIDX; + trendColorBuffer[bar_index] = iTrendColor; + + // + // Calculate KI / Color ... + if (isInited) + { + // + double iLLKI = iBar.FindLowest(kiLength, MODE_LOW); + double iHHKI = iBar.FindHighest(kiLength, MODE_HIGH); + + // + double iKI = (iHHKI + iLLKI) / 2; + kiBuffer[bar_index] = iKI; + + // + double iKIState = + iClose > iKI + ? bullishColorIDX + : iClose < iKI + ? bearishColorIDX + : neuturalColorIDX; + kiStateBuffer[bar_index] = iKIState; + + // + double iKIColor = + showKI + ? iKIState + : hideColorIDX; + kiColorBuffer[bar_index] = iKIColor; + } + + // + // Calculate PV Gold ... + if (isInited) + { + // + double iPeakGold = iBar.FindHighest(mHCLength, MODE_CLOSE); + peakGoldenBuffer[bar_index] = iPeakGold; + + // + double iValeGold = iBar.FindLowest(mHCLength, MODE_CLOSE); + valeGoldenBuffer[bar_index] = iValeGold; + } + + // + // Calculate Swings ... + + // + double lastSwingLow = + isFirstBar + ? emptyValue + : swingLowBuffer[lastBarIndex]; + bool isSwingLow = IsSwingLow( + high, + low, + bar_index, + swingLength // + ); + double iSwingLow = + isSwingLow + ? low[bar_index] + : lastSwingLow; + swingLowBuffer[bar_index] = iSwingLow; + + // + double lastSwingHigh = + isFirstBar + ? emptyValue + : swingHighBuffer[lastBarIndex]; + bool isSwingHigh = IsSwingHigh( + high, + low, + bar_index, + swingLength // + ); + double iSwingHigh = + isSwingHigh + ? high[bar_index] + : lastSwingHigh; + swingHighBuffer[bar_index] = iSwingHigh; + + // + // Cleanup Resources ... + + // + iBar.Clean(); +} + +// +bool IsSwingLow( + const double &high[], + const double &low[], + int index, + int length // +) +{ + // + bool result = false; + + // + for (int i = index + 1; i <= index + length; i++) + { + // + result = low[index] < low[i]; + if (!result) + { + break; + } + } + + // + return result; +} + +// +bool IsSwingHigh( + const double &high[], + const double &low[], + int index, + int length // +) +{ + // + bool result = false; + + // + for (int i = index + 1; i <= index + length; i++) + { + // + result = high[index] > high[i]; + if (!result) + { + break; + } + } + + // + return result; +} + +// \ No newline at end of file diff --git a/Libraries/x-saherelm.x-enums.lib.mq5 b/Libraries/x-saherelm.x-enums.lib.mq5 index 9a08aafa..e2124253 100644 --- a/Libraries/x-saherelm.x-enums.lib.mq5 +++ b/Libraries/x-saherelm.x-enums.lib.mq5 @@ -568,6 +568,8 @@ enum ENUM_X_FIBO_LEVELS X_FIBO_LEVEL_382, // 0.382 X_FIBO_LEVEL_500, // 0.5 X_FIBO_LEVEL_618, // 0.618 + X_FIBO_LEVEL_730, // 0.730 + X_FIBO_LEVEL_764, // 0.764 X_FIBO_LEVEL_786, // 0.786 }; @@ -614,6 +616,16 @@ string ToString(ENUM_X_FIBO_LEVELS value) result = "0.618"; break; + // + case X_FIBO_LEVEL_730: + result = "0.730"; + break; + + // + case X_FIBO_LEVEL_764: + result = "0.764"; + break; + // case X_FIBO_LEVEL_786: result = "0.786"; @@ -664,6 +676,16 @@ double GetFiboLevelValue(ENUM_X_FIBO_LEVELS value) result = 0.618; break; + // + case X_FIBO_LEVEL_730: + result = 0.730; + break; + + // + case X_FIBO_LEVEL_764: + result = 0.764; + break; + // case X_FIBO_LEVEL_786: result = 0.786; diff --git a/Libraries/x-saherelm.x-ohcl.lib.mq5 b/Libraries/x-saherelm.x-ohcl.lib.mq5 index 5570b8fb..943f9d77 100644 --- a/Libraries/x-saherelm.x-ohcl.lib.mq5 +++ b/Libraries/x-saherelm.x-ohcl.lib.mq5 @@ -1049,6 +1049,46 @@ struct XOHCL return result; } + // + bool IsBreaked( + double price, + ENUM_X_DIRECTION forDir // + ) + { + // + bool result = false; + + // + result = IsValid() && + price > 0 && + HasDirection(forDir); + if (!result) + { + return result; + } + + // + bool isBullish = + IsBullish() && + IsBullish(forDir) && + close > price && + open < price; + + // + bool isBearish = + IsBearish() && + IsBearish(forDir) && + close < price && + open > price; + + // + result = isBullish || + isBearish; + + // + return result; + } + // // Find Highest Bar Index ... int FindHighestIndex( diff --git a/XSTRCCI/Classes/xstrcci.x-trade.manager.class.mq5 b/XCAEA/Classes/xcaea.x-trade.manager.class.mq5 similarity index 73% rename from XSTRCCI/Classes/xstrcci.x-trade.manager.class.mq5 rename to XCAEA/Classes/xcaea.x-trade.manager.class.mq5 index c1cc44d6..e8628b90 100644 --- a/XSTRCCI/Classes/xstrcci.x-trade.manager.class.mq5 +++ b/XCAEA/Classes/xcaea.x-trade.manager.class.mq5 @@ -2,7 +2,7 @@ // // SaherElm IT Center MQL5 Class Library // -------------------------------------- -// Name: XCXSTRCCITradeManager +// Name: XCXCAEATradeManager // Description: provides all Requirements for Managing Trades ... // // @@ -24,23 +24,23 @@ #include "../../Classes/x-saherelm.x-alert.class.mq5" #include "../../Classes/x-saherelm.x-poi.drawer.class.mq5" #include "../../Classes/x-saherelm.x-trade.class.mq5" -#include "../Libraries/xstrcci.signaller.lib.mq5" +#include "../Libraries/xcaea.signaller.lib.mq5" // // Definitions ... // -enum ENUM_XSTRCCI_TRADE_FINALIZATION +enum ENUM_XCAEA_TRADE_FINALIZATION { - XSTRCCI_TRADE_FINAL_NONE, - XSTRCCI_TRADE_FINAL_TP, - XSTRCCI_TRADE_FINAL_SL, - XSTRCCI_TRADE_FINAL_CLOSE_IN_PROFIT, - XSTRCCI_TRADE_FINAL_CLOSE_IN_LOSE, + XCAEA_TRADE_FINAL_NONE, + XCAEA_TRADE_FINAL_TP, + XCAEA_TRADE_FINAL_SL, + XCAEA_TRADE_FINAL_CLOSE_IN_PROFIT, + XCAEA_TRADE_FINAL_CLOSE_IN_LOSE, }; // -struct XSTRCCITrade +struct XCAEATrade { // // Props ... @@ -49,12 +49,12 @@ struct XSTRCCITrade XSignal signal; ulong positionID; double commission; - XSTRCCIStrategyConditions conditions; - ENUM_XSTRCCI_TRADE_FINALIZATION finalize; + XCAEAStrategyConditions conditions; + ENUM_XCAEA_TRADE_FINALIZATION finalize; // // Constructor ... - XSTRCCITrade() + XCAEATrade() { Clean(); } @@ -74,7 +74,7 @@ struct XSTRCCITrade commission = 0; positionID = 0; conditions.Clean(); - finalize = XSTRCCI_TRADE_FINAL_NONE; + finalize = XCAEA_TRADE_FINAL_NONE; // ZeroMemory(this); @@ -127,7 +127,7 @@ struct XSTRCCITrade // result = HasSignal() && IsExecuted() && - finalize != XSTRCCI_TRADE_FINAL_NONE; + finalize != XCAEA_TRADE_FINAL_NONE; // return result; @@ -136,7 +136,7 @@ struct XSTRCCITrade // // Implementations ... -class XCXSTRCCITradeManager : public XCBaseAlert +class XCXCAEATradeManager : public XCBaseAlert { // // Public ... @@ -149,7 +149,7 @@ class XCXSTRCCITradeManager : public XCBaseAlert // // Constructors ... - XCXSTRCCITradeManager(XCTrade *&_trader) + XCXCAEATradeManager(XCTrade *&_trader) { // trader = _trader; @@ -159,7 +159,7 @@ class XCXSTRCCITradeManager : public XCBaseAlert // // De Constructors ... - ~XCXSTRCCITradeManager() + ~XCXCAEATradeManager() { // ZeroMemory(trader); @@ -220,6 +220,10 @@ class XCXSTRCCITradeManager : public XCBaseAlert */ void Protect() { + // + string prefix = "Protector: "; + int targetDistance = 5; + // bool has = HasChild(trades); if (!has) @@ -324,9 +328,94 @@ class XCXSTRCCITradeManager : public XCBaseAlert // // Select Position ... XPosition iPosition = ownPosition[i]; + int idx = -1; + has = HasTrade( + idx, + iPosition.ticket // + ); + if (!has) + { + continue; + } // - // Handle RF ... + bool isLong = IsLong(iPosition.type); + double points = GetPoints(iPosition.symbol); + + // + // Handle RF On Targets ... + if (iPosition.profit > 0) + { + // + double targets[]; + Copy( + trades[idx].signal.targets, + targets // + ); + int targetsCount = ArraySize(targets); + has = IsValidSize(targetsCount); + if (has) + { + // + for (int j = 0; j < targetsCount; j++) + { + // + double jTarget = targets[j]; + + // + // Check Traget Validation ... + has = + iPosition.sl == 0 + ? true + : isLong + ? iPosition.sl < jTarget + : iPosition.sl > jTarget; + if (!has) + { + continue; + } + + // + double targetDelta = isLong + ? jTarget + (targetDistance * points) + : jTarget - (targetDistance * points); + + // + // Can Risk Free ... + bool canRF = jTarget > 0 && + (isLong + ? jTarget > iPosition.entry + : jTarget < iPosition.entry) && + (isLong + ? iPosition.price > targetDelta + : iPosition.price < targetDelta); + if (canRF) + { + // + double sl = jTarget; + double tp = iPosition.tp; + string comment = "RF On Target ..."; + bool isModified = trader.Modify( + iPosition.ticket, + sl, + tp, + comment // + ); + if (isModified) + { + // + string message = prefix + + ToString(iPosition.type) + + " Position: " + + ToString(iPosition.ticket) + + " RF On Traget: " + ToString(jTarget) + + " Successfully ..."; + Alert(message); + } + } + } + } + } } } @@ -334,13 +423,13 @@ class XCXSTRCCITradeManager : public XCBaseAlert * Execute Specified Signal ... * * @param signal: XSignal instance reference ... - * @param conditions: XSTRCCIStrategyConditions instance reference ... + * @param conditions: XCAEAStrategyConditions instance reference ... * * @return ( bool ) */ bool Execute( XSignal &signal, - XSTRCCIStrategyConditions &conditions // + XCAEAStrategyConditions &conditions // ) { // @@ -400,7 +489,7 @@ class XCXSTRCCITradeManager : public XCBaseAlert } // - XSTRCCITrade iTrade; + XCAEATrade iTrade; // ulong positionID = trader.GetLastOpenPositionTicket(); @@ -447,7 +536,7 @@ class XCXSTRCCITradeManager : public XCBaseAlert trades[idx].swap = deal.swap; trades[idx].profit = deal.profit; trades[idx].commission = deal.commission; - trades[idx].finalize = XSTRCCI_TRADE_FINAL_TP; + trades[idx].finalize = XCAEA_TRADE_FINAL_TP; // tpCount++; @@ -480,7 +569,7 @@ class XCXSTRCCITradeManager : public XCBaseAlert trades[idx].swap = deal.swap; trades[idx].profit = deal.profit; trades[idx].commission = deal.commission; - trades[idx].finalize = XSTRCCI_TRADE_FINAL_SL; + trades[idx].finalize = XCAEA_TRADE_FINAL_SL; // slCount++; @@ -517,8 +606,8 @@ class XCXSTRCCITradeManager : public XCBaseAlert trades[idx].profit = position.profit; trades[idx].commission = position.commission; trades[idx].finalize = isInProfit - ? XSTRCCI_TRADE_FINAL_CLOSE_IN_PROFIT - : XSTRCCI_TRADE_FINAL_CLOSE_IN_LOSE; + ? XCAEA_TRADE_FINAL_CLOSE_IN_PROFIT + : XCAEA_TRADE_FINAL_CLOSE_IN_LOSE; // if (isInProfit) @@ -576,7 +665,7 @@ class XCXSTRCCITradeManager : public XCBaseAlert for (int i = 0; i < count; i++) { // - XSTRCCITrade iTrade = trades[i]; + XCAEATrade iTrade = trades[i]; // result = @@ -636,7 +725,7 @@ class XCXSTRCCITradeManager : public XCBaseAlert for (int i = 0; i < count; i++) { // - XSTRCCITrade iTrade = trades[i]; + XCAEATrade iTrade = trades[i]; // result = @@ -687,7 +776,7 @@ class XCXSTRCCITradeManager : public XCBaseAlert CArrayObj mObjects; // - XSTRCCITrade trades[]; + XCAEATrade trades[]; }; // diff --git a/XSTRCCI/Helpers/xstrcci.helper.mq5 b/XCAEA/Helpers/xcaea.helper.mq5 similarity index 61% rename from XSTRCCI/Helpers/xstrcci.helper.mq5 rename to XCAEA/Helpers/xcaea.helper.mq5 index e04501f9..8c0750b7 100644 --- a/XSTRCCI/Helpers/xstrcci.helper.mq5 +++ b/XCAEA/Helpers/xcaea.helper.mq5 @@ -2,7 +2,7 @@ // // SaherElm IT Center MQL5 Helper Class Library // ---------------------------------------------- -// Name: XCXSTRCCIHelper +// Name: XCXCAEAHelper // Description: provides all Indicator // Helper requirements ... // @@ -25,17 +25,14 @@ #include "../../Classes/x-saherelm.x-bar.analyser.class.mq5" #include "../../Classes/x-saherelm.x-poi.class.mq5" #include "../../Classes/x-saherelm.x-poi.drawer.class.mq5" -#include "../../Helpers/x-saherelm.x121.x3ma.helper.mq5" +#include "../../Helpers/x-saherelm.x121.xca.helper.mq5" #include "../../Helpers/x-saherelm.x121.xcc.helper.mq5" #include "../../Helpers/x-saherelm.x121.xct.helper.mq5" -#include "../../Helpers/x-saherelm.x121.xich.helper.mq5" #include "../../Helpers/x-saherelm.x121.xoscs.helper.mq5" -#include "../../Helpers/x-saherelm.x121.xpv.helper.mq5" -#include "../../Helpers/x-saherelm.x121.xstr.helper.mq5" // // Input Structure ... -struct XSTRCCIInputs +struct XCAEAInputs { // bool showAC; @@ -53,15 +50,12 @@ struct XSTRCCIInputs // X121XCTInputs ctInputs; X121XCCInputs ccInputs; - X121XPVInputs pvInputs; - X121X3MAInputs ma3Inputs; - X121XICHInputs ichInputs; - X121XSTRInputs strInputs; + X121XCAInputs caInputs; X121XOCSInputs oscsInputs; // // Constructor ... - XSTRCCIInputs() + XCAEAInputs() { Clean(); } @@ -90,10 +84,7 @@ struct XSTRCCIInputs // ctInputs.Clean(); ccInputs.Clean(); - pvInputs.Clean(); - ma3Inputs.Clean(); - ichInputs.Clean(); - strInputs.Clean(); + caInputs.Clean(); oscsInputs.Clean(); // @@ -108,10 +99,7 @@ struct XSTRCCIInputs // ctInputs.Default(); ccInputs.Default(); - pvInputs.Default(); - ma3Inputs.Default(); - ichInputs.Default(); - strInputs.Default(); + caInputs.Default(); oscsInputs.Default(); } @@ -130,10 +118,7 @@ struct XSTRCCIInputs // ctInputs.IsValid() && ccInputs.IsValid() && - pvInputs.IsValid() && - ma3Inputs.IsValid() && - ichInputs.IsValid() && - strInputs.IsValid() && + caInputs.IsValid() && oscsInputs.IsValid() // ; @@ -155,19 +140,13 @@ struct XSTRCCIInputs // int ctMax = ctInputs.Max(); int ccMax = ccInputs.Max(); - int pvMax = pvInputs.Max(); - int ma3Max = ma3Inputs.Max(); - int ichMax = ichInputs.Max(); - int strMax = strInputs.Max(); + int caMax = caInputs.Max(); int ocsMax = oscsInputs.Max(); // - result = MathMax(strMax, ocsMax); - result = MathMax(result, ma3Max); - result = MathMax(result, ichMax); - result = MathMax(result, pvMax); - result = MathMax(result, ccMax); - result = MathMax(result, ctMax); + result = MathMax(ctMax, ccMax); + result = MathMax(result, caMax); + result = MathMax(result, ocsMax); // return result; @@ -176,7 +155,7 @@ struct XSTRCCIInputs // // Conditions Structure ... -struct XSTRCCIConditions +struct XCAEAConditions { // // Common ... @@ -185,16 +164,13 @@ struct XSTRCCIConditions datetime time; // - // XPV ... + // XCA ... // // Buffers ... // - // Buffers ... - double sarBuffer[]; - double cHHBuffer[]; - double cLLBuffer[]; + double kiBuffer[]; double sHHBuffer[]; double sLLBuffer[]; double mHHBuffer[]; @@ -203,23 +179,40 @@ struct XSTRCCIConditions double lLLBuffer[]; double hHHBuffer[]; double hLLBuffer[]; + double sarBuffer[]; + double peakBuffer[]; + double valeBuffer[]; double trendBuffer[]; - double peaksBuffer[]; - double valesBuffer[]; - double supportsBuffer[]; - double swingLowsBuffer[]; - double swingHighsBuffer[]; - double trendColorBuffer[]; + double kiStateBuffer[]; + double supportBuffer[]; + double swingLowBuffer[]; + double swingHighBuffer[]; + double resistanceBuffer[]; + double peakGoldenBuffer[]; + double valeGoldenBuffer[]; + double fiboLevel1Buffer[]; + double fiboLevel2Buffer[]; + double fiboLevel3Buffer[]; double trendStateBuffer[]; - double peaksGoldenBuffer[]; - double valesGoldenBuffer[]; - double resistancesBuffer[]; - double fractalsUpperBuffer[]; - double fractalsLowerBuffer[]; // // Conditions ... + // + // KI ... + + // + bool isKIRejectUp; + bool isKIRejectDown; + + // + bool isKIBullish; + bool isKIBearish; + + // + bool isKISwitchedToBullish; + bool isKISwitchedToBearish; + // // SAR ... @@ -232,220 +225,102 @@ struct XSTRCCIConditions bool isSarSwitchedToBearish; // - // XPV ... + // PEAK ... // - bool isNewPeak; - bool isNewPeakOverLast; - bool isNewPeakUnderLast; + bool isPeakSameLast; + bool isPeakOverLast; + bool isPeakUnderLast; // - bool isNewVale; - bool isNewValeOverLast; - bool isNewValeUnderLast; + // VALE ... // - // XSTR ... + bool isValeSameLast; + bool isValeOverLast; + bool isValeUnderLast; // - // Buffers ... + // TREND ... // - double strBuffer[]; - double vidyaBuffer[]; - double strUpBuffer[]; - double strDownBuffer[]; - double strPriceBuffer[]; - double strStateBuffer[]; - double strSMLowBuffer[]; - double strSMHighBuffer[]; + bool isTrendRejectUp; + bool isTrendRejectDown; // - // Conditions ... + bool isTrendBullish; + bool isTrendBearish; // - // STR ... + bool isTrendSwitchedToBullish; + bool isTrendSwitchedToBearish; // - bool isStrBullish; - bool isStrBearish; + // SUPPORT ... // - bool isStrSwitchedToBullish; - bool isStrSwitchedToBearish; + bool isSupportSameLast; + bool isSupportOverLast; + bool isSupportUnderLast; // - // VIDYA ... + bool isLastSupportBreaked; + bool isLastSupportRejected; // - bool isRejectUpVidya; - bool isCloseOverVidya; - bool isCrossedOverVidya; + // RESISTANCE ... // - bool isRejectDownVidya; - bool isCloseUnderVidya; - bool isCrossedUnderVidya; + bool isResistanceSameLast; + bool isResistanceOverLast; + bool isResistanceUnderLast; // - // HMS ... + bool isLastResistanceBreaked; + bool isLastResistanceRejected; // - bool isRejectUpLSM; - bool isCloseOverLSM; - bool isCrossedOverLSM; + // SWING Low ... // - bool isRejectDownLSM; - bool isCloseUnderLSM; - bool isCrossedUnderLSM; + bool isSwingLowSameLast; + bool isSwingLowOverLast; + bool isSwingLowUnderLast; // - // HSM .. + bool isLastSwingLowBreaked; + bool isLastSwingLowRejected; // - bool isRejectUpHSM; - bool isCloseOverHSM; - bool isCrossedOverHSM; + // SWING High ... // - bool isRejectDownHSM; - bool isCloseUnderHSM; - bool isCrossedUnderHSM; + bool isSwingHighSameLast; + bool isSwingHighOverLast; + bool isSwingHighUnderLast; // - // STR ... + bool isLastSwingHighBreaked; + bool isLastSwingHighRejected; // - bool isRejectUpStr; - bool isCloseOverStr; - bool isCrossedOverStr; + // COMPLEX Conditions ... // - bool isRejectDownStr; - bool isCloseUnderStr; - bool isCrossedUnderStr; + bool isPeakIsPivot; + bool isValeIsPivot; // - // HSM / ViDYA ... + bool isSwingLowSameAsVale; + bool isSwingHighSameAsPeak; // - bool isVidyaOverHSM; - bool isVidyaCrossedOverHSM; + bool isSupportSameAsVale; + bool isResistanceSameAsPeak; // - bool isVidyaUnderHSM; - bool isVidyaCrossedUnderHSM; - - // - // LSM / VIDYA ... - - // - bool isVidyaOverLSM; - bool isVidyaCrossedOverLSM; - - // - bool isVidyaUnderLSM; - bool isVidyaCrossedUnderLSM; - - // - // STR / VIDYA ... - - // - bool isVidyaOverStr; - bool isVidyaCrossedOverStr; - - // - bool isVidyaUnderStr; - bool isVidyaCrossedUnderStr; - - // - // X3MA ... - - // - // Buffers ... - double x3maFastBuffer[]; - double x3maMidBuffer[]; - double x3maSlowBuffer[]; - double x3maFastStateBuffer[]; - double x3maMidStateBuffer[]; - double x3maSlowStateBuffer[]; - - // - // Conditions ... - - // - bool isX3MaFastBullish; - bool isX3MaFastBearish; - bool isX3MaFastNeutural; - - // - bool isX3MaMidBullish; - bool isX3MaMidBearish; - bool isX3MaMidNeutural; - - // - bool isX3MaSlowBullish; - bool isX3MaSlowBearish; - bool isX3MaSlowNeutural; - - // - bool isX3MaFastOverMid; - bool isX3MaMidOverSlow; - - // - bool isX3MaFastUnderMid; - bool isX3MaMidUnderSlow; - - // - bool isX3MaBullishState; - bool isX3MaBearishState; - bool isX3MaNeuturalState; - - // - bool isX3MaBullishOrdered; - bool isX3MaBearishOrdered; - - // - bool isX3MaSwitchedToBullishOrdered; - bool isX3MaSwitchedToBearishOrdered; - - // - bool isX3MaSwitchedToBullishState; - bool isX3MaSwitchedToBearishState; - bool isX3MaSwitchedToNeuturalState; - - // - // XICH ... - - // - // Buffers ... - - // - double kijunSenBuffer[]; - double tenkanSenBuffer[]; - double chikouSpanBuffer[]; - double senkouSpanABuffer[]; - double senkouSpanBBuffer[]; - - // - // Conditions ... - - // - bool isTenkanSenOverKijunSen; - bool isTenkanSenUnderKijunSen; - - // - bool isTenkanSenCrossedOverKijunSen; - bool isTenkanSenCrossedUnderKijunSen; - - // - bool isSenkouSpanAOverB; - bool isSenkouSpanAUnderB; - - // - bool isSenkouSpanACrossedOverB; - bool isSenkouSpanACrossedUnderB; + bool isSupportSameAsSwingLow; + bool isResistanceSameAsSwingHigh; // // XOSCS ... @@ -685,7 +560,7 @@ struct XSTRCCIConditions // // Constructor ... - XSTRCCIConditions() + XCAEAConditions() { Clean(); } @@ -705,15 +580,13 @@ struct XSTRCCIConditions time = NULL; // - // XPV ... + // XCA ... // // Buffers ... // - Clean(sarBuffer); - Clean(cHHBuffer); - Clean(cLLBuffer); + Clean(kiBuffer); Clean(sHHBuffer); Clean(sLLBuffer); Clean(mHHBuffer); @@ -722,28 +595,24 @@ struct XSTRCCIConditions Clean(lLLBuffer); Clean(hHHBuffer); Clean(hLLBuffer); + Clean(sarBuffer); + Clean(peakBuffer); + Clean(valeBuffer); Clean(trendBuffer); - Clean(peaksBuffer); - Clean(valesBuffer); - Clean(supportsBuffer); - Clean(swingLowsBuffer); - Clean(swingHighsBuffer); - Clean(trendColorBuffer); + Clean(kiStateBuffer); + Clean(supportBuffer); + Clean(swingLowBuffer); + Clean(swingHighBuffer); + Clean(resistanceBuffer); + Clean(peakGoldenBuffer); + Clean(valeGoldenBuffer); + Clean(fiboLevel1Buffer); + Clean(fiboLevel2Buffer); + Clean(fiboLevel3Buffer); Clean(trendStateBuffer); - Clean(peaksGoldenBuffer); - Clean(valesGoldenBuffer); - Clean(resistancesBuffer); - Clean(fractalsUpperBuffer); - Clean(fractalsLowerBuffer); // - // Clean(bullishTrendBuffer); - // Clean(bearishTrendBuffer); - - // - ArraySetAsSeries(sarBuffer, true); - ArraySetAsSeries(cHHBuffer, true); - ArraySetAsSeries(cLLBuffer, true); + ArraySetAsSeries(kiBuffer, true); ArraySetAsSeries(sHHBuffer, true); ArraySetAsSeries(sLLBuffer, true); ArraySetAsSeries(mHHBuffer, true); @@ -752,23 +621,43 @@ struct XSTRCCIConditions ArraySetAsSeries(lLLBuffer, true); ArraySetAsSeries(hHHBuffer, true); ArraySetAsSeries(hLLBuffer, true); + ArraySetAsSeries(sarBuffer, true); + ArraySetAsSeries(peakBuffer, true); + ArraySetAsSeries(valeBuffer, true); ArraySetAsSeries(trendBuffer, true); - ArraySetAsSeries(peaksBuffer, true); - ArraySetAsSeries(valesBuffer, true); - ArraySetAsSeries(supportsBuffer, true); - ArraySetAsSeries(swingLowsBuffer, true); - ArraySetAsSeries(swingHighsBuffer, true); - ArraySetAsSeries(trendColorBuffer, true); + ArraySetAsSeries(kiStateBuffer, true); + ArraySetAsSeries(supportBuffer, true); + ArraySetAsSeries(swingLowBuffer, true); + ArraySetAsSeries(swingHighBuffer, true); + ArraySetAsSeries(resistanceBuffer, true); + ArraySetAsSeries(peakGoldenBuffer, true); + ArraySetAsSeries(valeGoldenBuffer, true); + ArraySetAsSeries(fiboLevel1Buffer, true); + ArraySetAsSeries(fiboLevel2Buffer, true); + ArraySetAsSeries(fiboLevel3Buffer, true); ArraySetAsSeries(trendStateBuffer, true); - ArraySetAsSeries(peaksGoldenBuffer, true); - ArraySetAsSeries(valesGoldenBuffer, true); - ArraySetAsSeries(resistancesBuffer, true); - ArraySetAsSeries(fractalsUpperBuffer, true); - ArraySetAsSeries(fractalsLowerBuffer, true); // // Conditions ... + // + // KI ... + + // + isKIRejectUp = false; + isKIRejectDown = false; + + // + isKIBullish = false; + isKIBearish = false; + + // + isKISwitchedToBullish = false; + isKISwitchedToBearish = false; + + // + // SAR ... + // isSarBullish = false; isSarBearish = false; @@ -778,192 +667,102 @@ struct XSTRCCIConditions isSarSwitchedToBearish = false; // - isNewPeak = false; - isNewPeakOverLast = false; - isNewPeakUnderLast = false; + // PEAK ... // - isNewVale = false; - isNewValeOverLast = false; - isNewValeUnderLast = false; + isPeakSameLast = false; + isPeakOverLast = false; + isPeakUnderLast = false; // - // XSTR ... + // VALE ... // - // Buffers ... + isValeSameLast = false; + isValeOverLast = false; + isValeUnderLast = false; // - Clean(strBuffer); - Clean(atrBuffer); - Clean(vidyaBuffer); - Clean(strUpBuffer); - Clean(strDownBuffer); - Clean(strPriceBuffer); - Clean(strStateBuffer); - Clean(strSMLowBuffer); - Clean(strSMHighBuffer); + // TREND ... // - ArraySetAsSeries(strBuffer, true); - ArraySetAsSeries(atrBuffer, true); - ArraySetAsSeries(vidyaBuffer, true); - ArraySetAsSeries(strUpBuffer, true); - ArraySetAsSeries(strDownBuffer, true); - ArraySetAsSeries(strPriceBuffer, true); - ArraySetAsSeries(strStateBuffer, true); - ArraySetAsSeries(strSMLowBuffer, true); - ArraySetAsSeries(strSMHighBuffer, true); + isTrendRejectUp = false; + isTrendRejectDown = false; // - // Conditions ... + isTrendBullish = false; + isTrendBearish = false; // - 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; - isCloseOverVidya = 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; + isTrendSwitchedToBullish = false; + isTrendSwitchedToBearish = false; // - // X3MA ... + // SUPPORT ... // - // Buffers ... + isSupportSameLast = false; + isSupportOverLast = false; + isSupportUnderLast = false; // - Clean(x3maFastBuffer); - Clean(x3maMidBuffer); - Clean(x3maSlowBuffer); - Clean(x3maFastStateBuffer); - Clean(x3maMidStateBuffer); - Clean(x3maSlowStateBuffer); + isLastSupportBreaked = false; + isLastSupportRejected = false; // - ArraySetAsSeries(x3maFastBuffer, true); - ArraySetAsSeries(x3maMidBuffer, true); - ArraySetAsSeries(x3maSlowBuffer, true); - ArraySetAsSeries(x3maFastStateBuffer, true); - ArraySetAsSeries(x3maMidStateBuffer, true); - ArraySetAsSeries(x3maSlowStateBuffer, true); + // RESISTANCE ... // - // Conditions ... + isResistanceSameLast = false; + isResistanceOverLast = false; + isResistanceUnderLast = false; // - isX3MaFastBullish = false; - isX3MaFastBearish = false; - isX3MaFastNeutural = false; + isLastResistanceBreaked = false; + isLastResistanceRejected = false; // - isX3MaMidBullish = false; - isX3MaMidBearish = false; - isX3MaMidNeutural = false; + // SWING Low ... // - isX3MaSlowBullish = false; - isX3MaSlowBearish = false; - isX3MaSlowNeutural = false; + isSwingLowSameLast = false; + isSwingLowOverLast = false; + isSwingLowUnderLast = false; // - isX3MaFastOverMid = false; - isX3MaMidOverSlow = false; + isLastSwingLowBreaked = false; + isLastSwingLowRejected = false; // - isX3MaFastUnderMid = false; - isX3MaMidUnderSlow = false; + // SWING High ... // - isX3MaBullishState = false; - isX3MaBearishState = false; - isX3MaNeuturalState = false; + isSwingHighSameLast = false; + isSwingHighOverLast = false; + isSwingHighUnderLast = false; // - isX3MaBullishOrdered = false; - isX3MaBearishOrdered = false; + isLastSwingHighBreaked = false; + isLastSwingHighRejected = false; // - isX3MaSwitchedToBullishOrdered = false; - isX3MaSwitchedToBearishOrdered = false; + // COMPLEX Conditions ... // - isX3MaSwitchedToBullishState = false; - isX3MaSwitchedToBearishState = false; - isX3MaSwitchedToNeuturalState = false; + isPeakIsPivot = false; + isValeIsPivot = false; // - // XICH ... + isSwingLowSameAsVale = false; + isSwingHighSameAsPeak = false; // - // Buffers ... + isSupportSameAsVale = false; + isResistanceSameAsPeak = false; // - Clean(kijunSenBuffer); - Clean(tenkanSenBuffer); - Clean(chikouSpanBuffer); - Clean(senkouSpanABuffer); - Clean(senkouSpanBBuffer); - - // - ArraySetAsSeries(kijunSenBuffer, true); - ArraySetAsSeries(tenkanSenBuffer, true); - ArraySetAsSeries(chikouSpanBuffer, true); - ArraySetAsSeries(senkouSpanABuffer, true); - ArraySetAsSeries(senkouSpanBBuffer, true); - - // - // Conditions ... - - // - isTenkanSenOverKijunSen = false; - isTenkanSenUnderKijunSen = false; - - // - isTenkanSenCrossedOverKijunSen = false; - isTenkanSenCrossedUnderKijunSen = false; - - // - isSenkouSpanAOverB = false; - isSenkouSpanAUnderB = false; - - // - isSenkouSpanACrossedOverB = false; - isSenkouSpanACrossedUnderB = false; + isSupportSameAsSwingLow = false; + isResistanceSameAsSwingHigh = false; // // XOSCS ... @@ -1176,7 +975,41 @@ struct XSTRCCIConditions double highScore = 1.5; // - // XPV ... + // XCA ... + + // + // KI ... + + // + if (isKIBullish) + { + bullishScore += minScore; + } + if (isKIRejectUp) + { + bullishScore += minScore; + } + if (isKISwitchedToBullish) + { + bullishScore += minScore; + } + + // + if (isKIBearish) + { + bearishScore += minScore; + } + if (isKIRejectDown) + { + bearishScore += minScore; + } + if (isKISwitchedToBearish) + { + bearishScore += minScore; + } + + // + // SAR ... // if (isSarBullish) @@ -1185,7 +1018,7 @@ struct XSTRCCIConditions } if (isSarSwitchedToBullish) { - bullishScore += score; + bullishScore += minScore; } // @@ -1195,304 +1028,185 @@ struct XSTRCCIConditions } if (isSarSwitchedToBearish) { - bearishScore += score; + bearishScore += minScore; } // - // XSTR ... + // TREND ... // - if (isStrBullish) + if (isTrendBullish) { bullishScore += minScore; } - if (isStrSwitchedToBullish) + if (isTrendRejectUp) + { + bullishScore += minScore; + } + if (isTrendSwitchedToBullish) + { + bullishScore += minScore; + } + + // + if (isTrendBearish) + { + bearishScore += minScore; + } + if (isTrendRejectDown) + { + bearishScore += minScore; + } + if (isTrendSwitchedToBearish) + { + bearishScore += minScore; + } + + // + // SUPPORT ... + + // + if (isSupportSameLast) + { + bullishScore += minScore; + } + if (isSupportOverLast) + { + bullishScore += minScore; + } + if (isLastSupportRejected) + { + bullishScore += minScore; + } + + // + if (isSupportUnderLast) + { + bearishScore += minScore; + } + if (isLastSupportBreaked) + { + bearishScore += minScore; + } + + // + // RESISTANCE ... + + // + if (isResistanceOverLast) + { + bullishScore += minScore; + } + if (isLastResistanceBreaked) + { + bullishScore += minScore; + } + + // + if (isResistanceSameLast) + { + bearishScore += minScore; + } + if (isResistanceUnderLast) + { + bearishScore += minScore; + } + if (isLastResistanceRejected) + { + bearishScore += minScore; + } + + // + // SWING Low ... + + // + if (isSwingLowSameLast) + { + bullishScore += minScore; + } + if (isSwingLowOverLast) + { + bullishScore += minScore; + } + if (isLastSwingLowRejected) + { + bullishScore += minScore; + } + + // + if (isSwingLowUnderLast) + { + bearishScore += minScore; + } + if (isLastSwingLowBreaked) + { + bearishScore += minScore; + } + + // + // SWING High ... + + // + if (isSwingHighOverLast) + { + bullishScore += minScore; + } + if (isLastSwingHighBreaked) + { + bullishScore += minScore; + } + + // + if (isSwingHighSameLast) + { + bearishScore += minScore; + } + if (isSwingHighUnderLast) + { + bearishScore += minScore; + } + if (isLastSwingHighRejected) + { + bearishScore += minScore; + } + + // + // COMPLEX Conditions ... + + // + if (isValeIsPivot) { bullishScore += score; } - if (isRejectUpVidya) - { - bullishScore += minScore; - } - if (isCloseOverVidya) - { - 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) - { - bearishScore += minScore; - } - if (isStrSwitchedToBearish) - { - 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; - } - - // - // X3MA ... - - // - if (isX3MaBullishState) + if (isSupportSameAsVale) { bullishScore += score; } - if (isX3MaBullishOrdered) + if (isSwingLowSameAsVale) { bullishScore += score; } - if (isX3MaSwitchedToBullishState) + if (isSupportSameAsSwingLow) { - bullishScore += highScore; - } - if (isX3MaSwitchedToBullishOrdered) - { - bullishScore += highScore; - } - if (!isX3MaBullishState && - !isX3MaSwitchedToBullishState) - { - // - if (isX3MaFastBullish) - { - bullishScore += minScore; - } - if (isX3MaSlowBullish) - { - bullishScore += minScore; - } - } - if (!isX3MaBullishOrdered && - !isX3MaSwitchedToBullishOrdered) - { - // - if (isX3MaFastOverMid) - { - bullishScore += minScore; - } - if (isX3MaMidOverSlow) - { - bullishScore += minScore; - } + bullishScore += score; } // - if (isX3MaBearishState) + if (isPeakIsPivot) { bearishScore += score; } - if (isX3MaBearishOrdered) + if (isSwingHighSameAsPeak) { bearishScore += score; } - if (isX3MaSwitchedToBearishState) + if (isResistanceSameAsPeak) { - bearishScore += highScore; + bearishScore += score; } - if (isX3MaSwitchedToBearishOrdered) + if (isResistanceSameAsSwingHigh) { - bearishScore += highScore; - } - if (!isX3MaBearishState && - !isX3MaSwitchedToBearishState) - { - // - if (isX3MaFastBearish) - { - bearishScore += minScore; - } - if (isX3MaSlowBearish) - { - bearishScore += minScore; - } - } - if (!isX3MaBearishOrdered && - !isX3MaSwitchedToBearishOrdered) - { - // - if (isX3MaFastUnderMid) - { - bearishScore += minScore; - } - if (isX3MaMidUnderSlow) - { - bearishScore += minScore; - } - } - - // - // XICH ... - - // - if (isSenkouSpanAOverB) - { - bullishScore += minScore; - } - if (isTenkanSenOverKijunSen) - { - bullishScore += minScore; - } - if (isSenkouSpanACrossedOverB) - { - bullishScore += highScore; - } - if (isTenkanSenCrossedOverKijunSen) - { - bullishScore += highScore; - } - - // - if (isSenkouSpanAUnderB) - { - bearishScore += minScore; - } - if (isTenkanSenUnderKijunSen) - { - bearishScore += minScore; - } - if (isSenkouSpanACrossedUnderB) - { - bearishScore += highScore; - } - if (isTenkanSenCrossedUnderKijunSen) - { - bearishScore += highScore; + bearishScore += score; } // @@ -1973,98 +1687,58 @@ struct XSTRCCIConditions // // "-----------------------" + separator + - "XPV: " + separator + + "XCA: " + separator + "-----------------------" + separator + + ToString("isKIRejectUp", isKIRejectUp, ignoreFalseConditions, separator) + + ToString("isKIRejectDown", isKIRejectDown, ignoreFalseConditions, separator) + + ToString("isKIBullish", isKIBullish, ignoreFalseConditions, separator) + + ToString("isKIBearish", isKIBearish, ignoreFalseConditions, separator) + + ToString("isKISwitchedToBullish", isKISwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isKISwitchedToBearish", isKISwitchedToBearish, ignoreFalseConditions, separator) + ToString("isSarBullish", isSarBullish, ignoreFalseConditions, separator) + ToString("isSarBearish", isSarBearish, ignoreFalseConditions, separator) + ToString("isSarSwitchedToBullish", isSarSwitchedToBullish, ignoreFalseConditions, separator) + ToString("isSarSwitchedToBearish", isSarSwitchedToBearish, ignoreFalseConditions, separator) + - ToString("isNewPeak", isNewPeak, ignoreFalseConditions, separator) + - ToString("isNewPeakOverLast", isNewPeakOverLast, ignoreFalseConditions, separator) + - ToString("isNewPeakUnderLast", isNewPeakUnderLast, ignoreFalseConditions, separator) + - ToString("isNewVale", isNewVale, ignoreFalseConditions, separator) + - ToString("isNewValeOverLast", isNewValeOverLast, ignoreFalseConditions, separator) + - ToString("isNewValeUnderLast", isNewValeUnderLast, ignoreFalseConditions, separator) + - "-----------------------" + separator + - "XICH: " + separator + - "-----------------------" + separator + - ToString("isTenkanSenOverKijunSen", isTenkanSenOverKijunSen, ignoreFalseConditions, separator) + - ToString("isTenkanSenUnderKijunSen", isTenkanSenUnderKijunSen, ignoreFalseConditions, separator) + - ToString("isTenkanSenCrossedOverKijunSen", isTenkanSenCrossedOverKijunSen, ignoreFalseConditions, separator) + - ToString("isTenkanSenCrossedUnderKijunSen", isTenkanSenCrossedUnderKijunSen, ignoreFalseConditions, separator) + - ToString("isSenkouSpanAOverB", isSenkouSpanAOverB, ignoreFalseConditions, separator) + - ToString("isSenkouSpanAUnderB", isSenkouSpanAUnderB, ignoreFalseConditions, separator) + - ToString("isSenkouSpanACrossedOverB", isSenkouSpanACrossedOverB, ignoreFalseConditions, separator) + - ToString("isSenkouSpanACrossedUnderB", isSenkouSpanACrossedUnderB, ignoreFalseConditions, separator) + - "-----------------------" + separator + - "X3MA: " + separator + - "-----------------------" + separator + - ToString("isX3MaFastBullish", isX3MaFastBullish, ignoreFalseConditions, separator) + - ToString("isX3MaFastBearish", isX3MaFastBearish, ignoreFalseConditions, separator) + - ToString("isX3MaFastNeutural", isX3MaFastNeutural, ignoreFalseConditions, separator) + - ToString("isX3MaMidBullish", isX3MaMidBullish, ignoreFalseConditions, separator) + - ToString("isX3MaMidBearish", isX3MaMidBearish, ignoreFalseConditions, separator) + - ToString("isX3MaMidNeutural", isX3MaMidNeutural, ignoreFalseConditions, separator) + - ToString("isX3MaSlowBullish", isX3MaSlowBullish, ignoreFalseConditions, separator) + - ToString("isX3MaSlowBearish", isX3MaSlowBearish, ignoreFalseConditions, separator) + - ToString("isX3MaSlowNeutural", isX3MaSlowNeutural, ignoreFalseConditions, separator) + - ToString("isX3MaFastOverMid", isX3MaFastOverMid, ignoreFalseConditions, separator) + - ToString("isX3MaMidOverSlow", isX3MaMidOverSlow, ignoreFalseConditions, separator) + - ToString("isX3MaFastUnderMid", isX3MaFastUnderMid, ignoreFalseConditions, separator) + - ToString("isX3MaMidUnderSlow", isX3MaMidUnderSlow, ignoreFalseConditions, separator) + - ToString("isX3MaBullishState", isX3MaBullishState, ignoreFalseConditions, separator) + - ToString("isX3MaBearishState", isX3MaBearishState, ignoreFalseConditions, separator) + - ToString("isX3MaNeuturalState", isX3MaNeuturalState, ignoreFalseConditions, separator) + - ToString("isX3MaBullishOrdered", isX3MaBullishOrdered, ignoreFalseConditions, separator) + - ToString("isX3MaBearishOrdered", isX3MaBearishOrdered, ignoreFalseConditions, separator) + - ToString("isX3MaSwitchedToBullishOrdered", isX3MaSwitchedToBullishOrdered, ignoreFalseConditions, separator) + - ToString("isX3MaSwitchedToBearishOrdered", isX3MaSwitchedToBearishOrdered, ignoreFalseConditions, separator) + - ToString("isX3MaSwitchedToBullishState", isX3MaSwitchedToBullishState, ignoreFalseConditions, separator) + - ToString("isX3MaSwitchedToBearishState", isX3MaSwitchedToBearishState, ignoreFalseConditions, separator) + - ToString("isX3MaSwitchedToNeuturalState", isX3MaSwitchedToNeuturalState, ignoreFalseConditions, separator) + - "-----------------------" + separator + - "XSTR: " + separator + - "-----------------------" + separator + - ToString("isStrBullish", isStrBullish, ignoreFalseConditions, separator) + - ToString("isStrBearish", isStrBearish, ignoreFalseConditions, separator) + - ToString("isStrSwitchedToBullish", isStrSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isStrSwitchedToBearish", isStrSwitchedToBearish, ignoreFalseConditions, separator) + - ToString("isRejectUpVidya", isRejectUpVidya, ignoreFalseConditions, separator) + - ToString("isCloseOverVidya", isCloseOverVidya, 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) + + ToString("isPeakSameLast", isPeakSameLast, ignoreFalseConditions, separator) + + ToString("isPeakOverLast", isPeakOverLast, ignoreFalseConditions, separator) + + ToString("isPeakUnderLast", isPeakUnderLast, ignoreFalseConditions, separator) + + ToString("isValeSameLast", isValeSameLast, ignoreFalseConditions, separator) + + ToString("isValeOverLast", isValeOverLast, ignoreFalseConditions, separator) + + ToString("isValeUnderLast", isValeUnderLast, ignoreFalseConditions, separator) + + ToString("isTrendRejectUp", isTrendRejectUp, ignoreFalseConditions, separator) + + ToString("isTrendRejectDown", isTrendRejectDown, ignoreFalseConditions, separator) + + ToString("isTrendBullish", isTrendBullish, ignoreFalseConditions, separator) + + ToString("isTrendBearish", isTrendBearish, ignoreFalseConditions, separator) + + ToString("isTrendSwitchedToBullish", isTrendSwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isTrendSwitchedToBearish", isTrendSwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isSupportSameLast", isSupportSameLast, ignoreFalseConditions, separator) + + ToString("isSupportOverLast", isSupportOverLast, ignoreFalseConditions, separator) + + ToString("isSupportUnderLast", isSupportUnderLast, ignoreFalseConditions, separator) + + ToString("isLastSupportBreaked", isLastSupportBreaked, ignoreFalseConditions, separator) + + ToString("isLastSupportRejected", isLastSupportRejected, ignoreFalseConditions, separator) + + ToString("isResistanceSameLast", isResistanceSameLast, ignoreFalseConditions, separator) + + ToString("isResistanceOverLast", isResistanceOverLast, ignoreFalseConditions, separator) + + ToString("isResistanceUnderLast", isResistanceUnderLast, ignoreFalseConditions, separator) + + ToString("isLastResistanceBreaked", isLastResistanceBreaked, ignoreFalseConditions, separator) + + ToString("isLastResistanceRejected", isLastResistanceRejected, ignoreFalseConditions, separator) + + ToString("isSwingLowSameLast", isSwingLowSameLast, ignoreFalseConditions, separator) + + ToString("isSwingLowOverLast", isSwingLowOverLast, ignoreFalseConditions, separator) + + ToString("isSwingLowUnderLast", isSwingLowUnderLast, ignoreFalseConditions, separator) + + ToString("isLastSwingLowBreaked", isLastSwingLowBreaked, ignoreFalseConditions, separator) + + ToString("isLastSwingLowRejected", isLastSwingLowRejected, ignoreFalseConditions, separator) + + ToString("isSwingHighSameLast", isSwingHighSameLast, ignoreFalseConditions, separator) + + ToString("isSwingHighOverLast", isSwingHighOverLast, ignoreFalseConditions, separator) + + ToString("isSwingHighUnderLast", isSwingHighUnderLast, ignoreFalseConditions, separator) + + ToString("isLastSwingHighBreaked", isLastSwingHighBreaked, ignoreFalseConditions, separator) + + ToString("isLastSwingHighRejected", isLastSwingHighRejected, ignoreFalseConditions, separator) + + ToString("isPeakIsPivot", isPeakIsPivot, ignoreFalseConditions, separator) + + ToString("isValeIsPivot", isValeIsPivot, ignoreFalseConditions, separator) + + ToString("isSwingLowSameAsVale", isSwingLowSameAsVale, ignoreFalseConditions, separator) + + ToString("isSwingHighSameAsPeak", isSwingHighSameAsPeak, ignoreFalseConditions, separator) + + ToString("isSupportSameAsVale", isSupportSameAsVale, ignoreFalseConditions, separator) + + ToString("isResistanceSameAsPeak", isResistanceSameAsPeak, ignoreFalseConditions, separator) + + ToString("isSupportSameAsSwingLow", isSupportSameAsSwingLow, ignoreFalseConditions, separator) + + ToString("isResistanceSameAsSwingHigh", isResistanceSameAsSwingHigh, ignoreFalseConditions, separator) + "-----------------------" + separator + "XOCS: " + separator + "-----------------------" + separator + @@ -2194,7 +1868,7 @@ struct XSTRCCIConditions // // Helper Class Implementation ... -class XCXSTRCCIHelper : XCBase +class XCXCAEAHelper : XCBase { // // Public ... @@ -2212,15 +1886,12 @@ class XCXSTRCCIHelper : XCBase // XCX121XCCHelper *ccHelper; XCX121XCTHelper *ctHelper; - XCX121XPVHelper *pvHelper; - XCX121X3MAHelper *ma3Helper; - XCX121XICHHelper *ichHelper; - XCX121XSTRHelper *strHelper; + XCX121XCAHelper *caHelper; XCX121XOCSHelper *ocsHelper; // // Constructor ... - XCXSTRCCIHelper() + XCXCAEAHelper() { // barAnalyser = new XCBarAnalyser(); @@ -2228,7 +1899,7 @@ class XCXSTRCCIHelper : XCBase // // Deconstructor ... - ~XCXSTRCCIHelper() + ~XCXCAEAHelper() { // mInputs.Clean(); @@ -2236,10 +1907,7 @@ class XCXSTRCCIHelper : XCBase // ZeroMemory(ccHelper); ZeroMemory(ctHelper); - ZeroMemory(pvHelper); - ZeroMemory(ma3Helper); - ZeroMemory(ichHelper); - ZeroMemory(strHelper); + ZeroMemory(caHelper); ZeroMemory(ocsHelper); // @@ -2281,14 +1949,14 @@ class XCXSTRCCIHelper : XCBase * * @param symbol: String, Symbol ... * @param period: ENUM_TIMEFRAMES member, Period ... - * @param inputs: XSTRCCIInputs instance, Indicator Inputs ... + * @param inputs: XCAEAInputs instance, Indicator Inputs ... * * @return ( bool ) */ bool Init( string symbol, // Trading Symbol ENUM_TIMEFRAMES period, // Trading Period - XSTRCCIInputs &inputs // Inputs + XCAEAInputs &inputs // Inputs ) { // @@ -2350,47 +2018,14 @@ class XCXSTRCCIHelper : XCBase ); // - // XPV ... - pvHelper = new XCX121XPVHelper(); + // XCA ... + caHelper = new XCX121XCAHelper(); result = result && - pvHelper.Init( + caHelper.Init( symbol, period, - mInputs.pvInputs // - ); - - // - // XSTR ... - strHelper = new XCX121XSTRHelper(); - result = - result && - strHelper.Init( - symbol, - period, - mInputs.strInputs // - ); - - // - // X3MA ... - ma3Helper = new XCX121X3MAHelper(); - result = - result && - ma3Helper.Init( - symbol, - period, - mInputs.ma3Inputs // - ); - - // - // XICH ... - ichHelper = new XCX121XICHHelper(); - result = - result && - ichHelper.Init( - symbol, - period, - mInputs.ichInputs // + mInputs.caInputs // ); // @@ -2410,10 +2045,10 @@ class XCXSTRCCIHelper : XCBase // ZeroMemory(ccHelper); ZeroMemory(ctHelper); - ZeroMemory(strHelper); + ZeroMemory(caHelper); ZeroMemory(ocsHelper); - // + // ZeroMemory(poiDrawer); ZeroMemory(poiDetector); @@ -2631,7 +2266,7 @@ class XCXSTRCCIHelper : XCBase // ZeroMemory(ccHelper); ZeroMemory(ctHelper); - ZeroMemory(strHelper); + ZeroMemory(caHelper); ZeroMemory(ocsHelper); // @@ -2667,8 +2302,8 @@ class XCXSTRCCIHelper : XCBase * * @return ( bool ) */ - bool GetPVConditions( - X121XPVConditions &conditions, // + bool GetCAConditions( + X121XCAConditions &conditions, // int barIndex = 0, // int loopback = 5 // ) @@ -2677,94 +2312,7 @@ class XCXSTRCCIHelper : XCBase bool result = false; // - result = pvHelper.GetConditions( - conditions, - barIndex, - loopback // - ); - - // - return result; - } - - /** - * Retrieve Conditions ... - * - * @param conditions: Argument 1 - * @param barIndex: int, Specified Bar Index ... - * @param loopback: int, Loopback looking for others ... - * - * @return ( bool ) - */ - bool GetSTRConditions( - X121XSTRConditions &conditions, // - int barIndex = 0, // - int loopback = 5 // - ) - { - // - bool result = false; - - // - result = strHelper.GetConditions( - conditions, - barIndex, - loopback // - ); - - // - return result; - } - - /** - * Retrieve Conditions ... - * - * @param conditions: Argument 1 - * @param barIndex: int, Specified Bar Index ... - * @param loopback: int, Loopback looking for others ... - * - * @return ( bool ) - */ - bool GetMA3Conditions( - X121X3MAConditions &conditions, // - int barIndex = 0, // - int loopback = 5 // - ) - { - // - bool result = false; - - // - result = ma3Helper.GetConditions( - conditions, - barIndex, - loopback // - ); - - // - return result; - } - - /** - * Retrieve Conditions ... - * - * @param conditions: Argument 1 - * @param barIndex: int, Specified Bar Index ... - * @param loopback: int, Loopback looking for others ... - * - * @return ( bool ) - */ - bool GetICHConditions( - X121XICHConditions &conditions, // - int barIndex = 0, // - int loopback = 5 // - ) - { - // - bool result = false; - - // - result = ichHelper.GetConditions( + result = caHelper.GetConditions( conditions, barIndex, loopback // @@ -2810,15 +2358,15 @@ class XCXSTRCCIHelper : XCBase void Free() { // - strHelper.Free(); + caHelper.Free(); ocsHelper.Free(); } // bool GetConditions( - XSTRCCIConditions &conditions, // - int barIndex = 0, // - int loopback = 5 // + XCAEAConditions &conditions, // + int barIndex = 0, // + int loopback = 5 // ) { // @@ -2850,10 +2398,7 @@ class XCXSTRCCIHelper : XCBase XOHCL pBar; // - X121XPVConditions xpvConditions; - X121XSTRConditions xstrConditions; - X121X3MAConditions x3maConditions; - X121XICHConditions xichConditions; + X121XCAConditions xcaConditions; X121XOCSConditions xocsConditions; // @@ -2873,41 +2418,11 @@ class XCXSTRCCIHelper : XCBase // Conditions Retriever ... // - // XPV ... + // XCA ... result = result && - GetPVConditions( - xpvConditions, - barIndex, - loopback // - ); - - // - // XSTR ... - result = - result && - GetSTRConditions( - xstrConditions, - barIndex, - loopback // - ); - - // - // X3MA ... - result = - result && - GetMA3Conditions( - x3maConditions, - barIndex, - loopback // - ); - - // - // XICH ... - result = - result && - GetICHConditions( - xichConditions, + GetCAConditions( + xcaConditions, barIndex, loopback // ); @@ -2932,10 +2447,7 @@ class XCXSTRCCIHelper : XCBase pBar.Clean(); // - xpvConditions.Clean(); - xstrConditions.Clean(); - x3maConditions.Clean(); - xichConditions.Clean(); + xcaConditions.Clean(); xocsConditions.Clean(); // @@ -2951,390 +2463,209 @@ class XCXSTRCCIHelper : XCBase int pIDX = cIDX + 1; // - // Conditions ... - - // - // XPV ... + // XCA ... // // Buffers ... // Copy( - xpvConditions.sarBuffer, - conditions.sarBuffer // + xcaConditions.kiBuffer, + conditions.kiBuffer // ); // Copy( - xpvConditions.cHHBuffer, - conditions.cHHBuffer // - ); - - // - Copy( - xpvConditions.cLLBuffer, - conditions.cLLBuffer // - ); - - // - Copy( - xpvConditions.sHHBuffer, + xcaConditions.sHHBuffer, conditions.sHHBuffer // ); // Copy( - xpvConditions.sLLBuffer, + xcaConditions.sLLBuffer, conditions.sLLBuffer // ); // Copy( - xpvConditions.mHHBuffer, + xcaConditions.mHHBuffer, conditions.mHHBuffer // ); // Copy( - xpvConditions.mLLBuffer, + xcaConditions.mLLBuffer, conditions.mLLBuffer // ); // Copy( - xpvConditions.lHHBuffer, + xcaConditions.lHHBuffer, conditions.lHHBuffer // ); // Copy( - xpvConditions.lLLBuffer, + xcaConditions.lLLBuffer, conditions.lLLBuffer // ); // Copy( - xpvConditions.hHHBuffer, + xcaConditions.hHHBuffer, conditions.hHHBuffer // ); // Copy( - xpvConditions.hLLBuffer, + xcaConditions.hLLBuffer, conditions.hLLBuffer // ); // Copy( - xpvConditions.trendBuffer, + xcaConditions.sarBuffer, + conditions.sarBuffer // + ); + + // + Copy( + xcaConditions.peakBuffer, + conditions.peakBuffer // + ); + + // + Copy( + xcaConditions.valeBuffer, + conditions.valeBuffer // + ); + + // + Copy( + xcaConditions.trendBuffer, conditions.trendBuffer // ); // Copy( - xpvConditions.peaksBuffer, - conditions.peaksBuffer // + xcaConditions.kiStateBuffer, + conditions.kiStateBuffer // ); // Copy( - xpvConditions.valesBuffer, - conditions.valesBuffer // + xcaConditions.supportBuffer, + conditions.supportBuffer // ); // Copy( - xpvConditions.supportsBuffer, - conditions.supportsBuffer // + xcaConditions.swingLowBuffer, + conditions.swingLowBuffer // ); // Copy( - xpvConditions.swingLowsBuffer, - conditions.swingLowsBuffer // + xcaConditions.swingHighBuffer, + conditions.swingHighBuffer // ); // Copy( - xpvConditions.swingHighsBuffer, - conditions.swingHighsBuffer // + xcaConditions.resistanceBuffer, + conditions.resistanceBuffer // ); // Copy( - xpvConditions.trendColorBuffer, - conditions.trendColorBuffer // + xcaConditions.peakGoldenBuffer, + conditions.peakGoldenBuffer // ); // Copy( - xpvConditions.trendStateBuffer, + xcaConditions.valeGoldenBuffer, + conditions.valeGoldenBuffer // + ); + + // + Copy( + xcaConditions.fiboLevel1Buffer, + conditions.fiboLevel1Buffer // + ); + + // + Copy( + xcaConditions.fiboLevel2Buffer, + conditions.fiboLevel2Buffer // + ); + + // + Copy( + xcaConditions.fiboLevel3Buffer, + conditions.fiboLevel3Buffer // + ); + + // + Copy( + xcaConditions.trendStateBuffer, conditions.trendStateBuffer // ); - // - Copy( - xpvConditions.peaksGoldenBuffer, - conditions.peaksGoldenBuffer // - ); - - // - Copy( - xpvConditions.valesGoldenBuffer, - conditions.valesGoldenBuffer // - ); - - // - Copy( - xpvConditions.resistancesBuffer, - conditions.resistancesBuffer // - ); - - // - Copy( - xpvConditions.fractalsUpperBuffer, - conditions.fractalsUpperBuffer // - ); - - // - Copy( - xpvConditions.fractalsLowerBuffer, - conditions.fractalsLowerBuffer // - ); - // // Conditions ... // - conditions.isNewPeak = xpvConditions.isNewPeak; - conditions.isNewVale = xpvConditions.isNewVale; - conditions.isSarBullish = xpvConditions.isSarBullish; - conditions.isSarBearish = xpvConditions.isSarBearish; - conditions.isNewPeakOverLast = xpvConditions.isNewPeakOverLast; - conditions.isNewValeOverLast = xpvConditions.isNewValeOverLast; - conditions.isNewPeakUnderLast = xpvConditions.isNewPeakUnderLast; - conditions.isNewValeUnderLast = xpvConditions.isNewValeUnderLast; - conditions.isSarSwitchedToBullish = xpvConditions.isSarSwitchedToBullish; - conditions.isSarSwitchedToBearish = xpvConditions.isSarSwitchedToBearish; - - // - // XSTR ... - - // - // Buffers ... - - // - Copy( - xstrConditions.vidyaBuffer, - conditions.vidyaBuffer // - ); - - // - Copy( - xstrConditions.strBuffer, - conditions.strBuffer // - ); - - // - Copy( - xstrConditions.strUpBuffer, - conditions.strUpBuffer // - ); - - // - Copy( - xstrConditions.strDownBuffer, - conditions.strDownBuffer // - ); - - // - Copy( - xstrConditions.strPriceBuffer, - conditions.strPriceBuffer // - ); - - // - Copy( - xstrConditions.strStateBuffer, - conditions.strStateBuffer // - ); - - // - Copy( - xstrConditions.strSMLowBuffer, - conditions.strSMLowBuffer // - ); - - // - Copy( - xstrConditions.strSMHighBuffer, - conditions.strSMHighBuffer // - ); - - // - // 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.isCloseOverVidya = xstrConditions.isCloseOverVidya; - 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; - - // - // X3MA ... - - // - // Buffers ... - - // - Copy( - x3maConditions.x3maFastBuffer, - conditions.x3maFastBuffer // - ); - - // - Copy( - x3maConditions.x3maMidBuffer, - conditions.x3maMidBuffer // - ); - - // - Copy( - x3maConditions.x3maSlowBuffer, - conditions.x3maSlowBuffer // - ); - - // - Copy( - x3maConditions.x3maFastStateBuffer, - conditions.x3maFastStateBuffer // - ); - - // - Copy( - x3maConditions.x3maMidStateBuffer, - conditions.x3maMidStateBuffer // - ); - - // - Copy( - x3maConditions.x3maSlowStateBuffer, - conditions.x3maSlowStateBuffer // - ); - - // - // Conditions ... - - // - conditions.isX3MaMidBullish = x3maConditions.isX3MaMidBullish; - conditions.isX3MaMidBearish = x3maConditions.isX3MaMidBearish; - conditions.isX3MaFastBullish = x3maConditions.isX3MaFastBullish; - conditions.isX3MaFastBearish = x3maConditions.isX3MaFastBearish; - conditions.isX3MaMidNeutural = x3maConditions.isX3MaMidNeutural; - conditions.isX3MaSlowBullish = x3maConditions.isX3MaSlowBullish; - conditions.isX3MaSlowBearish = x3maConditions.isX3MaSlowBearish; - conditions.isX3MaFastOverMid = x3maConditions.isX3MaFastOverMid; - conditions.isX3MaMidOverSlow = x3maConditions.isX3MaMidOverSlow; - conditions.isX3MaFastNeutural = x3maConditions.isX3MaFastNeutural; - conditions.isX3MaSlowNeutural = x3maConditions.isX3MaSlowNeutural; - conditions.isX3MaFastUnderMid = x3maConditions.isX3MaFastUnderMid; - conditions.isX3MaMidUnderSlow = x3maConditions.isX3MaMidUnderSlow; - conditions.isX3MaBullishState = x3maConditions.isX3MaBullishState; - conditions.isX3MaBearishState = x3maConditions.isX3MaBearishState; - conditions.isX3MaNeuturalState = x3maConditions.isX3MaNeuturalState; - conditions.isX3MaBullishOrdered = x3maConditions.isX3MaBullishOrdered; - conditions.isX3MaBearishOrdered = x3maConditions.isX3MaBearishOrdered; - conditions.isX3MaSwitchedToBullishState = x3maConditions.isX3MaSwitchedToBullishState; - conditions.isX3MaSwitchedToBearishState = x3maConditions.isX3MaSwitchedToBearishState; - conditions.isX3MaSwitchedToNeuturalState = x3maConditions.isX3MaSwitchedToNeuturalState; - conditions.isX3MaSwitchedToBullishOrdered = x3maConditions.isX3MaSwitchedToBullishOrdered; - conditions.isX3MaSwitchedToBearishOrdered = x3maConditions.isX3MaSwitchedToBearishOrdered; - - // - // XICH ... - - // - // Buffers ... - - // - Copy( - xichConditions.kijunSenBuffer, - conditions.kijunSenBuffer // - ); - - // - Copy( - xichConditions.tenkanSenBuffer, - conditions.tenkanSenBuffer // - ); - - // - Copy( - xichConditions.chikouSpanBuffer, - conditions.chikouSpanBuffer // - ); - - // - Copy( - xichConditions.senkouSpanABuffer, - conditions.senkouSpanABuffer // - ); - - // - Copy( - xichConditions.senkouSpanBBuffer, - conditions.senkouSpanBBuffer // - ); - - // - // Conditions ... - - // - conditions.isSenkouSpanAOverB = xichConditions.isSenkouSpanAOverB; - conditions.isSenkouSpanAUnderB = xichConditions.isSenkouSpanAUnderB; - conditions.isTenkanSenOverKijunSen = xichConditions.isTenkanSenOverKijunSen; - conditions.isTenkanSenUnderKijunSen = xichConditions.isTenkanSenUnderKijunSen; - conditions.isSenkouSpanACrossedOverB = xichConditions.isSenkouSpanACrossedOverB; - conditions.isSenkouSpanACrossedUnderB = xichConditions.isSenkouSpanACrossedUnderB; - conditions.isTenkanSenCrossedOverKijunSen = xichConditions.isTenkanSenCrossedOverKijunSen; - conditions.isTenkanSenCrossedUnderKijunSen = xichConditions.isTenkanSenCrossedUnderKijunSen; + conditions.isKIBullish = xcaConditions.isKIBullish; + conditions.isKIBearish = xcaConditions.isKIBearish; + conditions.isKIRejectUp = xcaConditions.isKIRejectUp; + conditions.isSarBullish = xcaConditions.isSarBullish; + conditions.isSarBearish = xcaConditions.isSarBearish; + conditions.isPeakIsPivot = xcaConditions.isPeakIsPivot; + conditions.isValeIsPivot = xcaConditions.isValeIsPivot; + conditions.isKIRejectDown = xcaConditions.isKIRejectDown; + conditions.isPeakSameLast = xcaConditions.isPeakSameLast; + conditions.isPeakOverLast = xcaConditions.isPeakOverLast; + conditions.isValeSameLast = xcaConditions.isValeSameLast; + conditions.isValeOverLast = xcaConditions.isValeOverLast; + conditions.isTrendBullish = xcaConditions.isTrendBullish; + conditions.isTrendBearish = xcaConditions.isTrendBearish; + conditions.isPeakUnderLast = xcaConditions.isPeakUnderLast; + conditions.isValeUnderLast = xcaConditions.isValeUnderLast; + conditions.isTrendRejectUp = xcaConditions.isTrendRejectUp; + conditions.isTrendRejectDown = xcaConditions.isTrendRejectDown; + conditions.isSupportSameLast = xcaConditions.isSupportSameLast; + conditions.isSupportOverLast = xcaConditions.isSupportOverLast; + conditions.isSupportUnderLast = xcaConditions.isSupportUnderLast; + conditions.isSwingLowSameLast = xcaConditions.isSwingLowSameLast; + conditions.isSwingLowOverLast = xcaConditions.isSwingLowOverLast; + conditions.isSwingLowUnderLast = xcaConditions.isSwingLowUnderLast; + conditions.isSwingHighSameLast = xcaConditions.isSwingHighSameLast; + conditions.isSwingHighOverLast = xcaConditions.isSwingHighOverLast; + conditions.isSupportSameAsVale = xcaConditions.isSupportSameAsVale; + conditions.isLastSupportBreaked = xcaConditions.isLastSupportBreaked; + conditions.isResistanceSameLast = xcaConditions.isResistanceSameLast; + conditions.isResistanceOverLast = xcaConditions.isResistanceOverLast; + conditions.isSwingHighUnderLast = xcaConditions.isSwingHighUnderLast; + conditions.isSwingLowSameAsVale = xcaConditions.isSwingLowSameAsVale; + conditions.isLastSupportRejected = xcaConditions.isLastSupportRejected; + conditions.isResistanceUnderLast = xcaConditions.isResistanceUnderLast; + conditions.isKISwitchedToBullish = xcaConditions.isKISwitchedToBullish; + conditions.isKISwitchedToBearish = xcaConditions.isKISwitchedToBearish; + conditions.isLastSwingLowBreaked = xcaConditions.isLastSwingLowBreaked; + conditions.isSwingHighSameAsPeak = xcaConditions.isSwingHighSameAsPeak; + conditions.isLastSwingLowRejected = xcaConditions.isLastSwingLowRejected; + conditions.isSarSwitchedToBullish = xcaConditions.isSarSwitchedToBullish; + conditions.isSarSwitchedToBearish = xcaConditions.isSarSwitchedToBearish; + conditions.isLastSwingHighBreaked = xcaConditions.isLastSwingHighBreaked; + conditions.isResistanceSameAsPeak = xcaConditions.isResistanceSameAsPeak; + conditions.isLastSwingHighRejected = xcaConditions.isLastSwingHighRejected; + conditions.isLastResistanceBreaked = xcaConditions.isLastResistanceBreaked; + conditions.isSupportSameAsSwingLow = xcaConditions.isSupportSameAsSwingLow; + conditions.isLastResistanceRejected = xcaConditions.isLastResistanceRejected; + conditions.isTrendSwitchedToBullish = xcaConditions.isTrendSwitchedToBullish; + conditions.isTrendSwitchedToBearish = xcaConditions.isTrendSwitchedToBearish; + conditions.isResistanceSameAsSwingHigh = xcaConditions.isResistanceSameAsSwingHigh; // // XOSCS ... @@ -3537,10 +2868,7 @@ class XCXSTRCCIHelper : XCBase pBar.Clean(); // - xpvConditions.Clean(); - xstrConditions.Clean(); - x3maConditions.Clean(); - xichConditions.Clean(); + xcaConditions.Clean(); xocsConditions.Clean(); // @@ -3565,7 +2893,7 @@ class XCXSTRCCIHelper : XCBase // // Inputs ... - XSTRCCIInputs mInputs; + XCAEAInputs mInputs; // // Handlers ... diff --git a/XSTRCCI/Libraries/xstrcci.signaller.lib.mq5 b/XCAEA/Libraries/xcaea.signaller.lib.mq5 similarity index 76% rename from XSTRCCI/Libraries/xstrcci.signaller.lib.mq5 rename to XCAEA/Libraries/xcaea.signaller.lib.mq5 index 0d7500a0..9f7ee2b1 100644 --- a/XSTRCCI/Libraries/xstrcci.signaller.lib.mq5 +++ b/XCAEA/Libraries/xcaea.signaller.lib.mq5 @@ -2,8 +2,8 @@ // // SaherElm IT Center MQL5 Indicator // ------------------------------------------------- -// Name: XSTRCCISignaller Lib -// Description: Library for XSTRCCI Signaller ... +// Name: XCAEASignaller Lib +// Description: Library for XCAEA Signaller ... // // // Maintainer: @@ -16,7 +16,7 @@ #property copyright "Copyright 2023, SaherElm IT Center" #property link "https://saherelm.ir" #property version "1.00" -#property description "SaherElm Library for XSTRCCI Signaller" +#property description "SaherElm Library for XCAEA Signaller" #property strict // @@ -24,7 +24,7 @@ #include "../../Libraries/x-saherelm.common.lib.mq5" #include "../../Libraries/x-saherelm.x-poi.lib.mq5" #include "../../Libraries/x-saherelm.x-trade.lib.mq5" -#include "../Helpers/xstrcci.helper.mq5" +#include "../Helpers/xcaea.helper.mq5" // // Enumeration ... @@ -49,7 +49,7 @@ enum ENUM_GUARD_ACTIONS // // Conditions Struct ... -struct XSTRCCIStrategyConditions +struct XCAEAStrategyConditions { // // Props ... @@ -78,11 +78,11 @@ struct XSTRCCIStrategyConditions XBoxZone signalBox; ENUM_X_DIRECTION dir; ENUM_X_POSITION_TYPES type; - XSTRCCIConditions conditions; + XCAEAConditions conditions; // // Constructor ... - XSTRCCIStrategyConditions() + XCAEAStrategyConditions() { Clean(); } @@ -286,7 +286,7 @@ struct XSTRCCIStrategyConditions // // Model a Guard Action ... -struct XSTRCCIGuard +struct XCAEAGuard { // // Props ... @@ -315,7 +315,7 @@ struct XSTRCCIGuard // // Constructor ... - XSTRCCIGuard() + XCAEAGuard() { Clean(); } @@ -385,14 +385,14 @@ struct XSTRCCIGuard /** * Add Guard to Collection ... * - * @param guard: XSTRCCIGuard instance ... - * @param guards: XSTRCCIGuard instance Collection ... + * @param guard: XCAEAGuard instance ... + * @param guards: XCAEAGuard instance Collection ... * * @return ( int ) */ int AddGuard( - XSTRCCIGuard &guard, - XSTRCCIGuard &guards[] // + XCAEAGuard &guard, + XCAEAGuard &guards[] // ) { // @@ -418,11 +418,11 @@ int AddGuard( } // -bool DetectXSTRCCIConditions( - XSTRCCIConditions &conditions, +bool DetectXCAEAConditions( + XCAEAConditions &conditions, XBoxZone &box, ENUM_X_DIRECTION &dir, - XCXSTRCCIHelper *helper, + XCXCAEAHelper *helper, int barIndex = 0, int loopback = 10 // ) @@ -601,114 +601,20 @@ bool DetectXSTRCCIConditions( // // Conditions ... - // - bool isLowsUnderValesGolden = - // - pBar.low < conditions.valesGoldenBuffer[pIDX] && - ppBar.low < conditions.valesGoldenBuffer[ppIDX] && - p3Bar.low < conditions.valesGoldenBuffer[p3IDX] && - p4Bar.low < conditions.valesGoldenBuffer[p4IDX] - // - ; - - // - bool isHighsOverPeaksGolden = - // - pBar.high > conditions.peaksGoldenBuffer[pIDX] && - ppBar.high > conditions.peaksGoldenBuffer[ppIDX] && - p3Bar.high > conditions.peaksGoldenBuffer[p3IDX] && - p4Bar.high > conditions.peaksGoldenBuffer[p4IDX] - // - ; - - // - bool isSwingLowSameAsVale = - conditions.swingLowsBuffer[p4IDX] == conditions.valesBuffer[p4IDX]; - - // - bool isSwingHighSameAsPeak = - conditions.swingHighsBuffer[p4IDX] == conditions.peaksBuffer[p4IDX]; - - // - bool isStrSame = conditions.strBuffer[cIDX] == conditions.strBuffer[pIDX] && - conditions.strBuffer[pIDX] == conditions.strBuffer[ppIDX]; - - // - bool isSameStrBreakedUp = - isStrSame && - conditions.strBuffer[zIDX] > conditions.strBuffer[cIDX]; - - // - bool isSameStrBreakedDown = - isStrSame && - conditions.strBuffer[zIDX] < conditions.strBuffer[cIDX]; - - // - bool isStrBullishVPattern = - // - conditions.strStateBuffer[zIDX] > 0 && - conditions.strStateBuffer[cIDX] > 0 && - conditions.strStateBuffer[pIDX] > 0 && - conditions.strBuffer[pIDX] < conditions.strBuffer[ppIDX] && - conditions.strBuffer[pIDX] < conditions.strBuffer[cIDX] && - conditions.strBuffer[pIDX] < conditions.strBuffer[zIDX] && - conditions.strBuffer[zIDX] > conditions.strBuffer[cIDX] - // - ; - - // - bool isStrBearishVPattern = - // - conditions.strStateBuffer[zIDX] < 0 && - conditions.strStateBuffer[cIDX] < 0 && - conditions.strStateBuffer[pIDX] < 0 && - conditions.strBuffer[pIDX] > conditions.strBuffer[ppIDX] && - conditions.strBuffer[pIDX] > conditions.strBuffer[cIDX] && - conditions.strBuffer[pIDX] > conditions.strBuffer[zIDX] && - conditions.strBuffer[zIDX] < conditions.strBuffer[cIDX] - // - ; - - // - bool isCBarLowInTKZone = - // - cBar.low < conditions.tenkanSenBuffer[cIDX] && - cBar.low > conditions.kijunSenBuffer[cIDX] - // - ; - - // - bool isCBarHighInTKZone = - // - cBar.high > conditions.tenkanSenBuffer[cIDX] && - cBar.high < conditions.kijunSenBuffer[cIDX] - // - ; - // // Summarise Conditions ... // bool isBullish = // - isCBarLowInTKZone && - isCBarBullishRejected && - isCBarValidForBullish && - conditions.isX3MaSlowBullish && - conditions.isTenkanSenOverKijunSen && - conditions.kijunSenBuffer[cIDX] > conditions.x3maSlowBuffer[cIDX] + false // ; // bool isBearish = // - isCBarHighInTKZone && - isCBarBearishRejected && - isCBarValidForBearish && - conditions.isX3MaSlowBearish && - conditions.isTenkanSenUnderKijunSen && - conditions.kijunSenBuffer[cIDX] < conditions.x3maSlowBuffer[cIDX] + false // ; @@ -728,7 +634,7 @@ bool DetectXSTRCCIConditions( conditions.symbol, dir // ); - double sl = conditions.kijunSenBuffer[cIDX]; + double sl = 0; // conditions.kijunSenBuffer[cIDX]; // box.dir = dir; diff --git a/XSTRCCI/Signals/xstrcci.signaller.class.mq5 b/XCAEA/Signals/xcaea.signaller.class.mq5 similarity index 83% rename from XSTRCCI/Signals/xstrcci.signaller.class.mq5 rename to XCAEA/Signals/xcaea.signaller.class.mq5 index 295ebb57..3cfdcea1 100644 --- a/XSTRCCI/Signals/xstrcci.signaller.class.mq5 +++ b/XCAEA/Signals/xcaea.signaller.class.mq5 @@ -2,8 +2,8 @@ // // SaherElm IT Center MQL5 Indicator // ------------------------------------------------- -// Name: XCXSTRCCISignaller ... -// Description: Class for XSTRCCI Signaller ... +// Name: XCXCAEASignaller ... +// Description: Class for XCAEA Signaller ... // // // Maintainer: @@ -16,20 +16,20 @@ #property copyright "Copyright 2023, SaherElm IT Center" #property link "https://saherelm.ir" #property version "1.00" -#property description "SaherElm Class for XSTRCCI Signaller" +#property description "SaherElm Class for XCAEA Signaller" #property strict // // 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" +#include "../Helpers/xcaea.helper.mq5" +#include "../Libraries/xcaea.signaller.lib.mq5" // // Definitions ... -class XCXSTRCCISignaller : XCBase +class XCXCAEASignaller : XCBase { // // Public ... @@ -37,16 +37,16 @@ class XCXSTRCCISignaller : XCBase // // Props ... bool useGuards; - XSTRCCIInputs inputs; + XCAEAInputs inputs; XBarTracker barTraker; - XCXSTRCCIHelper *helper; + XCXCAEAHelper *helper; bool continuesRFTillTarget; - XSTRCCIStrategyConditions mConditions; - XSTRCCIStrategyConditions mConditionsCollection[]; + XCAEAStrategyConditions mConditions; + XCAEAStrategyConditions mConditionsCollection[]; // // Constructor ... - XCXSTRCCISignaller( + XCXCAEASignaller( string _symbol, ENUM_TIMEFRAMES _period // ) @@ -59,7 +59,7 @@ class XCXSTRCCISignaller : XCBase // // Deconstructor ... - ~XCXSTRCCISignaller() + ~XCXCAEASignaller() { DeInit(); } @@ -89,7 +89,7 @@ class XCXSTRCCISignaller : XCBase */ bool DetectSignalSetup( double tpReward = 3, - double maxAllowedSLDistanceInPoint = 300 // + double maxAllowedSLDistanceInPoint = 100 // ) { // @@ -162,8 +162,8 @@ class XCXSTRCCISignaller : XCBase // Checking Conditions ... // - XSTRCCIConditions conditions; - hasSignalBox = DetectXSTRCCIConditions( + XCAEAConditions conditions; + hasSignalBox = DetectXCAEAConditions( conditions, signalBox, signalBoxDir, @@ -232,6 +232,17 @@ class XCXSTRCCISignaller : XCBase ? entry - sl : sl - entry; risk += spread; + if (risk >= maxAllowedSLDistanceInPoint * points) { + // + // Fix Risk in Big Distances ... + double hh5 = zBar.FindHighest(5, MODE_HIGH); + double ll5 = zBar.FindLowest(5, MODE_LOW); + + // + double hhll5Delta = hh5 - ll5; + double riskDelta = hhll5Delta / 2; + risk = riskDelta; + } // double rewardTP = risk * tpReward; @@ -255,7 +266,7 @@ class XCXSTRCCISignaller : XCBase ? entry : sl; mConditions.dir = signalBoxDir; - mConditions.provider = "XSTRCCI"; + mConditions.provider = "XCAEA"; mConditions.signalBox = signalBox; mConditions.setupTime = zBar.time; mConditions.conditions = conditions; @@ -307,13 +318,13 @@ class XCXSTRCCISignaller : XCBase /** * Detect Trigger Conditions for Specified Signal ... * - * @param conditions: XSTRCCIStrategyConditions instance Reference, Specified Signal Conditions ... + * @param conditions: XCAEAStrategyConditions instance Reference, Specified Signal Conditions ... * @param maxAllowedSetupAge: specified Setup Age for Expiration (if bigger than Zero) ... * * @return ( bool ) */ bool DetectSignalTrigger( - XSTRCCIStrategyConditions &conditions, + XCAEAStrategyConditions &conditions, int maxAllowedSetupAge = 60 // ) { @@ -381,14 +392,14 @@ class XCXSTRCCISignaller : XCBase /** * Detect Guards bsed on Signalling Class ... * - * @param guards: XSTRCCIGuard instance Collection, Holds Provided Guards ... + * @param guards: XCAEAGuard 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[], + XCAEAGuard &guards[], const XPosition &positions[] // ) { @@ -427,7 +438,7 @@ class XCXSTRCCISignaller : XCBase { // // Copy Original Items ... - XSTRCCIStrategyConditions tmpItems[]; + XCAEAStrategyConditions tmpItems[]; Copy( mConditionsCollection, tmpItems // @@ -441,7 +452,7 @@ class XCXSTRCCISignaller : XCBase for (int i = 0; i < count; i++) { // - XSTRCCIStrategyConditions iItem = tmpItems[i]; + XCAEAStrategyConditions iItem = tmpItems[i]; // bool canRemove = mConditions.dir == iItem.dir && @@ -526,40 +537,27 @@ class XCXSTRCCISignaller : XCBase inputs.ctInputs.showCandleTime = true; // - // XPV ... - inputs.pvInputs.showSar = false; - inputs.pvInputs.showPeaks = false; - inputs.pvInputs.showVales = false; - inputs.pvInputs.showTrend = false; - inputs.pvInputs.showSwingLows = false; - inputs.pvInputs.showSwingHighs = false; - inputs.pvInputs.showGoldenZones = false; - inputs.pvInputs.showSupports = false; - inputs.pvInputs.showResistances = false; + // XCA ... // - // XSTR ... - inputs.strInputs.showStr = false; - inputs.strInputs.showVidya = false; - inputs.strInputs.showStrUpper = false; - inputs.strInputs.showStrLower = false; - inputs.strInputs.showStrSMLow = false; - inputs.strInputs.showStrSMHigh = false; + inputs.caInputs.supResSmoothingLength = 7; + inputs.caInputs.supResSmoothingMode = X_MA_MODE_NONE; // - // X3MA ... - inputs.ma3Inputs.showX3MaFast = false; - inputs.ma3Inputs.showX3MaMid = false; - inputs.ma3Inputs.showX3MaSlow = true; - - // - // XICH ... - inputs.ichInputs.showKumo = false; - inputs.ichInputs.showKijunSen = true; - inputs.ichInputs.showTenkanSen = true; - inputs.ichInputs.showChikouSpan = false; - inputs.ichInputs.showSenkouSpanA = false; - inputs.ichInputs.showSenkouSpanB = false; + inputs.caInputs.showKI = true; + inputs.caInputs.showSar = true; + inputs.caInputs.showTrend = true; + inputs.caInputs.showSwings = false; + inputs.caInputs.showLongCycle = false; + inputs.caInputs.showHindCycle = false; + inputs.caInputs.showFiboLevel1 = false; + inputs.caInputs.showFiboLevel2 = false; + inputs.caInputs.showFiboLevel3 = false; + inputs.caInputs.showShortCycle = false; + inputs.caInputs.showMediumCycle = false; + inputs.caInputs.showPeaksAndVales = true; + inputs.caInputs.showPeakAndValeGolden = true; + inputs.caInputs.showSupportAndResistance = true; // // XOSCS ... @@ -577,8 +575,8 @@ class XCXSTRCCISignaller : XCBase inputs.showMACD = false; // - // XSTRCCI Helper ... - helper = new XCXSTRCCIHelper(); + // XCAEA Helper ... + helper = new XCXCAEAHelper(); helper.Init( symbol, period, diff --git a/cleanupEX.js b/cleanupEX.js index 90506052..483ac260 100644 --- a/cleanupEX.js +++ b/cleanupEX.js @@ -18,6 +18,7 @@ async function handleCleanup() { "Parsers", // Strategies Filters based on Conditions "Strategies", // Strategies Classes which Provides Signals "X121SMCEA", // X121SMC EA Projects ... + "XCAEA", // XCAEA Projects ... ]; //