From e023518bba5c5b78046ee5ebe5b75a591cfd8f54 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Tue, 11 Jun 2024 22:50:23 +0330 Subject: [PATCH] cleanup workspace ... --- Classes/Indicators/x-saherelm.mid.class.mq5 | 404 -- Classes/x-saherelm.x121.provider.class.mq5 | 2232 ------- Classes/x-saherelm.x121.xea.class.mq5 | 2230 ------- Classes/x-saherelm.x121.xmcycle.class.mq5 | 5857 ------------------ Classes/x-saherelm.xdata-collector.class.mq5 | 481 -- Classes/x-saherelm.xea.class.mq5 | 539 -- Classes/x-saherelm.xind.class.mq5 | 891 --- Classes/x-saherelm.xprovider.class.mq5 | 170 - Experts/x-be-test.mq5 | 351 -- Experts/x-test.x121ea.mq5 | 1136 ---- Libraries/x-saherelm.xtrade.lib.mq5 | 185 - 11 files changed, 14476 deletions(-) delete mode 100644 Classes/Indicators/x-saherelm.mid.class.mq5 delete mode 100644 Classes/x-saherelm.x121.provider.class.mq5 delete mode 100644 Classes/x-saherelm.x121.xea.class.mq5 delete mode 100644 Classes/x-saherelm.x121.xmcycle.class.mq5 delete mode 100644 Classes/x-saherelm.xdata-collector.class.mq5 delete mode 100644 Classes/x-saherelm.xind.class.mq5 delete mode 100644 Classes/x-saherelm.xprovider.class.mq5 delete mode 100644 Experts/x-be-test.mq5 delete mode 100644 Experts/x-test.x121ea.mq5 diff --git a/Classes/Indicators/x-saherelm.mid.class.mq5 b/Classes/Indicators/x-saherelm.mid.class.mq5 deleted file mode 100644 index 3082f710..00000000 --- a/Classes/Indicators/x-saherelm.mid.class.mq5 +++ /dev/null @@ -1,404 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Class Library -// ---------------------------------------------- -// Name: XSCBaseInd -// Description: provides Indicator implementation -// 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.xind.class.mq5" - -// -// XSCMid Indicator Buffers ... -enum ENUM_XSCMID_BUFFERS -{ - XSCMID_MAIN_LINE = 0, // Main Buffer ... - XSCMID_STATE_LINE = 1, // State Buffer ... -}; - -// -string GetTitle(ENUM_XSCMID_BUFFERS bufferLine) -{ - // - string result = NULL; - - // - switch (bufferLine) - { - // - case XSCMID_MAIN_LINE: - result = "XMID"; - break; - - // - case XSCMID_STATE_LINE: - result = "XSTATE"; - break; - } - - // - return result; -} - -// -// XSCMid Indicator Inputs ... -struct XSCMidInputs -{ - // - // Props ... - string version; - - // - // Constructor ... - XSCMidInputs() - { - Clean(); - } - - // - // Tools ... - - // - // Initial Inputs ... - bool Init() - { - // - bool result = false; - - // - result = IsValid(); - - // - return result; - } - - // - // Cleanup ... - void Clean() - { - } - - // - // Default ... - void Default() - { - } - - // - // Validate ... - bool IsValid() - { - // - bool result = false; - - // - result = - // - true - // - ; - - // - return result; - } - - // - // Retrieve Max Length ... - int Max() - { - // - int result = 0; - - // - result = 0; - - // - return result; - } -}; - -// -// a Simple Indicator ... - -class XSCMid : public XSCBaseInd -{ - // - // Public ... -public: - // - // Props ... - - // - // Constructor(s) ... - void XSCMid( - string symbol, // Trading Symbol - ENUM_TIMEFRAMES period // Trading TimeFrame - ) : XSCBaseInd(symbol, period) - { - // - mSymbol = symbol; - mPeriod = period; - - // - mCalculatedBars = 0; - } - - // - // Deconstructor ... - void ~XSCMid() {} - // - // Initialize Indicator ... - bool Init( - XSCMidInputs &inputs // Indicator Inputs ... - ) - { - // - bool result = false; - - // - result = inputs.IsValid(); - if (!result) - { - return result; - } - - // - // Set Inputs ... - this.mInputs = inputs; - - // - // Validate Indicator State ... - result = this.IsValid(); - if (!result) - { - return result; - } - - // - // Register Required Buffers ... - XBuffer main; - string mTitle = GetTitle(XSCMID_MAIN_LINE); - result = main.Init( - mTitle, - mSymbol, - mPeriod // - ); - if (!result) - { - return result; - } - - // - result = SetBuffer(main); - if (!result) - { - return result; - } - - // - // Calculate First Time ... - Calculate(); - - // - return result; - } - - // - // Property Getter(s) / Setter(s) ... - - // - XSCMidInputs GetInputs() - { - return mInputs; - } - - // - bool SetInputs( - XSCMidInputs &inputs // Indicator Inputs - ) - { - return Init(inputs); - } - - // - // Override(s) ... - - // - // Get Tag ... - string GetTag() override - { - // - string result = NULL; - - // - result = GetToken(); - - // - return result; - } - - // - // Get Token ... - string GetToken() override - { - // - string result = NULL; - - // - result = GetSpecificToken(this); - - // - return result; - } - - // - // Validate Inputs ... - bool IsValidInputs() override - { - return mInputs.IsValid(); - } - - // - // Calculate Buffers ... - void Calculate() override - { - // - int max = mInputs.Max(); - int limit = CountLimit(); - int totalBars = CountBars(); - int prevCalculated = GetCalculatedBars(); - - // - // Prepare Buffers Index ... - int mainIDX = GetBufferIndexByLine(XSCMID_MAIN_LINE); - - // - // Print("Total: ", totalBars, ", prevCalculated: ", prevCalculated, ", Limit: ", limit); - - // - // Only Calculate Last Item ... - bool onlyLast = false; - if (prevCalculated == totalBars - 1) - { - onlyLast = true; - } - - // - int start = totalBars - prevCalculated - 1; - for (int i = start; i >= 0; i--) - { - // - int barIndex = i - 1; - // Print("barIndex: ", barIndex, ", onlyLast: ", onlyLast); - if (barIndex < 0 && !onlyLast) - { - continue; - } - - // - if (onlyLast) - { - barIndex = 0; - } - - // - datetime iBarTime = iTime( - mSymbol, - mPeriod, - barIndex - 1 - // - ); - int iBarIndex = iBarShift( - mSymbol, - mPeriod, - iBarTime // - ); - - // - double iValue = iClose(mSymbol, mPeriod, iBarIndex); - - // - Print("Bar: ", barIndex, ", Bar Time: ", iBarTime, ", Bar Index: ", iBarIndex, ", iValue: ", iValue); - if (iValue != 0.0) - { - // - // Print("Bar: ", barIndex, ", Bar Time: ", iBarTime, ", Bar Index: ", iBarIndex, ", iValue: ", iValue); - mBuffers[mainIDX].Add(barIndex, iValue); - } - } - - // - // Prevent Double Calculation Same Bars ... - mCalculatedBars = totalBars - 1; - } - - // - // De Initialize Class ... - void DeInit(int reason) - { - } - - // - // Tools ... - - // - int GetBufferIndexByLine( - ENUM_XSCMID_BUFFERS bufferLine // Specified Buffer Line - ) - { - // - string mTitle = GetTitle(bufferLine); - return GetBufferIndex(mTitle); - } - - // - bool GetBufferByLine( - ENUM_XSCMID_BUFFERS bufferLine, // Specified Buffer Line - XBuffer &buffer // Hold Result - ) - { - // - string mTitle = GetTitle(bufferLine); - return GetBuffer(mTitle, buffer); - } - - // // - // double GetBufferValueByLine( - // ENUM_XSCMID_BUFFERS bufferLine, // Specified Buffer Line - // datetime time = NULL // Time - // ) - // { - // // - // string mTitle = GetTitle(bufferLine); - // return GetBufferValue(mTitle, time); - // } - - // - // Protected ... -protected: - // - // Private ... -private: - // - // Props ... - - // - // Inputs ... - XSCMidInputs mInputs; -}; \ No newline at end of file diff --git a/Classes/x-saherelm.x121.provider.class.mq5 b/Classes/x-saherelm.x121.provider.class.mq5 deleted file mode 100644 index 5dbd7618..00000000 --- a/Classes/x-saherelm.x121.provider.class.mq5 +++ /dev/null @@ -1,2232 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Class Library -// ---------------------------------------------- -// Name: XSC121Provider -// Description: provides all Base Provider -// requirements For X121 ... -// -// -// 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 "../Helpers/x-saherelm.xcc.helper.mq5" -#include "../Helpers/x-saherelm.xct.helper.mq5" -#include "../Helpers/x-saherelm.xmc.helper.mq5" -#include "../Helpers/x-saherelm.xzg.helper.mq5" -#include "../Helpers/x-saherelm.xpv.helper.mq5" -#include "../Helpers/x-saherelm.xtm.helper.mq5" -#include "../Helpers/x-saherelm.xtd.helper.mq5" -#include "../Helpers/x-saherelm.xdon.helper.mq5" -#include "../Helpers/x-saherelm.xstr.helper.mq5" -#include "../Helpers/x-saherelm.xche.helper.mq5" -#include "../Helpers/x-saherelm.xosc.helper.mq5" -#include "../Helpers/x-saherelm.xama.helper.mq5" -#include "../Helpers/x-saherelm.xasct.helper.mq5" -#include "../Helpers/x-saherelm.xhull.helper.mq5" -#include "../Helpers/x-saherelm.xsslc.helper.mq5" - -// -#include "../Classes/x-saherelm.xprovider.class.mq5" -#include "../Classes/x-saherelm.x121.xmcycle.class.mq5" - -// -// Definitions ... - -// -// X121 Provider Inputs ... -class X121ProviderInputs : public XSCBase -{ - // - // Public ... -public: - // - // Props ... - - // - string symbol; - ENUM_TIMEFRAMES period; - - // - // S Market ... - ENUM_TIMEFRAMES sMarketPeriod; // Short Market Period - ENUM_X_PERIOD_METHOD sMarketMethod; // Short Market Period Method - string sMarketPrefix; // Short Market Prefix - - // - // MEDIUM Market ... - ENUM_TIMEFRAMES mMarketPeriod; // Medium Market Period - ENUM_X_PERIOD_METHOD mMarketMethod; // Medium Market Period Method - string mMarketPrefix; // Medium Market Prefix - - // - // LONG Market ... - ENUM_TIMEFRAMES lMarketPeriod; // Long Market Period - ENUM_X_PERIOD_METHOD lMarketMethod; // Long Market Period Method - string lMarketPrefix; // Long Market Prefix - - // - // HIND Market ... - ENUM_TIMEFRAMES hMarketPeriod; // Hind Market Period - ENUM_X_PERIOD_METHOD hMarketMethod; // Hind Market Period Method - string hMarketPrefix; // Hind Market Prefix - - // - // Indicators ... - XCCInputs ccInputs; - XCTInputs ctInputs; - - // - XZGInputs zgInputs; - XPVInputs pvInputs; - XHKInputs hkInputs; - XMCInputs mcInputs; - XTDInputs tdInputs; - XMRBInputs mrbInputs; - XICHInputs ichInputs; - XCHEInputs cheInputs; - XSTRInputs strInputs; - XDONInputs donInputs; - XOSCInputs oscInputs; - XASCTInputs asctInputs; - XHULLInputs hullInputs; - XSSLCInputs sslcInputs; - - // - X121MCycleInputs cMarketInputs; // Curent Market Inputs - X121MCycleInputs sMarketInputs; // Short Market Inputs - X121MCycleInputs mMarketInputs; // Medium Market Inputs - X121MCycleInputs lMarketInputs; // Long Market Inputs - X121MCycleInputs hMarketInputs; // Hind Market Inputs - - // - // Tools ... - - // - // Initialize Input ... - bool Init() - { - // - bool result = false; - - // - // Validate Base Requirements ... - result = - // - IsSpecifiedValid(symbol) && - IsSpecifiedValid(period) && - IsSpecifiedValid(sMarketMethod, sMarketPeriod) && - IsSpecifiedValid(mMarketMethod, mMarketPeriod) && - IsSpecifiedValid(lMarketMethod, lMarketPeriod) && - IsSpecifiedValid(hMarketMethod, hMarketPeriod) - // - ; - if (!result) - { - return result; - } - - // - if (!zgInputs.IsValid()) - { - zgInputs.Default(); - } - if (!pvInputs.IsValid()) - { - pvInputs.Default(); - } - if (!mcInputs.IsValid()) - { - mcInputs.Default(); - } - if (!hkInputs.IsValid()) - { - hkInputs.Default(); - } - if (!mrbInputs.IsValid()) - { - mrbInputs.Default(); - } - if (!cheInputs.IsValid()) - { - cheInputs.Default(); - } - if (!strInputs.IsValid()) - { - strInputs.Default(); - } - if (!donInputs.IsValid()) - { - donInputs.Default(); - } - if (!oscInputs.IsValid()) - { - oscInputs.Default(); - } - if (!ichInputs.IsValid()) - { - ichInputs.Default(); - } - if (!hullInputs.IsValid()) - { - hullInputs.Default(); - } - if (!asctInputs.IsValid()) - { - asctInputs.Default(); - } - if (!sslcInputs.IsValid()) - { - sslcInputs.Default(); - } - if (!tdInputs.IsValid()) - { - tdInputs.Default(); - } - - // - // Initialize Market Inputs ... - - // - // Current ... - cMarketInputs.pvInputs = this.pvInputs; - cMarketInputs.zgInputs = this.zgInputs; - cMarketInputs.tdInputs = this.tdInputs; - cMarketInputs.mcInputs = this.mcInputs; - cMarketInputs.hkInputs = this.hkInputs; - cMarketInputs.mrbInputs = this.mrbInputs; - cMarketInputs.strInputs = this.strInputs; - cMarketInputs.oscInputs = this.oscInputs; - cMarketInputs.cheInputs = this.cheInputs; - cMarketInputs.ichInputs = this.ichInputs; - cMarketInputs.donInputs = this.donInputs; - cMarketInputs.asctInputs = this.asctInputs; - cMarketInputs.hullInputs = this.hullInputs; - cMarketInputs.sslcInputs = this.sslcInputs; - result = cMarketInputs.Init( - this.symbol, - this.period, - X_MARKET_CYCLE_SHORT, - this.period, - X_PERIOD_MANUALLY, - "HOST", - false // - ); - if (!result) - { - return result; - } - - // - // Short ... - sMarketInputs.pvInputs = this.pvInputs; - sMarketInputs.zgInputs = this.zgInputs; - sMarketInputs.tdInputs = this.tdInputs; - sMarketInputs.mcInputs = this.mcInputs; - sMarketInputs.hkInputs = this.hkInputs; - sMarketInputs.mrbInputs = this.mrbInputs; - sMarketInputs.strInputs = this.strInputs; - sMarketInputs.oscInputs = this.oscInputs; - sMarketInputs.cheInputs = this.cheInputs; - sMarketInputs.ichInputs = this.ichInputs; - sMarketInputs.donInputs = this.donInputs; - sMarketInputs.asctInputs = this.asctInputs; - sMarketInputs.hullInputs = this.hullInputs; - sMarketInputs.sslcInputs = this.sslcInputs; - result = sMarketInputs.Init( - this.symbol, - this.period, - X_MARKET_CYCLE_SHORT, - this.sMarketPeriod, - this.sMarketMethod, - this.sMarketPrefix, - false // - ); - if (!result) - { - return result; - } - - // - // Medium ... - mMarketInputs.pvInputs = this.pvInputs; - mMarketInputs.zgInputs = this.zgInputs; - mMarketInputs.tdInputs = this.tdInputs; - mMarketInputs.mcInputs = this.mcInputs; - mMarketInputs.hkInputs = this.hkInputs; - mMarketInputs.mrbInputs = this.mrbInputs; - mMarketInputs.strInputs = this.strInputs; - mMarketInputs.oscInputs = this.oscInputs; - mMarketInputs.cheInputs = this.cheInputs; - mMarketInputs.ichInputs = this.ichInputs; - mMarketInputs.donInputs = this.donInputs; - mMarketInputs.asctInputs = this.asctInputs; - mMarketInputs.hullInputs = this.hullInputs; - mMarketInputs.sslcInputs = this.sslcInputs; - result = mMarketInputs.Init( - this.symbol, - this.period, - X_MARKET_CYCLE_MEDIUM, - this.mMarketPeriod, - this.mMarketMethod, - this.mMarketPrefix, - false // - ); - if (!result) - { - return result; - } - - // - // Long ... - lMarketInputs.pvInputs = this.pvInputs; - lMarketInputs.zgInputs = this.zgInputs; - lMarketInputs.tdInputs = this.tdInputs; - lMarketInputs.mcInputs = this.mcInputs; - lMarketInputs.hkInputs = this.hkInputs; - lMarketInputs.mrbInputs = this.mrbInputs; - lMarketInputs.strInputs = this.strInputs; - lMarketInputs.oscInputs = this.oscInputs; - lMarketInputs.cheInputs = this.cheInputs; - lMarketInputs.ichInputs = this.ichInputs; - lMarketInputs.donInputs = this.donInputs; - lMarketInputs.asctInputs = this.asctInputs; - lMarketInputs.hullInputs = this.hullInputs; - lMarketInputs.sslcInputs = this.sslcInputs; - result = lMarketInputs.Init( - this.symbol, - this.period, - X_MARKET_CYCLE_LONG, - this.lMarketPeriod, - this.lMarketMethod, - this.lMarketPrefix, - false // - ); - if (!result) - { - return result; - } - - // - // Hind ... - hMarketInputs.pvInputs = this.pvInputs; - hMarketInputs.zgInputs = this.zgInputs; - hMarketInputs.tdInputs = this.tdInputs; - hMarketInputs.mcInputs = this.mcInputs; - hMarketInputs.hkInputs = this.hkInputs; - hMarketInputs.mrbInputs = this.mrbInputs; - hMarketInputs.strInputs = this.strInputs; - hMarketInputs.oscInputs = this.oscInputs; - hMarketInputs.cheInputs = this.cheInputs; - hMarketInputs.ichInputs = this.ichInputs; - hMarketInputs.donInputs = this.donInputs; - hMarketInputs.asctInputs = this.asctInputs; - hMarketInputs.hullInputs = this.hullInputs; - hMarketInputs.sslcInputs = this.sslcInputs; - result = hMarketInputs.Init( - this.symbol, - this.period, - X_MARKET_CYCLE_HIND, - this.hMarketPeriod, - this.hMarketMethod, - this.hMarketPrefix, - false // - ); - if (!result) - { - return result; - } - - // - result = IsValid(); - - // - return result; - } - - // - // Validate Input ... - bool IsValid() - { - // - bool result = false; - - // - result = - // - // - IsSpecifiedValid(symbol) && - IsSpecifiedValid(period) && - IsSpecifiedValid(sMarketMethod, sMarketPeriod) && - IsSpecifiedValid(mMarketMethod, mMarketPeriod) && - IsSpecifiedValid(lMarketMethod, lMarketPeriod) && - IsSpecifiedValid(hMarketMethod, hMarketPeriod) && - // - ccInputs.IsValid() && - ctInputs.IsValid() && - zgInputs.IsValid() && - pvInputs.IsValid() && - mcInputs.IsValid() && - hkInputs.IsValid() && - tdInputs.IsValid() && - mrbInputs.IsValid() && - cheInputs.IsValid() && - strInputs.IsValid() && - donInputs.IsValid() && - oscInputs.IsValid() && - ichInputs.IsValid() && - asctInputs.IsValid() && - hullInputs.IsValid() && - sslcInputs.IsValid() && - // - cMarketInputs.IsValid() && - sMarketInputs.IsValid() && - mMarketInputs.IsValid() && - lMarketInputs.IsValid() && - hMarketInputs.IsValid() - // - ; - - // - return result; - } - - // - // Cleanup ... - void Clean() - { - // - symbol = NULL; - period = NULL; - - // - sMarketPeriod = NULL; - sMarketMethod = X_PERIOD_NOTHING; - sMarketPrefix = NULL; - - // - mMarketPeriod = NULL; - mMarketMethod = X_PERIOD_NOTHING; - mMarketPrefix = NULL; - - // - lMarketPeriod = NULL; - lMarketMethod = X_PERIOD_NOTHING; - lMarketPrefix = NULL; - - // - hMarketPeriod = NULL; - hMarketMethod = X_PERIOD_NOTHING; - hMarketPrefix = NULL; - - // - ccInputs.Clean(); - ctInputs.Clean(); - zgInputs.Clean(); - pvInputs.Clean(); - mcInputs.Clean(); - hkInputs.Clean(); - tdInputs.Clean(); - mrbInputs.Clean(); - cheInputs.Clean(); - strInputs.Clean(); - donInputs.Clean(); - oscInputs.Clean(); - ichInputs.Clean(); - asctInputs.Clean(); - hullInputs.Clean(); - sslcInputs.Clean(); - // - cMarketInputs.Clean(); - sMarketInputs.Clean(); - mMarketInputs.Clean(); - lMarketInputs.Clean(); - hMarketInputs.Clean(); - } - - // - // Default ... - void Default() - { - // - symbol = NULL; - period = NULL; - - // - sMarketPeriod = NULL; - sMarketMethod = X_PERIOD_AUTO; - sMarketPrefix = NULL; - - // - mMarketPeriod = NULL; - mMarketMethod = X_PERIOD_AUTO; - mMarketPrefix = NULL; - - // - lMarketPeriod = NULL; - lMarketMethod = X_PERIOD_AUTO; - lMarketPrefix = NULL; - - // - hMarketPeriod = NULL; - hMarketMethod = X_PERIOD_AUTO; - hMarketPrefix = NULL; - - // - ccInputs.Default(); - ctInputs.Default(); - zgInputs.Default(); - pvInputs.Default(); - mcInputs.Default(); - hkInputs.Default(); - tdInputs.Default(); - mrbInputs.Default(); - cheInputs.Default(); - strInputs.Default(); - donInputs.Default(); - oscInputs.Default(); - ichInputs.Default(); - asctInputs.Default(); - hullInputs.Default(); - sslcInputs.Default(); - - // - cMarketInputs.Default(); - sMarketInputs.Default(); - mMarketInputs.Default(); - lMarketInputs.Default(); - hMarketInputs.Default(); - } - - // - // Max ... - int Max() - { - // - int result = 0; - - // - result = MathMax(ctInputs.Max(), ccInputs.Max()); - - // - result = MathMax(result, ctInputs.Max()); - result = MathMax(result, ccInputs.Max()); - result = MathMax(result, tdInputs.Max()); - result = MathMax(result, zgInputs.Max()); - result = MathMax(result, pvInputs.Max()); - result = MathMax(result, mcInputs.Max()); - result = MathMax(result, hkInputs.Max()); - result = MathMax(result, mrbInputs.Max()); - result = MathMax(result, cheInputs.Max()); - result = MathMax(result, strInputs.Max()); - result = MathMax(result, donInputs.Max()); - result = MathMax(result, oscInputs.Max()); - result = MathMax(result, ichInputs.Max()); - result = MathMax(result, asctInputs.Max()); - result = MathMax(result, hullInputs.Max()); - result = MathMax(result, sslcInputs.Max()); - - // - return result; - } - - // - // Set Symbol ... - bool SetSymbol(string value) - { - // - bool result = false; - - // - result = IsSpecifiedValid(value); - if (!result) - { - return result; - } - - // - symbol = value; - - // - cMarketInputs.cycle.symbol = value; - sMarketInputs.cycle.symbol = value; - mMarketInputs.cycle.symbol = value; - lMarketInputs.cycle.symbol = value; - hMarketInputs.cycle.symbol = value; - - // - return result; - } - - // - // Set Period ... - bool SetPeriod(ENUM_TIMEFRAMES value) - { - // - bool result = false; - - // - result = IsSpecifiedValid(value); - if (!result) - { - return result; - } - - // - period = value; - - // - cMarketInputs.cycle.period = value; - sMarketInputs.cycle.period = value; - mMarketInputs.cycle.period = value; - lMarketInputs.cycle.period = value; - hMarketInputs.cycle.period = value; - - // - return result; - } - - // -}; - -// -// X121 Provider Market Conditions ... -class X121MarketConditions : public XSCBase -{ - // - // Public ... -public: - // - // Props ... - string symbol; // Symbol - ENUM_TIMEFRAMES period; // Period - datetime time; // Time - - // - XOHCL bars[]; // Number of Bars ... - - // - // Market Props ... - X121MCycleConditions cMarketConditions; // Current Market Conditions - X121MCycleConditions sMarketConditions; // Short Market Conditions - X121MCycleConditions mMarketConditions; // Medium Market Conditions - X121MCycleConditions lMarketConditions; // Long Market Conditions - X121MCycleConditions hMarketConditions; // Hind Market Conditions - - // - // Tools ... - - // - // Cleanup ... - void Clear() - { - // - symbol = NULL; - period = NULL; - - // - Clean(bars); - - // - ArraySetAsSeries(bars, true); - - // - cMarketConditions.Clear(); - sMarketConditions.Clear(); - mMarketConditions.Clear(); - lMarketConditions.Clear(); - hMarketConditions.Clear(); - } - - // - void GenerateScore( - double &bullishScore, // Bullish Score - double &bearishScore, // Bearish Score - double cMarketMultiplier = 1, // Current Market Score Multiplier - double sMarketMultiplier = 1.25, // Short Market Score Multiplier - double mMarketMultiplier = 1.5, // Medium Market Score Multiplier - double lMarketMultiplier = 2, // Long Market Score Multiplier - double hMarketMultiplier = 2.5 // Hind Market Score Multiplier - ) - { - // - double bullScore = 0; - double bearScore = 0; - - // - // Current Market ... - double cMarketBullScore = 0; - double cMarketBearScore = 0; - cMarketConditions.GenerateScore( - cMarketBullScore, - cMarketBearScore, - cMarketMultiplier // - ); - - // - // Short Market ... - double sMarketBullScore = 0; - double sMarketBearScore = 0; - sMarketConditions.GenerateScore( - sMarketBullScore, - sMarketBearScore, - sMarketMultiplier // - ); - - // - // Medium Market ... - double mMarketBullScore = 0; - double mMarketBearScore = 0; - mMarketConditions.GenerateScore( - mMarketBullScore, - mMarketBearScore, - mMarketMultiplier // - ); - - // - // Long Market ... - double lMarketBullScore = 0; - double lMarketBearScore = 0; - lMarketConditions.GenerateScore( - lMarketBullScore, - lMarketBearScore, - lMarketMultiplier // - ); - - // - // Hind Market ... - double hMarketBullScore = 0; - double hMarketBearScore = 0; - hMarketConditions.GenerateScore( - hMarketBullScore, - hMarketBearScore, - hMarketMultiplier // - ); - - // - // Calculate Summary Scores ... - - // - bullishScore = - // - bullScore + - cMarketBullScore + - sMarketBullScore + - mMarketBullScore + - lMarketBullScore + - hMarketBullScore - // - ; - - // - bearishScore = - // - bearScore + - cMarketBearScore + - sMarketBearScore + - mMarketBearScore + - lMarketBearScore + - hMarketBearScore - // - ; - } - - // - string GenerateSummary( - const bool onlySummary = false, // Only Generate Conditions Summary - const bool onlyCyclesSummary = false, // Only Generate Conditions Summary - double cMarketMultiplier = 1, // Current Market Score Multiplier - double sMarketMultiplier = 1.25, // Short Market Score Multiplier - double mMarketMultiplier = 1.5, // Medium Market Score Multiplier - double lMarketMultiplier = 2, // Long Market Score Multiplier - double hMarketMultiplier = 2.5, // Hind Market Score Multiplier - const string separator = "\n", // Separator - string provided = NULL, // Additional Info about Type, Provider and Symbol - const bool ignoreFalseConditions = true // Ignore False Conditions - ) - { - // - string result = NULL; - - // - double bullScore = 0; - double bearScore = 0; - GenerateScore( - bullScore, - bearScore, - cMarketMultiplier, - sMarketMultiplier, - mMarketMultiplier, - lMarketMultiplier, - hMarketMultiplier // - ); - - // - string commonStr = - // - "Commons: " + separator + - "-----------------------------" + separator + - "Symbol: " + symbol + separator + - "Period: " + ToString(period) + separator + - "Time: " + ToString(TimeCurrent()) + separator + - "-----------" + separator + - "Cycles: " + separator + - "-----------" + separator + - sMarketConditions.GetTitle() + separator + - mMarketConditions.GetTitle() + separator + - lMarketConditions.GetTitle() + separator + - hMarketConditions.GetTitle() + separator + - "-----------" + separator + - "Scores: " + separator + - "-----------" + separator + - "Bullish: " + ToString(bullScore) + separator + - "Bearish: " + ToString(bearScore) + separator + - "-----------------------------" + separator + - // - // TODO: Add Scores Later ... - separator + - "" - // - ; - - // - string cMarketConditionsStr = cMarketConditions.GenerateSummary(onlyCyclesSummary, cMarketMultiplier); - string sMarketConditionsStr = sMarketConditions.GenerateSummary(onlyCyclesSummary, sMarketMultiplier); - string mMarketConditionsStr = mMarketConditions.GenerateSummary(onlyCyclesSummary, mMarketMultiplier); - string lMarketConditionsStr = lMarketConditions.GenerateSummary(onlyCyclesSummary, lMarketMultiplier); - string hMarketConditionsStr = hMarketConditions.GenerateSummary(onlyCyclesSummary, hMarketMultiplier); - - // - result = - // - "[" + GetToken() + "]" + separator + - (IsSpecifiedValid(provided) ? provided + separator : "") + - "-----------------------------" + separator + - commonStr + - (!onlySummary - ? cMarketConditionsStr + - sMarketConditionsStr + - mMarketConditionsStr + - lMarketConditionsStr + - hMarketConditionsStr + - "" - : "") + - "" - // - ; - - // - return result; - } - - // - // Tools ... - - // - string GetToken() - { - return GetSpecificToken(this); - } -}; - -// -// Class ... - -// -// X121 Provider Class ... -class XSCX121Provider : public XSCBaseProvider -{ - // - // Public ... -public: - // - // Props ... - - // - XSCXCCHelper *ccHelper; // Candle Clear - XSCXCTHelper *ctHelper; // Candle Timer - - // - XSCX121Market *cMarket; // Current Market - XSCX121Market *sMarket; // Short Market - XSCX121Market *mMarket; // Medium Market - XSCX121Market *lMarket; // Long Market - XSCX121Market *hMarket; // Hind Market - - // - // Constructor ... - XSCX121Provider( - string symbol, // Trading Symbol - ENUM_TIMEFRAMES period // Trading Period - ) : XSCBaseProvider(symbol, period) - { - // - ccHelper = new XSCXCCHelper(); - ctHelper = new XSCXCTHelper(); - - // - // Instantiate X121 Market Cycles Classes ... - cMarket = new XSCX121Market(); - sMarket = new XSCX121Market(); - mMarket = new XSCX121Market(); - lMarket = new XSCX121Market(); - hMarket = new XSCX121Market(); - - // - mNumberOfItems = 15; - } - - // - // Properties Gettr(s) / Setter(s) ... - - // - void SetNumberOfItems(int value) - { - mNumberOfItems = value; - } - - // - int GetNumberOfItems() - { - return mNumberOfItems; - } - - // - // Overrides ... - - // - // DeInit all Requirements ... - void DeInit() override - { - // - delete ccHelper; - delete ctHelper; - - // - delete cMarket; - delete sMarket; - delete mMarket; - delete lMarket; - delete hMarket; - } - - // - // Functions ... - - // - // Init all Requirements ... - bool Init(X121ProviderInputs &inputs) - { - // - bool result = false; - - // - // Validate ... - result = inputs.IsValid(); - if (!result) - { - return result; - } - - // - mInputs = inputs; - - // - string mSymbol = GetSymbol(); - ENUM_TIMEFRAMES mPeriod = GetPeriod(); - - // - // Init Indicators Helpers ... - - // - // CT ... - result = ctHelper - .Init( - mSymbol, - mPeriod, - mInputs.ctInputs - // - ); - if (!result) - { - return result; - } - - // - // CC ... - result = ccHelper - .Init( - mSymbol, - mPeriod, - mInputs.ccInputs - // - ); - if (!result) - { - return result; - } - - // - // Initialize X121 Market Cycles ... - - // - // Current Market ... - result = cMarket - .Init(mInputs.cMarketInputs); - if (!result) - { - return result; - } - - // - // Short Market ... - result = sMarket - .Init(mInputs.sMarketInputs); - if (!result) - { - return result; - } - - // - // Medium Market ... - result = mMarket - .Init(mInputs.mMarketInputs); - if (!result) - { - return result; - } - - // - // Long Market ... - result = lMarket - .Init(mInputs.lMarketInputs); - if (!result) - { - return result; - } - - // - // Hind Market ... - result = hMarket - .Init(mInputs.hMarketInputs); - if (!result) - { - return result; - } - - // - return result; - } - - // - string GetTag() - { - // - string result = NULL; - - // - result = - // - GetToken() + - "[" + - GetSymbol() + - "," + - ToString(GetPeriod()) + - "]" - // - ; - - // - return result; - } - - // - void GetMarketConditions( - X121MarketConditions &mConditions, // Market Conditions Result - int barIndex = 0 // Specified Bar Index - ) - { - // - mConditions.Clear(); - - // - CalculateConditions(mConditions, barIndex); - } - - // - // Tools ... - - // - void Draw() - { - // - string symbol = GetSymbol(); - ENUM_TIMEFRAMES period = GetPeriod(); - - // - ulong chID = FindChartID( - symbol, - period); - if (chID < 0) - { - return; - } - - // - int subWindow = 0; - - // - int offset = 0; - - // - cMarket.Draw(chID, subWindow, offset); - sMarket.Draw(chID, subWindow, offset); - mMarket.Draw(chID, subWindow, offset); - lMarket.Draw(chID, subWindow, offset); - hMarket.Draw(chID, subWindow, offset); - } - - // - // Protected ... -protected: - // - X121ProviderInputs mInputs; - - // - // Private ... -private: - // - // Props ... - - // - int mNumberOfItems; // Number of Buffer Ites Read in Conditions ... - - // - void CalculateConditions( - X121MarketConditions &mConditions, // Market Conditions Result - int barIndex = 0 // Specified Bar Index - ) - { - // - mConditions.Clear(); - - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - if (barIndex >= CountBars()) - { - barIndex = CountBars() + 2; - } - - // - int curr = barIndex + 1; - int prev = curr + 1; - int mLength = 10; - int mFrom = curr + mLength; - - // - mConditions.symbol = GetSymbol(); - mConditions.period = GetPeriod(); - mConditions.time = iTime( - mConditions.symbol, - mConditions.period, - barIndex // - ); - - // - GetBars( - mConditions.bars, - mConditions.symbol, - mConditions.period, - barIndex, - mNumberOfItems // - ); - - // - // X121 Cycles Conditions ... - - // - cMarket.GetMarketConditions( - mConditions.cMarketConditions, - barIndex, - mNumberOfItems // - ); - - // - sMarket.GetMarketConditions( - mConditions.sMarketConditions, - barIndex, - mNumberOfItems // - ); - - // - mMarket.GetMarketConditions( - mConditions.mMarketConditions, - barIndex, - mNumberOfItems // - ); - - // - lMarket.GetMarketConditions( - mConditions.lMarketConditions, - barIndex, - mNumberOfItems // - ); - - // - hMarket.GetMarketConditions( - mConditions.hMarketConditions, - barIndex, - mNumberOfItems // - ); - } - - // -}; - -// -// Tools ... - -// -// Model Provider Descriptor ... -struct X121ProviderDescriptor -{ - // - string symbol; // Trading Symbol - ENUM_TIMEFRAMES period; // Trading Timeframe - XSignallerDescriptor *signallers[]; // Allowed Signal Providers - - // - X121ProviderInputs inputs; - XSCX121Provider *provider; - - // - XSignal signals[]; - X121MarketConditions conditions; - - // - // Tools ... - - // - bool Init() - { - // - bool result = false; - - // - result = this.Init( - this.symbol, - this.period); - - // - return result; - } - - // - bool Init( - string mSymbol, // Trading Symbol - ENUM_TIMEFRAMES mPeriod // Trading Timeframe - ) - { - // - bool result = false; - - // - result = - // - inputs.IsValid() && - IsValid(mSymbol) && - IsValid(mPeriod) && - IsValidSize(ArraySize(this.signallers)) - // - ; - if (!result) - { - return result; - } - - // - this.symbol = mSymbol; - this.period = mPeriod; - - // - // Instantiate Provider ... - provider = new XSCX121Provider( - this.symbol, - this.period // - ); - - // - // Now Must to Initialize Provider ... - result = provider.Init( - this.inputs); - - // - return result; - } - - // - // Cleanup ... - void Clean() - { - // - Clean(signals); - conditions.Clear(); - } - - // - // Validate ... - bool IsValid(bool validateInputs = true) - { - // - bool result = false; - - // - result = - // - IsValid(symbol) && - IsValid(period) && - (validateInputs - ? inputs.IsValid() - : true) && - ArraySize(signallers) > 0 - // - ; - - // - return result; - } - - // - // Check Signal ... - int HasSignal(int barIndex = 0) - { - // - int result = 0; - - // - if (!inputs.IsValid()) - { - return result; - } - - // - int signallersCount = ArraySize(this.signallers); - if (!IsValidSize(signallersCount)) - { - return result; - } - - // - // Clear Signal and Conditions ... - Clean(); - - // - // Check Waits Until New Bar ... - if (!this.provider.CanIgnoreProcess()) - { - return result; - } - - // - // Fill Market Conditions ... - provider.GetMarketConditions( - this.conditions, - barIndex // - ); - - // - // Retrieve All Scores ... - double bullishScore = 0; - double bearishScore = 0; - this.conditions.GenerateScore( - bullishScore, - bearishScore // - ); - - // - // Generate Conditions Summary and Comment it on Chart ... - string conditionsStr = this.conditions.GenerateSummary( - true // OnlySummary - ); - Comment("\n", conditionsStr); - - // - // Verifiers ... - int longVerifiers = 0; - int shortVerifiers = 0; - - // - double mR2R = 0; - double mVolume = 0; - double slPrice = 0; - double tpPrice = 0; - string mProvider = NULL; - - // - // Current Market ... - double cLNSL = 0; - double cLNTP = 0; - double cSHSL = 0; - double cSHTP = 0; - bool cHasLong = false; - bool cHasShort = false; - double cBullishScore = 0; - double cBearishScore = 0; - this.conditions.cMarketConditions.GenerateScore( - cBullishScore, - cBearishScore // - ); - - // - // Short Market ... - double sLNSL = 0; - double sLNTP = 0; - double sSHSL = 0; - double sSHTP = 0; - bool sHasLong = false; - bool sHasShort = false; - double sBullishScore = 0; - double sBearishScore = 0; - this.conditions.sMarketConditions.GenerateScore( - sBullishScore, - sBearishScore // - ); - - // - // Medium Market ... - double mLNSL = 0; - double mLNTP = 0; - double mSHSL = 0; - double mSHTP = 0; - bool mHasLong = false; - bool mHasShort = false; - double mBullishScore = 0; - double mBearishScore = 0; - this.conditions.mMarketConditions.GenerateScore( - mBullishScore, - mBearishScore // - ); - - // - // Long Market ... - double lLNSL = 0; - double lLNTP = 0; - double lSHSL = 0; - double lSHTP = 0; - bool lHasLong = false; - bool lHasShort = false; - double lBullishScore = 0; - double lBearishScore = 0; - this.conditions.lMarketConditions.GenerateScore( - lBullishScore, - lBearishScore // - ); - - // - // Hind Market ... - double hLNSL = 0; - double hLNTP = 0; - double hSHSL = 0; - double hSHTP = 0; - bool hHasLong = false; - bool hHasShort = false; - double hBullishScore = 0; - double hBearishScore = 0; - this.conditions.hMarketConditions.GenerateScore( - hBullishScore, - hBearishScore // - ); - - // - for (int i = 0; i < signallersCount; i++) - { - // - // Check all Markets for Long Conditions ... - - // - // Current Market ... - cLNSL = 0; - cLNTP = 0; - cHasLong = this.signallers[i] - .HasLongConditions( - this.conditions.cMarketConditions, - cLNSL, - cLNTP // - ); - if (cHasLong) - { - // - slPrice = cLNSL; - tpPrice = cLNTP; - longVerifiers++; - mR2R = this.signallers[i].r2r; - mProvider = this.signallers[i].GetName(); - mVolume = this.signallers[i].staticVolumeLong; - } - - // - // Short Market ... - sLNSL = 0; - sLNTP = 0; - sHasLong = this.signallers[i] - .HasLongConditions( - this.conditions.sMarketConditions, - sLNSL, - sLNTP // - ); - if (sHasLong) - { - // - slPrice = sLNSL; - tpPrice = sLNTP; - longVerifiers++; - mR2R = this.signallers[i].r2r; - mProvider = this.signallers[i].GetName(); - mVolume = this.signallers[i].staticVolumeLong; - } - - // - // Medium Market ... - mLNSL = 0; - mLNTP = 0; - mHasLong = this.signallers[i] - .HasLongConditions( - this.conditions.mMarketConditions, - mLNSL, - mLNTP // - ); - if (mHasLong) - { - // - slPrice = mLNSL; - tpPrice = mLNTP; - longVerifiers++; - mR2R = this.signallers[i].r2r; - mProvider = this.signallers[i].GetName(); - mVolume = this.signallers[i].staticVolumeLong; - } - - // - // Long Market ... - lLNSL = 0; - lLNTP = 0; - lHasLong = this.signallers[i] - .HasLongConditions( - this.conditions.lMarketConditions, - lLNSL, - lLNTP // - ); - if (lHasLong) - { - // - slPrice = lLNSL; - tpPrice = lLNTP; - longVerifiers++; - mR2R = this.signallers[i].r2r; - mProvider = this.signallers[i].GetName(); - mVolume = this.signallers[i].staticVolumeLong; - } - - // - // Hind Market ... - hLNSL = 0; - hLNTP = 0; - hHasLong = this.signallers[i] - .HasLongConditions( - this.conditions.hMarketConditions, - hLNSL, - hLNTP // - ); - if (hHasLong) - { - // - slPrice = hLNSL; - tpPrice = hLNTP; - longVerifiers++; - mR2R = this.signallers[i].r2r; - mProvider = this.signallers[i].GetName(); - mVolume = this.signallers[i].staticVolumeLong; - } - - // - // Check All Markets For Short Signals ... - - // - // Current Market ... - cSHSL = 0; - cSHTP = 0; - cHasShort = this.signallers[i] - .HasShortConditions( - this.conditions.cMarketConditions, - cSHSL, - cSHTP // - ); - if (cHasShort) - { - // - slPrice = cSHSL; - tpPrice = cSHTP; - shortVerifiers++; - mR2R = this.signallers[i].r2r; - mProvider = this.signallers[i].GetName(); - mVolume = this.signallers[i].staticVolumeShort; - } - - // - // Short Market ... - sSHSL = 0; - sSHTP = 0; - sHasShort = this.signallers[i] - .HasShortConditions( - this.conditions.sMarketConditions, - sSHSL, - sSHTP // - ); - if (sHasShort) - { - // - slPrice = sSHSL; - tpPrice = sSHTP; - shortVerifiers++; - mR2R = this.signallers[i].r2r; - mProvider = this.signallers[i].GetName(); - mVolume = this.signallers[i].staticVolumeShort; - } - - // - // Medium Market ... - mSHSL = 0; - mSHTP = 0; - mHasShort = this.signallers[i] - .HasShortConditions( - this.conditions.mMarketConditions, - mSHSL, - mSHTP // - ); - if (mHasShort) - { - // - slPrice = mSHSL; - tpPrice = mSHTP; - shortVerifiers++; - mR2R = this.signallers[i].r2r; - mProvider = this.signallers[i].GetName(); - mVolume = this.signallers[i].staticVolumeShort; - } - - // - // Long Market ... - lSHSL = 0; - lSHTP = 0; - lHasShort = this.signallers[i] - .HasShortConditions( - this.conditions.lMarketConditions, - lSHSL, - lSHTP // - ); - if (lHasShort) - { - // - slPrice = lSHSL; - tpPrice = lSHTP; - shortVerifiers++; - mR2R = this.signallers[i].r2r; - mProvider = this.signallers[i].GetName(); - mVolume = this.signallers[i].staticVolumeShort; - } - - // - // Hind Market ... - hSHSL = 0; - hSHTP = 0; - hHasShort = this.signallers[i] - .HasShortConditions( - this.conditions.hMarketConditions, - hSHSL, - hSHTP // - ); - if (hHasShort) - { - // - slPrice = hSHSL; - tpPrice = hSHTP; - shortVerifiers++; - mR2R = this.signallers[i].r2r; - mProvider = this.signallers[i].GetName(); - mVolume = this.signallers[i].staticVolumeShort; - } - - // - bool hasLong = - // - ( - // - cHasLong - // - || - // - sHasLong - // - ) - // - && - // - ( - // - mHasLong - // - || - // - lHasLong - // - || - // - hHasLong - // - ) - // - ; - - // - bool hasShort = - // - ( - // - cHasShort - // - || - // - sHasShort - // - ) - // - && - // - ( - // - mHasShort - // - || - // - lHasShort - // - || - // - hHasShort - // - ) - // - ; - - // - if (!(hasLong || hasShort)) - { - continue; - } - - // - bool isScorePassed = hasLong - ? bullishScore > bearishScore * 2 - : bearishScore > bullishScore * 2; - - // - bool hasSignal = - // - // isScorePassed && - (hasLong - ? longVerifiers >= 1 - : shortVerifiers >= 1) - // - ; - if (!hasSignal) - { - continue; - } - - // - // Try to Normalize SL and TP ... - - // - // For Longs ... - if (hasLong) - { - // - // Collect all Verifications SLs ... - - // - double sls[]; - double tps[]; - - // - // Current Market ... - - // - if (cLNSL > 0) - { - // - Add( - cLNSL, - sls // - ); - } - - // - if (cLNTP > 0) - { - // - Add( - cLNTP, - tps // - ); - } - - // - // Short Market ... - - // - if (sLNSL > 0) - { - // - Add( - sLNSL, - sls // - ); - } - - // - if (sLNTP > 0) - { - // - Add( - sLNTP, - tps // - ); - } - - // - // Medium Market ... - - // - if (mLNSL > 0) - { - // - Add( - mLNSL, - sls // - ); - } - - // - if (mLNTP > 0) - { - // - Add( - mLNTP, - tps // - ); - } - - // - // Long Market ... - - // - if (lLNSL > 0) - { - // - Add( - lLNSL, - sls // - ); - } - - // - if (lLNTP > 0) - { - // - Add( - lLNTP, - tps // - ); - } - - // - // Hind Market ... - - // - if (hLNSL > 0) - { - // - Add( - hLNSL, - sls // - ); - } - - // - if (hLNTP > 0) - { - // - Add( - hLNTP, - tps // - ); - } - - // - // Now Select Minimum SL ... - if (IsValidSize(ArraySize(sls))) - { - slPrice = GetMin(sls); - } - - // - // Average TP ... - if (IsValidSize(ArraySize(tps))) - { - tpPrice = GetAverage(tps); - } - } - - // - // For Shorts ... - if (hasShort) - { - // - // Collect all Verifications SLs ... - - // - double sls[]; - double tps[]; - - // - // Current Market ... - - // - if (cSHSL > 0) - { - // - Add( - cSHSL, - sls // - ); - } - - // - if (cSHTP > 0) - { - // - Add( - cSHTP, - tps // - ); - } - - // - // Short Market ... - - // - if (sSHSL > 0) - { - // - Add( - sSHSL, - sls // - ); - } - - // - if (sSHTP > 0) - { - // - Add( - sSHTP, - tps // - ); - } - - // - // Medium Market ... - - // - if (mSHSL > 0) - { - // - Add( - mSHSL, - sls // - ); - } - - // - if (mSHTP > 0) - { - // - Add( - mSHTP, - tps // - ); - } - - // - // Long Market ... - - // - if (lSHSL > 0) - { - // - Add( - lSHSL, - sls // - ); - } - - // - if (lSHTP > 0) - { - // - Add( - lSHTP, - tps // - ); - } - - // - // Hind Market ... - - // - if (hSHSL > 0) - { - // - Add( - hSHSL, - sls // - ); - } - - // - if (hSHTP > 0) - { - // - Add( - hSHTP, - tps // - ); - } - - // - // Now Select Minimum SL ... - if (IsValidSize(ArraySize(sls))) - { - slPrice = GetAverage(sls); - } - - // - // Average TP ... - if (IsValidSize(ArraySize(tps))) - { - tpPrice = GetAverage(tps); - } - } - - // - // Generate Signal ... - XSignal iSignal; - - // - ENUM_POSITION_TYPE mType = - hasLong - ? POSITION_TYPE_BUY - : POSITION_TYPE_SELL; - - // - double mEntry = GetEntry( - this.symbol, - mType // - ); - - // - double mTP = 0; - double mSL = 0; - CalculateTPSL( - mSL, - mTP, - mType, - mEntry, - mR2R, - slPrice, - tpPrice // - ); - if (mSL == 0 && mTP == 0) - { - continue; - } - - // - bool isPrepared = iSignal.Prepare( - this.symbol, - mProvider, - this.period, - mType, - X_ORDER_MODE_MARKET, - mEntry, - mVolume, - mSL, - mTP // - ); - if (!isPrepared) - { - iSignal.Clean(); - } - - // - if (iSignal.IsValid() && isPrepared && hasSignal) - { - // - AddRef( - iSignal, - this.signals // - ); - - // - this.provider.SetWaitsUntilNewBar(true); - } - } - - // - result = ArraySize(this.signals); - - // - // Set Wait Until New Bar ... - if (IsValidSize(result)) - { - this.provider.SetWaitsUntilNewBar(true); - } - - // - return result; - } - - // - // Check for Guards ... - int HasGuard(XGuard &guards[]) - { - // - int result = 0; - - // - Clean(guards); - - // - int signallersCount = CountSignallers(); - if (!IsValidSize(signallersCount)) - { - return result; - } - - // - // Loop through Signallers ... - for (int i = 0; i < signallersCount; i++) - { - // - XGuard iGuards[]; - int iGuardsCount = this.signallers[i] - .HasGuard(iGuards); - if (!IsValidSize(iGuardsCount)) - { - continue; - } - - // - Copy( - iGuards, - guards, - false // - ); - } - - // - result = ArraySize(guards); - - // - return result; - } - - // - // Count Signallers ... - int CountSignallers() - { - return ArraySize(signallers); - } - - // - // Find Specific Signaller Index ... - int FindSignallerIndex(ENUM_XSIGNAL_PROVIDERS name) - { - // - int result = -1; - - // - // Converts Provided Signaller Name to String ... - string strName = ToString(name); - - // - result = FindSignallerIndex(strName); - - // - return result; - } - - // - // Find Specific Signaller Index ... - int FindSignallerIndex(string name) - { - // - int result = -1; - - // - int signallersCount = ArraySize(signallers); - if (!IsValid() || - !IsValid(name) || - !IsValidSize(signallersCount) || - name == ToString(PROVIDER_NONE)) - { - return result; - } - - // - for (int i = 0; i < signallersCount; i++) - { - // - if (signallers[i].GetName() == name) - { - // - result = i; - break; - } - } - - // - return result; - } -}; - -// \ No newline at end of file diff --git a/Classes/x-saherelm.x121.xea.class.mq5 b/Classes/x-saherelm.x121.xea.class.mq5 deleted file mode 100644 index 6efb03ff..00000000 --- a/Classes/x-saherelm.x121.xea.class.mq5 +++ /dev/null @@ -1,2230 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Class Library -// ---------------------------------------------- -// Name: XSCX121EA -// Description: provides all X121 EA requirements ... -// - X5 Provider; -// -// -// 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.xea.class.mq5" -#include "../Classes/x-saherelm.x121.provider.class.mq5" - -// -// Define On Signal Event Handler Type Specified for X5 ... -typedef void (*TX121OnSignal)(X121ProviderDescriptor &descriptor); - -// -// Position Protect Structure ... -struct XProtectedPosition -{ - // - ulong ticket; // Position Ticket - string symbol; // Position Symbol - string provider; // Position Signaller - ENUM_TIMEFRAMES period; // Position Time Frame - ENUM_POSITION_TYPE type; // Position Type - double volume; // Position Volume - double entry; // Position Entry - double sl; // Position Stop Loss - double tp; // Position Take Profit - datetime openAt; // Position Opening Time - - // - // Working Variables ... - double recoveryZoneStep; // Used Recovery Zone Step - int lastRecoveryLevel; // Last Recovery Level - datetime lastRecoveryTime; // Last Recovery Time - double lastVolume; // Last Recovery Volume - ulong tickets[]; // Recovery Trades Tickets - - // - // Constructor ... - XProtectedPosition() - { - Clean(); - } - - // - // Tools ... - - // - // Initialized ... - bool Init( - double mRecoveryZoneStep, - XPosition &mPosition // - ) - { - // - bool result = false; - - // - // Validate Params ... - result = - // - mPosition.IsValid() && - mRecoveryZoneStep > 0 - // - ; - if (!result) - { - return result; - } - - // - Clean(); - - // - sl = mPosition.sl; - tp = mPosition.tp; - type = mPosition.type; - entry = mPosition.entry; - ticket = mPosition.ticket; - symbol = mPosition.symbol; - period = mPosition.period; - volume = mPosition.volume; - openAt = mPosition.openAt; - provider = mPosition.provider; - recoveryZoneStep = mRecoveryZoneStep; - - // - result = IsValid(); - - // - return result; - } - - // - // Cleanup ... - void Clean() - { - // - ticket = 0; - symbol = NULL; - period = NULL; - provider = NULL; - volume = 0; - entry = 0; - sl = 0; - tp = 0; - openAt = NULL; - lastRecoveryLevel = 0; - lastVolume = 0; - lastRecoveryTime = NULL; - Clean(tickets); - } - - // - // Validate ... - bool IsValid() - { - // - bool result = false; - - // - result = - // - ticket > 0 && - volume > 0 && - entry > 0 && - tp > 0 && - sl > 0 && - IsSpecifiedValid(symbol) && - IsSpecifiedValid(provider) && - IsSpecifiedValid(period) - // - ; - - // - return result; - } - - // - // Check Protected Type ... - bool IsLong() - { - // - bool result = false; - - // - result = IsValid(); - if (!result) - { - return result; - } - - // - result = IsLong(this.type); - - // - return result; - } - - // - // Retrieve Tick Based on Protected ... - bool GetTick( - MqlTick &tick // - ) - { - // - bool result = false; - - // - // Validate ... - result = IsValid(); - if (!result) - { - return result; - } - - // - result = GetTick( - this.symbol, - tick // - ); - - // - return result; - } - - // - // Retrieve Current Exit Price based on Protected ... - double GetExit() - { - // - double result = GetExit( - this.symbol, - this.type // - ); - - // - return result; - } - - // - // Retrieve Current Entry Price based on Protected ... - double GetEntry() - { - // - double result = GetEntry( - this.symbol, - this.type // - ); - - // - return result; - } - - // - // Calculate Recovery Step Price ... - double GetRecoveryAreaPrice() - { - // - double result = 0; - - // - // Validate ... - if (!IsValid()) - { - return result; - } - - // - double stepPrice = PointToPrice( - recoveryZoneStep, - symbol // - ); - - // - bool isLong = IsLong(type); - - // - result = - isLong - ? entry - stepPrice - : entry + stepPrice; - - // - return result; - } - - // - // Check Protected Has Recovery or not ... - // it it's true ... fill signal by proper info ... - bool GetRecoverySignal( - XSignal &signal // Result ... - ) - { - // - bool result = false; - - // - signal.Clean(); - - // - // Validate ... - result = IsValid(); - if (!result) - { - return result; - } - - // - // Check Position is Reoverable or not ... - bool isLong = IsLong(); - double recoveryPrice = GetRecoveryAreaPrice(); - - // - int currRecoveryLevel = lastRecoveryLevel + 1; - - // - double mExit = GetExit(); - double mEntry = GetEntry(); - double recoveryDiff = MathAbs(mEntry - recoveryPrice); - - // - // First Check Opposite Direction ... - bool canOppositDirectionRecover = - // - // Check State for Opposit Recovery ... - lastRecoveryLevel % 2 == 0 && - // - (isLong - ? mExit < recoveryPrice - : mExit > recoveryPrice) - // - ; - - // - // Check Same Direction Recovery ... - bool canSameDirectionRecover = - // - // Since for Same Direction Recover we have to at leaset 1 Opposite Recovery ... - lastRecoveryLevel % 2 == 1 && - // - (isLong - ? mEntry >= entry - : mEntry <= entry) - // - ; - - // - // Check Protected Can Recoverable or not ... - result = - // - lastRecoveryLevel < 5 && - (canSameDirectionRecover || - canOppositDirectionRecover) - // - ; - if (!result) - { - return result; - } - - // - // Check Last Recovery Time ... - int age = - !IsValid(this.lastRecoveryTime) - ? -1 - : iBarShift( - this.symbol, - this.period, - this.lastRecoveryTime, - false // - ); - result = - age == -1 - ? true - : age >= 5; - if (!result) - { - return result; - } - - // - // Now we have to Prepare Signal based on Recovery Mode ... - - // - // Recovery Position Type ... - ENUM_POSITION_TYPE mType = - canSameDirectionRecover - ? this.type - : GetOpposit(this.type); - - // - bool isMLong = IsLong(mType); - - // - // Recovery Position Entry Price ... - mEntry = GetEntry( - this.symbol, - mType // - ); - - // - // SL and TP ... - double mTP = - canSameDirectionRecover - ? this.tp - : this.sl; - mTP = - isMLong - ? mTP + recoveryDiff - : mTP - recoveryDiff; - - // - double mSL = - canSameDirectionRecover - ? this.sl - : this.tp; - mSL = - isMLong - ? mSL - recoveryDiff - : mSL + recoveryDiff; - - // - // Volume ... - // For Volume Calculating we have to use Recovery Level ... - // double mVolume = - // lastVolume == 0 - // ? volume * 1 - // : lastVolume * 1; - double mVolume = - canSameDirectionRecover - ? volume - : volume * 2; - - // - result = signal.Prepare( - this.symbol, - this.provider, - this.period, - mType, - X_ORDER_MODE_MARKET, - mEntry, - mVolume, - mSL, - mTP // - ); - - // - return result; - } -}; - -// -// a Position Protector Class ... -class XSCPositionProtector : public XSCBaseAlert -{ - // - // Public ... -public: - // - // Props ... - - // - bool enable; - - // - // Protected Positions ... - XProtectedPosition protecteds[]; - - // - // Trader Class Instance ... - XSCTrade *mTrader; - - // - // Constructor ... - void XSCPositionProtector() - { - // - Clean(protecteds); - - // - SetRecoveryStepDivider(5); - SetRecoveryStepPeriod(PERIOD_D1); - } - - // - // Deconstructor ... - void ~XSCPositionProtector() - { - delete mTrader; - } - - // - // Setter(s) / Getter(s) ... - - // - void SetRecoveryStepPeriod(ENUM_TIMEFRAMES value) - { - this.recoveryStepPeriod = value; - } - - // - ENUM_TIMEFRAMES GetRecoveryStepPeriod() - { - return this.recoveryStepPeriod; - } - - // - void SetRecoveryStepDivider(int value) - { - // - if (value <= 3) - { - value = 3; - } - - // - this.recoveryStepDivider = value; - } - - // - int GetRecoveryStepDivider() - { - return this.recoveryStepDivider; - } - - // - void SetMinRequiredProfitPerTrade(double value) - { - // - if (value < 0) - { - value = 0; - } - - // - this.minRequiredProfitPerTrade = value; - } - - // - double GetMinRequiredProfitPerTrade() - { - return this.minRequiredProfitPerTrade; - } - - // - void SetMinRequiredProfitPerTradeVolumeFactor(double value) - { - // - if (value < 0) - { - value = 0; - } - - // - this.minRequiredProfitPerTradeVolumeFactor = value; - } - - // - double GetMinRequiredProfitPerTradeVolumeFactor() - { - return this.minRequiredProfitPerTradeVolumeFactor; - } - - // - // Tools ... - - // - // Initial Class ... - bool Init( - bool mEnable, - XSCTrade *trader, - double mMinRequiredProfitPerTrade = 0.5, - double mMinRequiredProfitPerTradeVolumeFactor = 0.01 // - ) - { - // - bool result = false; - - // - this.enable = mEnable; - - // - result = trader != NULL; - if (!result) - { - return result; - } - - // - this.mTrader = trader; - - // - SetMinRequiredProfitPerTrade(mMinRequiredProfitPerTrade); - SetMinRequiredProfitPerTradeVolumeFactor(mMinRequiredProfitPerTradeVolumeFactor); - - // - return result; - } - - // - // Handle Trades for Processing ... - // this used for Automating Recovery Positions ... - // we have to call this in our EA Class ... - void HandleState(const XOnTradeHandlerState &state) - { - // - if (!enable) { - return; - } - - // - if ( - !state.hasNewDeal && - !state.hasNewOrder && - !state.hasNewPosition && - !state.hasNewHistoryOrder) - { - return; - } - - // - // Here we Can Handle new Positions ... - // To Protect ... - - // - // Detect New Positions ... - if (!state.hasNewPosition) - { - // - // This means a Position SL or TP or Close ... - return; - } - - // - ulong lastPositionTicket = mTrader.GetLastOpenPositionTicket(); - if (lastPositionTicket <= 0) - { - return; - } - - // - // Retrieve XPosition ... - XPosition position; - bool isRetrieved = mTrader.GetPosition( - lastPositionTicket, - position // - ); - if (!isRetrieved) - { - return; - } - - // - // Now we Have Position Struct ... - // - First Check Position is new Regular Position or - // it is a Support Position; - // - then We have to Decide what to Do ... - - // - // Check Position is New Or Not ... - ulong parentTicket = ExtractEQMSupportedTicket(position.comment); - if (!NotEmptyZero(parentTicket)) - { - // - AddPosition(position); - } - else - { - // - UpdatePosition( - parentTicket, - position // - ); - } - } - - // - // Here we Process all Protected Positions ... - // for Handling Zone Recovery ... - void Process() - { - // - if (!enable) { - return; - } - - // - int protectedsCount = ArraySize(protecteds); - if (IsValidSize(protectedsCount)) - { - // - // Loop through Exists ... - for (int i = 0; i < protectedsCount; i++) - { - // - // Do Protection ... - HandlePositionsProtecting(protecteds[i]); - } - } - - // - string comment = XEQMSupportToken + " Hege ..."; - - // - // Handle Hedging All Positions ... - bool allowHedge = AllowHedge(); - if (allowHedge) - { - // - XPosition positions[]; - int positionsCount = mTrader.GetPositions(positions); - if (!IsValidSize(positions) || positionsCount <= 1) - { - // - // Here We Can Close if Still Positions is EQM Support ... - bool canClosePosition = - // - positionsCount == 1 && - positions[0].provider == XEQMSupportToken && - positions[0].profit > (-1 * positions[0].swap) + (minRequiredProfitPerTrade * (positions[0].volume / minRequiredProfitPerTradeVolumeFactor)) - // - ; - if (canClosePosition) - { - // - bool isClosed = mTrader.Close( - positions[0].ticket, - comment // - ); - } - return; - } - - // - double profit = SpecifiedCalculatePositionsProfit(positions); - double requiredProfit = SpecifiedCalculateRequiredProfitForHedge( - positions, - minRequiredProfitPerTrade, - minRequiredProfitPerTradeVolumeFactor // - ); - bool canHedge = SpecifiedIsPositionsReadyForHedge( - positions, - minRequiredProfitPerTrade, - minRequiredProfitPerTradeVolumeFactor // - ); - if (!canHedge) - { - // - ProtectMargin(); - return; - } - - // - ENUM_X_SIGNAL_EXECUTION_RESULT states[]; - int closed = mTrader.Close( - positions, - comment // - ); - if (IsValidSize(closed)) - { - Clean(protecteds); - } - } - } - - // - // Sync Positions ... - - // - // Remove Support ... - bool Remove(ulong ticket) - { - // - bool result = false; - - // - if (!enable) { - return result; - } - - - // - int protectedIDX = FindProtectedIndex(ticket); - result = protectedIDX >= 0; - if (!result) - { - return result; - } - - // - // Close all Protected Support Positions if Exists ... - string comment = "EQM Close In Profit ..."; - - // - int ticketsCount = ArraySize(protecteds[protectedIDX].tickets); - if (IsValidSize(ticketsCount)) - { - // - for (int i = 0; i < ticketsCount; i++) - { - // - XPosition iPosition; - bool isRetrieved = mTrader.GetPosition( - protecteds[protectedIDX].tickets[i], - iPosition // - ); - if (!isRetrieved) - { - continue; - } - - // - bool isClosed = mTrader.Close( - iPosition.ticket, - comment // - ); - } - } - - // - result = ArrayRemove( - protecteds, - protectedIDX, - 1 // - ); - - // - // TODO: Update Collection here ... - - // - return result; - } - - // - // Protected ... -protected: - // - // Props ... - double minRequiredProfitPerTrade; // Minimum Required Profit Per Trade for Hedging - double minRequiredProfitPerTradeVolumeFactor; // Calculate Required Profit Based on Volume Factor for Hedging - int recoveryStepDivider; // Recovery Step Divider - ENUM_TIMEFRAMES recoveryStepPeriod; // Recovery Step Period - - // - // Tools ... - - // - // Here we recieve a new Position and - // Prepare it for Protecting ... - void AddPosition(XPosition &position) - { - // - // - Recieve Last Day Up and Low Boundary - // - Divided to 5 - // - Find Recovery Zone Step - // - Calculate Recoery Zone for this Specific Position - // - Prepare it's Structure - // - Add it to Collection - - // - // Validate Params ... - if (!position.IsValid()) - { - return; - } - - // - double recoveryStep = CalculateRecoveryZoneStep(position); - if (recoveryStep <= 0) - { - return; - } - - // - XProtectedPosition item; - bool isInited = item.Init( - recoveryStep, - position // - ); - if (!isInited) - { - return; - } - - // - AddRef( - item, - protecteds // - ); - - // - // TODO: Also Here We Can Collect Data ... - } - - // - // Here we recieve a Support Position and - // need to Update Parent Protected Position's - // info ... - void UpdatePosition( - ulong parentTicket, // Parent Position Ticket - XPosition &position // Support Position - ) - { - // - Print("Update Protected Position: " + ToString(parentTicket)); - } - - // - // Calculate Position Recovery one Step ... - double CalculateRecoveryZoneStep(XPosition &position) - { - // - double result = 0; - - // - // Validate Position ... - if (!position.IsValid()) - { - return result; - } - - // - // Validate Position must have TP and SL ... - if (position.tp == 0 || position.sl == 0) - { - return result; - } - - // - // Calculate Position Risk at Point ... - double point = GetPoints(position.symbol); - int digits = GetDigits(position.symbol); - double riskPoint = NormalizeDouble(MathAbs(position.entry - position.sl), digits) / point; - - // - // Retrieve Bar for finding Recovery Step ... - XOHCL rBar; - bool isInited = rBar.Init( - position.symbol, - recoveryStepPeriod, - 1 // - ); - if (!isInited) - { - return result; - } - - // - // Calculate Recovery Step ... - double riskPointRecoveryStep = riskPoint / 2; - double recoveryStep = (NormalizeDouble(MathAbs(rBar.high - rBar.low), digits) / point) / recoveryStepDivider; - result = MathMin(riskPointRecoveryStep, recoveryStep); - - // - return result; - } - - // - // Here we Implement all Protecting Senarios here ... - void HandlePositionsProtecting(XProtectedPosition &item) - { - // - // Check protected Validation ... - if (!item.IsValid()) - { - return; - } - - // - // Check Has Recovery Signal Or Not ... - XSignal signal; - bool hasRecovery = item.GetRecoverySignal(signal); - if (!hasRecovery) - { - return; - } - - // - signal.provider = XEQMSupportToken; - string comment = GenerateEQMSupportTag(item.ticket); - signal.comment = comment; - - // - // Remove Support Signal TP and SL ... - signal.tp = 0; - signal.sl = 0; - - // - ENUM_X_SIGNAL_EXECUTION_RESULT state; - bool isExecuted = mTrader.ExecuteSignal( - signal, - state, - ORDER_TIME_GTC, - NULL, - false // Ignore Policies ... - ); - if (isExecuted) - { - // - // Do What we Want ... - item.lastRecoveryLevel++; - item.lastVolume = signal.volume; - item.lastRecoveryTime = TimeCurrent(); - Add( - signal.positionId, - item.tickets // - ); - - // - int protectedIDX = FindProtectedIndex(item.ticket); - if (protectedIDX < 0) - { - return; - } - - // - protecteds[protectedIDX] = item; - - // - // TODO: Update Collect here ... - } - } - - // - // Check Hedging is Enabled ... - bool AllowHedge() - { - // - bool result = - // - minRequiredProfitPerTrade > 0 && - minRequiredProfitPerTradeVolumeFactor > 0 - // - ; - - // - return result; - } - - // - // Protecting Margin by Free Coveraged Positions ... - void ProtectMargin() - { - // - double freeMargin = mTrader.mAccount.GetFreeMargin(); - - // - double balance = mTrader.mAccount.GetBalance(); - double equity = mTrader.mAccount.GetEquity(); - - // - double selectedBalance = MathMin(balance, equity); - - // - // Retrieve All Positions ... - XPosition positions[]; - int positionsCount = mTrader.GetPositions(positions); - if (!IsValidSize(positionsCount)) - { - return; - } - - // - bool canForceHedging = - positionsCount >= 25 || - freeMargin <= selectedBalance / 2; - if (!canForceHedging) - { - return; - } - - // - // First Check Hedging By Half of Required Profit ... - double profit = SpecifiedCalculatePositionsProfit(positions); - double requiredProfit = SpecifiedCalculateRequiredProfitForHedge( - positions, - minRequiredProfitPerTrade, - minRequiredProfitPerTradeVolumeFactor // - ); - bool canHedge = - // - profit > requiredProfit / 2 - // - ; - if (canHedge) - { - // - string comment = XEQMSupportToken + " Hege ..."; - int closed = mTrader.Close( - positions, - comment // - ); - - // - return; - } - - // - // TODO: Enable this if we want ... - return; - - // - // Retrieve In Drawdown Positions ... - XPosition inDPositions[]; - int inDPositionsCount = ExtractInDrawdownPositions( - positions, - inDPositions /// - ); - if (!IsValidSize(inDPositionsCount)) - { - return; - } - - // - // Retrieve In Profit Positions ... - XPosition inPPositions[]; - int inPPositionsCount = ExtractInProfitPositions( - positions, - inPPositions // - ); - if (!IsValidSize(inPPositionsCount)) - { - return; - } - - // - // if we can't Hedge all Positions ... - // now we are looking to pair Positions for hedge ... - // - Select Max In Drawdown Position; - // - Looking for Coverage it inside In Profit Positions; - // - Clease All of them ... - int maxInDIDX = FindMaxDrawdownIndex(inDPositions); - if (maxInDIDX < 0) - { - return; - } - - // - string comment = XEQMSupportToken + " Force Hege ..."; - - // - XPosition maxInDCoverages[]; - int maxInDCoveragesCount = FindCoverageDrawdownPosition( - inDPositions[maxInDIDX], - inPPositions, - maxInDCoverages, - minRequiredProfitPerTrade, - minRequiredProfitPerTradeVolumeFactor // - ); - if (!IsValidSize(maxInDCoveragesCount)) - { - return; - } - - // - bool isClosedMaxInD = mTrader.Close( - inDPositions[maxInDIDX].ticket, - comment // - ); - if (isClosedMaxInD) - { - // - int closed = mTrader.Close( - maxInDCoverages, - comment // - ); - } - } - - // - // Protected Collection Management ... - - // - int CountProtecteds() - { - return ArraySize(protecteds); - } - - // - int FindProtectedIndex(XProtectedPosition &item) - { - // - int result = -1; - - // - if (!item.IsValid()) - { - return result; - } - - // - result = FindProtectedIndex(item.ticket); - - // - return result; - } - - // - int FindProtectedIndex(ulong ticket) - { - // - int result = -1; - - // - if (!NotEmptyZero(ticket)) - { - return result; - } - - // - int protectedsCount = CountProtecteds(); - if (!IsValidSize(protectedsCount)) - { - return result; - } - - // - for (int i = 0; i < protectedsCount; i++) - { - // - if (protecteds[i].ticket == ticket) - { - // - result = i; - break; - } - } - - // - return result; - } -}; - -// -// Class Definition ... - -class XSCX121EA : public XSCBaseEA -{ - // - // Public ... -public: - // - // Props ... - - // - // Constructors ... - XSCX121EA( - // - // XTrade Class Requirements ... - int slippage, // Specify Slippage - ulong magicNumber, // Specify Magic Number - // - // Time Management ... - // TODO: ... - // - // XSCTrade Event Handlers ... - TOnStopLoss onStopLossTriggered = NULL, // On StopLoass Triggered Event Handler - TOnTakeProfit onTakeProfitTriggered = NULL, // On TakeProfit Triggered Event Handler - TOnDealsChanged onDealsChangedHandler = NULL, // On Deals Changed Event Handler - TOnOrdersChanged onOrdersChangedHandler = NULL, // On Orders Changed Event Handler - TOnPositionsChanged onPositionsChangedHandler = NULL, // On Positions Changed Event Handler - TOnTradeStateChanged onTradeStateChangedHandler = NULL, // On Trade State Changed Event Handler - // - // Custom Event Handler ... - TOnSignal onSignalHandler = NULL // On Signal Event Handler - ) : XSCBaseEA(slippage, - magicNumber, - onStopLossTriggered, - onTakeProfitTriggered, - onDealsChangedHandler, - onOrdersChangedHandler, - onPositionsChangedHandler, - onTradeStateChangedHandler // - ) - { - // - mProtector = new XSCPositionProtector(); - mProtector.Init(false, mTrader); - } - - // - // Deconstructor ... - ~XSCX121EA() - { - delete mProtector; - } - - // - // Properties Getter(s) / Setter(s) ... - - // - // Add X5 Specified Signal Event Handler ... - void AddOnSignalEventHandler(TX121OnSignal listener) - { - // - Add( - listener, - mX121OnSignalEventHandlers - // - ); - } - - // - // Add Specified X5 Provider ... - bool AddProvider(X121ProviderDescriptor &descriptor) - { - // - bool result = false; - - // - // Validate Inputs ... - result = descriptor.Init(); - if (!result) - { - return result; - } - - // - AddRef( - descriptor, - mDescriptors // - ); - - // - return result; - } - - // - // Overrides ... - - // - // Customize Token ... - string GetToken() override - { - return GetSpecificToken(this); - } - - // - string GetTag() override - { - return this.GetToken(); - } - - // - void Draw() override - { - // - int descriptorsCount = CountDescriptors(); - if (descriptorsCount <= 0) - { - return; - } - - // - for (int i = 0; i < descriptorsCount; i++) - { - // - X121ProviderDescriptor iDescriptor = mDescriptors[i]; - - // - iDescriptor.provider.Draw(); - } - } - - // - // Check Provider for any Guards ... - bool CheckForGuard(XGuard &guards[]) override - { - // - bool result = false; - - // - Clean(guards); - - // - int descriptorsCount = CountDescriptors(); - result = descriptorsCount > 0; - if (!result) - { - return result; - } - - // - // Loop Through Descriptors for Collecting Guards ... - for (int i = 0; i < descriptorsCount; i++) - { - // - X121ProviderDescriptor iDescriptor = mDescriptors[i]; - - // - XGuard iGuards[]; - int iGuardsCount = iDescriptor.HasGuard(iGuards); - if (!IsValidSize(iGuardsCount)) - { - continue; - } - - // - Copy( - iGuards, - guards, - false // - ); - } - - // - result = ArraySize(guards) > 0; - - // - return result; - } - - // - // Request Provider to Collect all - // Potentially Signals and then - // filters theme here and passed them - // for Executing ... - int RequestForSignal( - XSignal &signals[] // Holds Signals ... - ) override - { - // - bool result = 0; - - // - Clean(signals); - - // - int descriptorsCount = CountDescriptors(); - if (descriptorsCount <= 0) - { - return result; - } - - // - for (int i = 0; i < descriptorsCount; i++) - { - // - X121ProviderDescriptor iDescriptor = mDescriptors[i]; - - // - if (iDescriptor.provider.CanIgnoreProcess()) - { - continue; - } - - // - int iSignalsCount = iDescriptor.HasSignal(); - if (IsValidSize(iSignalsCount)) - { - // - // Here we Can double check Signals by Conditions - // for Score Base Filtering ... - iDescriptor.provider.SetWaitsUntilNewBar(true); - - // - Copy( - iDescriptor.signals, - signals, - false - // - ); - - // - NotifyX121OnSignalEventHandlers(iDescriptor); - } - } - - // - result = ArraySize(signals); - - // - return result; - } - - // - // Request for Support Signals using Guard ... - bool RequestForSupport( - XSignal &support, // Holds Support Signal, if Provided - string provider, // Positions Provided by Specific Provider - string symbol, // Trading Symbol - ENUM_X_POSITION_TYPE type, // Trading Type - ENUM_TIMEFRAMES period // Specified Time Frame - ) override - { - // - // TODO: Implement this ... - - // - // Support Senario ... - // Check Support Position Exists or not ... - // Check Positions for Support based on Types ... - // Update Untriggered Positions ... - return false; - } - - // - // Here we Manage Signals for Executing ... - // - Check Policies based on their Signaller ... - // - Check Same Time Open Positions ... - // - Check Signal Age for new Trade ... - // and etc ... - int HandleSignalManagement(XSignal &signals[]) override - { - // - int result = 0; - - // - int signalsCount = ArraySize(signals); - if (!IsValidSize(signalsCount)) - { - return result; - } - - // - XSignal tmpSignals[]; - Copy( - signals, - tmpSignals // - ); - - // - Clean(signals); - - // - for (int i = 0; i < signalsCount; i++) - { - // - XSignal iSignal = tmpSignals[i]; - - // - // Find Provider Descriptor Which Issued this Signal ... - int iProviderIDX = FindDescriptorIndex( - iSignal.symbol, - iSignal.period); - if (!IsValidIndex(iProviderIDX)) - { - // - string message = "Couldn't find Signal Descriptor ..."; - Log(message); - - // - continue; - } - - // - // Now we Have to Find Signaller Which Issued this Signal ... - int iSignallerIDX = mDescriptors[iProviderIDX] - .FindSignallerIndex(iSignal.provider); - if (!IsValidIndex(iSignallerIDX)) - { - // - string message = "Couldn't find Signal Provider ..."; - Log(message); - - // - continue; - } - - // - // Check Position Type is Enabled or not ... - bool isLong = IsLong(iSignal.type); - bool isAllowedType = isLong - ? mDescriptors[iProviderIDX].signallers[iSignallerIDX].allowLong - : mDescriptors[iProviderIDX].signallers[iSignallerIDX].allowShort; - if (!isAllowedType) - { - // - string message = "ignore Signal due Type Policy ..."; - Log(message); - - // - continue; - } - - // - // Retrieve Long and Short Signals of same Provider ... - XPosition longs[]; - XPosition shorts[]; - mTrader.GetPositions( - longs, - shorts, - iSignal.symbol, - iSignal.provider, - iSignal.period // - ); - int longsCount = ArraySize(longs); - int shortsCount = ArraySize(shorts); - - // - // Check Max Number of Positions ... - bool isMaxNumberOfPositionsPassed = isLong - ? mDescriptors[iProviderIDX].signallers[iSignallerIDX].maxAllowedLong <= 0 - ? true - : longsCount < mDescriptors[iProviderIDX].signallers[iSignallerIDX].maxAllowedLong - : mDescriptors[iProviderIDX].signallers[iSignallerIDX].maxAllowedShort <= 0 - ? true - : shortsCount < mDescriptors[iProviderIDX].signallers[iSignallerIDX].maxAllowedShort; - if (!isMaxNumberOfPositionsPassed) - { - // - string message = "ignore Signal due Max Allowed Positions Reached ..."; - Log(message); - - // - continue; - } - - // - // Check Delay Between Two Same Type Signals ... - // Check Open Next Behaviour ... - if (longsCount > 0 || shortsCount > 0) - { - // - // Check if Signaller Configured for Check Delay between Same type Signals ... - if (mDescriptors[iProviderIDX].signallers[iSignallerIDX].delayBetweenTwoSameTypeSignals > 0) - { - // - bool isDelayPassed = true; - - // - if (longsCount > 0) - { - // - XPosition youngestLong; - int youngestLongAge = GetYoungest( - youngestLong, - longs // - ); - - // - if (isLong) - { - isDelayPassed = youngestLongAge >= mDescriptors[iProviderIDX].signallers[iSignallerIDX].delayBetweenTwoSameTypeSignals; - } - } - - // - if (shortsCount > 0) - { - // - XPosition youngestShort; - int youngetsShortAge = GetYoungest( - youngestShort, - shorts // - ); - - // - if (!isLong) - { - isDelayPassed = youngetsShortAge >= mDescriptors[iProviderIDX].signallers[iSignallerIDX].delayBetweenTwoSameTypeSignals; - } - } - - // - if (!isDelayPassed) - { - // - string message = "ignore Signal due Delay Between Same Type Policy ..."; - Log(message); - - // - continue; - } - } - - // - // Check Next Position ... - if (mDescriptors[iProviderIDX].signallers[iSignallerIDX].openNextPositionOnProfit) - { - // - bool isNextPassed = true; - - // - if (isLong && longsCount > 0) - { - // - double profit = SpecifiedCalculatePositionsProfit(longs); - isNextPassed = profit > 0; - } - - // - if (!isLong && shortsCount > 0) - { - // - double profit = SpecifiedCalculatePositionsProfit(shorts); - isNextPassed = profit > 0; - } - - // - // Check Ignore for Opposit Signals ... - if (!isNextPassed && - ((isLong && shortsCount > longsCount) || - (!isLong && longsCount > shortsCount))) - { - isNextPassed = mDescriptors[iProviderIDX].signallers[iSignallerIDX].ignoreProfitForOppositeSignals; - } - - // - if (!isNextPassed) - { - // - string message = "ignore Signal due Next Must be In Profit Policy ..."; - Log(message); - - // - continue; - } - } - } - - // - // Finally Add Filtered Signals into Result ... - AddRef( - iSignal, - signals // - ); - } - - // - result = ArraySize(signals); - - // - return result; - } - - // - // Handle State Management .... - // here we can manage current state ... - // - Check for Long Positions for each Signaller to Close ... - // - Handle Hedging Signaller's Positions if it's enabled ... - // - Force Closing Position when Specified Time reached ... - // - Check Start and End time or Trading Dates ... - // - handle Trailing or Risk free Signals based on several conditions ... - // and etc ... - bool HandleStateManagement(XSignal &signals[]) override - { - // - const bool result = false; - - // - // Here we Implement Account Protector ... - HandleAccountProtect(); - - // - // Check Descriptor ... - int descriptorsCount = CountDescriptors(); - if (!IsValidSize(descriptorsCount)) - { - return result; - } - - // - // Loop Through Descriptors ... - for (int i = 0; i < descriptorsCount; i++) - { - // - // Check Signallers ... - int signallersCount = mDescriptors[i].CountSignallers(); - if (!IsValidSize(signallersCount)) - { - continue; - } - - // - // Loop Through Signallers ... - for (int j = 0; j < signallersCount; j++) - { - // - // Retrieve Specified Signaller's Position ... - XPosition positions[]; - int positionsCount = mTrader.GetPositions( - positions, - mDescriptors[i].symbol, - mDescriptors[i].signallers[j].GetName(), - mDescriptors[i].period); - if (!IsValidSize(positionsCount)) - { - continue; - } - - // - // Check Signaller Enable Hedge or not and Handle it if enabled ... - if (positionsCount > 1 && mDescriptors[i].signallers[j].AllowHedge()) - { - // - // Check Profits Enough for Hedge or not ... - double profit = SpecifiedCalculatePositionsProfit(positions); - bool isReadyForHedge = - positionsCount > 1 && - SpecifiedIsPositionsReadyForHedge( - positions, - mDescriptors[i].signallers[j].minRequiredProfitPerTrade, - mDescriptors[i].signallers[j].minRequiredProfitPerTradeVolumeFactor // - ); - if (isReadyForHedge) - { - // - string comment = "Close due Hedge ..."; - int closeds = mTrader.Close( - positions, - comment // - ); - - // - if (closeds > 0) - { - // - string message = "Hedge (" + ToString(closeds) + ") Positions In Profit: " + ToString(profit); - - // - Alert(message); - - // - break; - } - } - } - - // - // Check Closing Long Age Position's Enabled or not ... - if (mDescriptors[i].signallers[j].maxAllowedOpenPositionAge > 0) - { - // - // Handle Close Long Time Trades ... - - // - // Find Oldest ... - XPosition oldest; - int oldestAge = GetOldest( - oldest, - positions // - ); - if (oldestAge >= mDescriptors[i].signallers[j].maxAllowedOpenPositionAge) - { - // - string comment = "Close due Long Age ..."; - bool isClosed = mTrader.Close( - oldest.ticket, - comment // - ); - - // - if (isClosed) - { - // - string message = "Position (" + ToString(oldest.ticket) + ") Closed due Long Age Policy ..."; - Alert(message); - } - } - } - } - } - - // - // if Returns true, Signal Execution failed ... - return result; - } - - // - void OnStopLossTriggered(const XDeal &deal) override - { - // - // Remove Position Protecting ... - mProtector.Remove(deal.positionId); - } - - // - void OnTakeProfitTriggered(const XDeal &deal) override - { - // - // Remove Position Protecting ... - mProtector.Remove(deal.positionId); - } - - // - void OnTradeStateChangedHandler( - const XOnTradeHandlerState &state // - ) override - { - // - // Calling Protector to Handle State ... - mProtector.HandleState(state); - } - - // - void HandleAccountProtect() - { - // - // Position Protector Calls to Process State ... - mProtector.Process(); - } - - // - // Tools ... - - // - // Protected ... -protected: - // - // Tools ... - - // - void NotifyX121OnSignalEventHandlers(X121ProviderDescriptor &descriptor) - { - // - int listenersCount = ArraySize(mX121OnSignalEventHandlers); - if (listenersCount <= 0) - { - return; - } - - // - for (int i = 0; i < listenersCount; i++) - { - // - TX121OnSignal iListener = mX121OnSignalEventHandlers[i]; - - // - iListener(descriptor); - } - } - - // - // Protect Specified Position ... - void ProtectPosition(XPosition &position) - { - // - // Here i Can Protect Position ... - // This Protect Include One Position in Market Mode ... - // If Provided ... - // the Positions Selection must passed Some conditions ... - - // - string message = "For (" + position.symbol + ") Max In Drawdown Position is: (" + - ToString(position.ticket) + "), by Profit: " + ToString(position.profit); - - // - mAlert.Alert(message); - } - - // - // Private ... -private: - // - // Props ... - - // - // Collection of Signal Event Listeners ... - TX121OnSignal mX121OnSignalEventHandlers[]; - - // - // a Collection of X5 Provider Descriptors ... - X121ProviderDescriptor mDescriptors[]; - - // - int CountDescriptors() - { - return ArraySize(mDescriptors); - } - - // - // Find Specifc Descriptor ... - int FindDescriptorIndex( - string symbol, - ENUM_TIMEFRAMES period // - ) - { - // - int result = -1; - - // - if (!IsValid(symbol) || - !IsValid(period)) - { - return result; - } - - // - int descriptorsCount = CountDescriptors(); - if (!IsValidSize(descriptorsCount)) - { - return result; - } - - // - for (int i = 0; i < descriptorsCount; i++) - { - // - X121ProviderDescriptor iDescriptor = mDescriptors[i]; - - // - bool isPassed = - // - iDescriptor.symbol == symbol && - iDescriptor.period == period - // - ; - if (isPassed) - { - // - result = i; - break; - } - } - - // - return result; - } - - template - int FindDescriptorIndex( - T &item // - ) - { - return FindDescriptorIndex( - item.symbol, - item.period // - ); - } - - // - // Trails Holding ... - - // - XTrail mSLTrails[]; - XTrail mTPTrails[]; - - // - int CountSLTrails() - { - return ArraySize(mSLTrails); - } - int CountTPTrails() - { - return ArraySize(mTPTrails); - } - - // - bool RemoveTrail(ulong ticket) - { - // - bool isSLRemoved = RemoveSLTrail(ticket); - bool isTPRemoved = RemoveTPTrail(ticket); - - // - bool result = isSLRemoved || isTPRemoved; - - // - return result; - } - bool RemoveSLTrail(ulong ticket) - { - // - bool result = false; - - // - int idx = FindSLTrailIndex(ticket); - result = idx >= 0; - if (!result) - { - return result; - } - - // - result = ArrayRemove( - mSLTrails, - idx, - 1 // - ); - - // - return result; - } - bool RemoveTPTrail(ulong ticket) - { - // - bool result = false; - - // - int idx = FindTPTrailIndex(ticket); - result = idx >= 0; - if (!result) - { - return result; - } - - // - result = ArrayRemove( - mTPTrails, - idx, - 1 // - ); - - // - return result; - } - - // - int FindSLTrailIndex(ulong ticket) - { - // - int result = -1; - - // - int trailsCount = CountSLTrails(); - if (ticket <= 0 || trailsCount <= 0) - { - return result; - } - - // - for (int i = 0; i < trailsCount; i++) - { - // - XTrail iTrail = mSLTrails[i]; - - // - if (iTrail.ticket == ticket) - { - // - result = i; - break; - } - } - - // - return result; - } - int FindTPTrailIndex(ulong ticket) - { - // - int result = -1; - - // - int trailsCount = CountTPTrails(); - if (ticket <= 0 || trailsCount <= 0) - { - return result; - } - - // - for (int i = 0; i < trailsCount; i++) - { - // - XTrail iTrail = mTPTrails[i]; - - // - if (iTrail.ticket == ticket) - { - // - result = i; - break; - } - } - - // - return result; - } - - // - bool GetSLTrail( - ulong ticket, - XTrail &trail // - ) - { - // - bool result = false; - - // - int idx = FindSLTrailIndex(ticket); - result = idx >= 0; - if (!result) - { - return result; - } - - // - trail = mSLTrails[idx]; - - // - return result; - } - bool GetTPTrail( - ulong ticket, - XTrail &trail // - ) - { - // - bool result = false; - - // - int idx = FindTPTrailIndex(ticket); - result = idx >= 0; - if (!result) - { - return result; - } - - // - trail = mTPTrails[idx]; - - // - return result; - } - - // - void AddSLTrail( - XTrail &trail // - ) - { - // - if (!trail.IsValid()) - { - return; - } - - // - AddRef( - trail, - mSLTrails // - ); - } - void AddTPTrail( - XTrail &trail // - ) - { - // - if (!trail.IsValid()) - { - return; - } - - // - AddRef( - trail, - mTPTrails // - ); - } - - // - // Position Protector ... - XSCPositionProtector *mProtector; - - // -}; - -// -// Tools ... - -// \ No newline at end of file diff --git a/Classes/x-saherelm.x121.xmcycle.class.mq5 b/Classes/x-saherelm.x121.xmcycle.class.mq5 deleted file mode 100644 index c57bc5c5..00000000 --- a/Classes/x-saherelm.x121.xmcycle.class.mq5 +++ /dev/null @@ -1,5857 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Class Library -// ---------------------------------------------- -// Name: XSC121MCycle -// Description: provides all requirements for -// Handling Specified Market Cycle Analysis... -// -// -// 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 "../Libraries/x-saherelm.draw.lib.mq5" - -// -#include "../Helpers/x-saherelm.xtd.helper.mq5" -#include "../Helpers/x-saherelm.xhk.helper.mq5" -#include "../Helpers/x-saherelm.xmc.helper.mq5" -#include "../Helpers/x-saherelm.xpv.helper.mq5" -#include "../Helpers/x-saherelm.xzg.helper.mq5" -#include "../Helpers/x-saherelm.xmrb.helper.mq5" -#include "../Helpers/x-saherelm.xdon.helper.mq5" -#include "../Helpers/x-saherelm.xche.helper.mq5" -#include "../Helpers/x-saherelm.xosc.helper.mq5" -#include "../Helpers/x-saherelm.xstr.helper.mq5" -#include "../Helpers/x-saherelm.xich.helper.mq5" -#include "../Helpers/x-saherelm.xasct.helper.mq5" -#include "../Helpers/x-saherelm.xhull.helper.mq5" -#include "../Helpers/x-saherelm.xsslc.helper.mq5" - -// -#include "../Libraries/x-saherelm.xtrade.lib.mq5" -#include "../Classes/x-saherelm.xalert.class.mq5" - -// -// Definitions ... - -// -// Signallers ... -enum ENUM_XSIGNAL_PROVIDERS -{ - // - PROVIDER_NONE, - XSP, - XTEST, - X786, - X121, - X110, - X92, - X128, -}; - -// -void GetAllXSignalProviders(ENUM_XSIGNAL_PROVIDERS &result[]) -{ - // - Clean(result); - - // - Add(XSP, result); - Add(XTEST, result); - Add(X786, result); - Add(X121, result); - Add(X110, result); - Add(X92, result); - Add(X128, result); -} - -// -string ToString(ENUM_XSIGNAL_PROVIDERS value) -{ - return EnumToString(value); -} - -// -ENUM_XSIGNAL_PROVIDERS ToXSignalProvider(string content) -{ - // - ENUM_XSIGNAL_PROVIDERS result = PROVIDER_NONE; - - // - if (!IsValid(content)) - { - return result; - } - - // - if (content == ToString(PROVIDER_NONE)) - { - result = PROVIDER_NONE; - } - else if (content == ToString(XSP)) - { - result = XSP; - } - else if (content == ToString(XTEST)) - { - result = XTEST; - } - else if (content == ToString(X786)) - { - result = X786; - } - else if (content == ToString(X121)) - { - result = X121; - } - else if (content == ToString(X110)) - { - result = X110; - } - else if (content == ToString(X92)) - { - result = X92; - } - else if (content == ToString(X128)) - { - result = X128; - } - - // - return result; -} - -// -// X121 Specified Market Cycle Structure ... -class X121MCycleInputs : public XSCBase -{ - // - // Public ... -public: - // - // Props ... - - // - XMarketCycle cycle; // Cycle Descriptor ... - - // - // Draw Props ... - - // - XDrawSpecifications cBarMidDrawSpecs; // Current Bar MidLine Draw Specifications - XOHCLDrawSpecification cBarDrawSpecs; // Current Bar Draw Specifications - - // - XDrawSpecifications pBarMidDrawSpecs; // Previous Bar MidLine Draw Specifications - XOHCLDrawSpecification pBarDrawSpecs; // Previous Bar Draw Specifications - - // - bool drawLabels; // Draw Labels - bool drawCBar; // Draw Current Bar - bool drawPBar; // Draw Previous Bar - bool drawCBarMid; // Draw Current Bar Mid Line - bool drawPBarMid; // Draw Previous Bar Mid Line - - // - XHKInputs hkInputs; // HK Inputs ... - XMCInputs mcInputs; // MC Inputs ... - XPVInputs pvInputs; // PV Inputs ... - XZGInputs zgInputs; // ZG Inputs ... - XTDInputs tdInputs; // TD Inputs ... - XMRBInputs mrbInputs; // MRB Inputs ... - XSTRInputs strInputs; // STR Inputs ... - XOSCInputs oscInputs; // OSC Inputs ... - XCHEInputs cheInputs; // CHE Inputs ... - XICHInputs ichInputs; // ICH Inputs ... - XDONInputs donInputs; // DON Inputs ... - XASCTInputs asctInputs; // ASCT Inputs ... - XHULLInputs hullInputs; // HULL Inputs ... - XSSLCInputs sslcInputs; // SSLC Inputs ... - - // - // Constructor ... - - // - // Tools ... - - // - // Initialize Market Cycle ... - bool Init( - string mSymbol, // Trading Symbol - ENUM_TIMEFRAMES mHostPeriod, // Host Period - ENUM_X_MARKET_CYCLES mCycle, // Init Cycle - ENUM_TIMEFRAMES mPeriod, // Cycle Period - ENUM_X_PERIOD_METHOD mPeriodMethod, // Cycle Period Method - string mPrefix = "", // Prefix - bool useDefaults = true // Use Inputs Default Settings ... - ) - { - // - bool result = false; - - // - cycle.period = mPeriod; - cycle.method = mPeriodMethod; - - // - // Initial Cycle Model ... - result = cycle.Init( - mSymbol, - mHostPeriod, - mCycle, - mPrefix - // - ); - if (!result) - { - return result; - } - - // - if (useDefaults) - { - // - hkInputs.Default(); - mcInputs.Default(); - pvInputs.Default(); - zgInputs.Default(); - mrbInputs.Default(); - strInputs.Default(); - oscInputs.Default(); - cheInputs.Default(); - ichInputs.Default(); - donInputs.Default(); - hullInputs.Default(); - sslcInputs.Default(); - } - - // - result = IsValid(); - if (!result) - { - return result; - } - - // - return result; - } - - // - // Initialize Market Cycle ... - bool Init( - string mSymbol, // Trading Symbol - ENUM_TIMEFRAMES mHostPeriod, // Host Period - ENUM_X_MARKET_CYCLES mCycle, // Init Cycle - XHKInputs &mHkInputs, // HK Inputs - XMCInputs &mMcInputs, // MC Inputs - XPVInputs &mPvInputs, // PV Inputs ... - XZGInputs &mZgInputs, // ZG Inputs ... - XTDInputs &mTdInputs, // TD Inputs ... - XMRBInputs &mMrbInputs, // MRB Inputs ... - XSTRInputs &mStrInputs, // STR Inputs - XOSCInputs &mOscInputs, // OSC Inputs - XCHEInputs &mCheInputs, // CHE Inputs - XICHInputs &mIchInputs, // ICH Inputs ... - XDONInputs &mDonInputs, // DON Inputs ... - XASCTInputs &mAsctInputs, // ASCT Inputs - XHULLInputs &mHullInputs, // HULL Inputs ... - XSSLCInputs &mSslcInputs, // SSLC Inputs ... - int mHostBarIndex = 0, // Specified Host Period Bar Index - string mPrefix = "" // Prefix - ) - { - // - bool result = false; - - // - // Initial Cycle Model ... - result = cycle.Init( - mSymbol, - mHostPeriod, - mCycle, - mPrefix - // - ); - if (!result) - { - return result; - } - - // - hkInputs = mHkInputs; - mcInputs = mMcInputs; - pvInputs = mPvInputs; - zgInputs = mZgInputs; - tdInputs = mTdInputs; - mrbInputs = mMrbInputs; - strInputs = mStrInputs; - oscInputs = mOscInputs; - cheInputs = mCheInputs; - ichInputs = mIchInputs; - donInputs = mDonInputs; - asctInputs = mAsctInputs; - hullInputs = mHullInputs; - sslcInputs = mSslcInputs; - - // - result = IsValid(); - if (!result) - { - return result; - } - - // - return result; - } - - // - // Cleanup ... - virtual void Clean() - { - // - cycle.Clean(); - - // - hkInputs.Clean(); - mcInputs.Clean(); - pvInputs.Clean(); - zgInputs.Clean(); - tdInputs.Clean(); - mrbInputs.Clean(); - strInputs.Clean(); - oscInputs.Clean(); - cheInputs.Clean(); - ichInputs.Clean(); - donInputs.Clean(); - asctInputs.Clean(); - hullInputs.Clean(); - sslcInputs.Clean(); - - // - cBarDrawSpecs.Clean(); - pBarDrawSpecs.Clean(); - cBarMidDrawSpecs.Clean(); - pBarMidDrawSpecs.Clean(); - - // - drawLabels = false; - drawCBar = false; - drawPBar = false; - drawCBarMid = false; - drawPBarMid = false; - } - - // - // Default ... - virtual void Default() - { - // - hkInputs.Default(); - mcInputs.Default(); - pvInputs.Default(); - zgInputs.Default(); - tdInputs.Default(); - mrbInputs.Default(); - strInputs.Default(); - oscInputs.Default(); - cheInputs.Default(); - ichInputs.Default(); - donInputs.Default(); - asctInputs.Default(); - hullInputs.Default(); - sslcInputs.Default(); - - // - drawLabels = false; - drawCBar = false; - drawPBar = false; - drawCBarMid = false; - drawPBarMid = false; - } - - // - // Validation ... - virtual bool IsValid() - { - // - bool result = false; - - // - result = cycle.IsValid(); - if (!result) - { - return result; - } - - // - result = hkInputs.IsValid(); - if (!result) - { - return result; - } - - // - result = mcInputs.IsValid(); - if (!result) - { - return result; - } - - // - result = pvInputs.IsValid(); - if (!result) - { - return result; - } - - // - result = zgInputs.IsValid(); - if (!result) - { - return result; - } - - // - result = tdInputs.IsValid(); - if (!result) - { - return result; - } - - // - result = mrbInputs.IsValid(); - if (!result) - { - return result; - } - - // - result = strInputs.IsValid(); - if (!result) - { - return result; - } - - // - result = oscInputs.IsValid(); - if (!result) - { - return result; - } - - // - result = cheInputs.IsValid(); - if (!result) - { - return result; - } - - // - result = ichInputs.IsValid(); - if (!result) - { - return result; - } - - // - result = donInputs.IsValid(); - if (!result) - { - return result; - } - - // - result = hullInputs.IsValid(); - if (!result) - { - return result; - } - - // - result = asctInputs.IsValid(); - if (!result) - { - return result; - } - - // - result = sslcInputs.IsValid(); - if (!result) - { - return result; - } - - // - return result; - } - - // - // Max ... - virtual int Max() - { - // - int result = 0; - - // - result = MathMax(mcInputs.Max(), strInputs.Max()); - - // - result = MathMax(result, hkInputs.Max()); - result = MathMax(result, mcInputs.Max()); - result = MathMax(result, pvInputs.Max()); - result = MathMax(result, zgInputs.Max()); - result = MathMax(result, tdInputs.Max()); - result = MathMax(result, mrbInputs.Max()); - result = MathMax(result, strInputs.Max()); - result = MathMax(result, oscInputs.Max()); - result = MathMax(result, cheInputs.Max()); - result = MathMax(result, ichInputs.Max()); - result = MathMax(result, donInputs.Max()); - result = MathMax(result, asctInputs.Max()); - result = MathMax(result, hullInputs.Max()); - result = MathMax(result, sslcInputs.Max()); - - // - return result; - } -}; - -// -// Specific Market Sense Based on Specified Bar Index on Host Period ... -class X121MCycleConditions : public XSCBase -{ - // - // Public ... -public: - // - // Props ... - datetime time; // Time - string symbol; // Symbol - ENUM_TIMEFRAMES period; // Period - - // - string prefix; // Cycle Prefix - ENUM_X_MARKET_CYCLES cycle; // Init Cycle - ENUM_TIMEFRAMES hostPeriod; // Hosting Time Frame - - // - XOHCL bars[]; // Number of Bars - - // - // Candlestic Conditions ... - bool isLastBullish; - bool isLastBearish; - bool isCurrentBullish; - bool isCurrentBearish; - bool isCurrentMidLineOverLastHigh; - bool isCurrentMidLineUnderLastLow; - bool isCurrentMidLineOverLastUp; - bool isCurrentMidLineUnderLastDown; - bool isCurrentMidLineOverLastMidLine; - bool isCurrentMidLineUnderLastMidLine; - - // - // Buffers ... - - // - XOHCL hkBars[]; - XOHCL smHKBars[]; - - // - // XASCT ... - double asctLongs[]; - double asctShorts[]; - - // - // XICH ... - double ichTenkanSens[]; - double ichKijunSens[]; - double ichChikouSpans[]; - double ichSenkouSpanAs[]; - double ichSenkouSpanBs[]; - double ichFutureSenkouSpanAs[]; - double ichFutureSenkouSpanBs[]; - - // - // XMC ... - double mcFasts[]; - double mcSlows[]; - double mcVerifiers[]; - - // - // XSTR ... - double strTrends[]; - double strStates[]; - - // - // XZG ... - double zigzags[]; - double zigzagPVs[]; - - // - // XHULL ... - double hullUps[]; - double hullDowns[]; - - // - // XSSLC ... - double sslcUps[]; - double sslcDowns[]; - - // - // XMRB ... - - // - double mrbFasts[]; - double mrb1Fasts[]; - double mrb2Fasts[]; - double mrb3Fasts[]; - double mrb4Fasts[]; - double mrb5Fasts[]; - double mrb6Fasts[]; - - // - double mrbSlows[]; - double mrb1Slows[]; - double mrb2Slows[]; - double mrb3Slows[]; - double mrb4Slows[]; - double mrb5Slows[]; - double mrb6Slows[]; - - // - // XCHE ... - double cheLongExit1s[]; - double cheLongExit2s[]; - double cheShortExit1s[]; - double cheShortExit2s[]; - - // - // XDON ... - double donUpperOs[]; - double donLowerOs[]; - double donUpperCs[]; - double donLowerCs[]; - double donUpperHs[]; - double donLowerHs[]; - double donUpperLs[]; - double donLowerLs[]; - - // - // XPV ... - double pvPeaks[]; - double pvVales[]; - double pvResistances[]; - double pvSupports[]; - double pvFib1s[]; - double pvFib2s[]; - double pvFib3s[]; - double pvFib4s[]; - double pvFib5s[]; - double pvSCHHs[]; - double pvSCLLs[]; - double pvMCHHs[]; - double pvMCLLs[]; - double pvLCHHs[]; - double pvLCLLs[]; - double pvHCHHs[]; - double pvHCLLs[]; - - // - // XOSC ... - double oscAtrs[]; - double oscRviMains[]; - double oscRviSignals[]; - double oscBullPs[]; - double oscBearPs[]; - double oscVolumes[]; - double oscRsis[]; - double oscCcis[]; - double oscMomentums[]; - double oscSars[]; - double oscMacdMains[]; - double oscMacdSignals[]; - double oscStochMains[]; - double oscStochSignals[]; - double oscStddevs[]; - - // - // XTD ... - double tdBullishs[]; - double tdBearishs[]; - double tdSignals[]; - - // - // General Conditions ... - - // - // XZG ... - bool isZigZagInPeak; - bool isZigZagInVale; - - // - // XASCT ... - bool isASCTLong; - bool isASCTShort; - - // - // XHULL ... - bool isHullBullish; - bool isHullBearish; - bool isHullUpBullish; - bool isHullUpBearish; - bool isHullDownBullish; - bool isHullDownBearish; - bool isHullSwitchedToBullish; - bool isHullSwitchedToBearish; - - // - // XSSLC ... - bool isSSLCBullish; - bool isSSLCBearish; - bool isSSLCSwitchedToBullish; - bool isSSLCSwitchedToBearish; - - // - // XPV ... - - // - bool isNewPeak; - bool isNewPeakOverLast; - bool isNewPeakUnderLast; - - // - bool isNewVale; - bool isNewValeOverLast; - bool isNewValeUnderLast; - - // - bool isFiboIncreased; - bool isFiboDecreased; - bool isFiboSectionChanged; - - // - // SC ... - - // - bool isSCBullish; - bool isSCHHBullish; - bool isSCLLBullish; - bool isSCSwitchedToBullish; - bool isSCHHSwitchedToBullish; - bool isSCLLSwitchedToBullish; - - // - bool isSCBearish; - bool isSCHHBearish; - bool isSCLLBearish; - bool isSCSwitchedToBearish; - bool isSCHHSwitchedToBearish; - bool isSCLLSwitchedToBeraish; - - // - // MC ... - - // - bool isMCBullish; - bool isMCHHBullish; - bool isMCLLBullish; - bool isMCSwitchedToBullish; - bool isMCHHSwitchedToBullish; - bool isMCLLSwitchedToBullish; - - // - bool isMCBearish; - bool isMCHHBearish; - bool isMCLLBearish; - bool isMCSwitchedToBearish; - bool isMCHHSwitchedToBearish; - bool isMCLLSwitchedToBeraish; - - // - // LC ... - - // - bool isLCBullish; - bool isLCHHBullish; - bool isLCLLBullish; - bool isLCSwitchedToBullish; - bool isLCHHSwitchedToBullish; - bool isLCLLSwitchedToBullish; - // - bool isLCBearish; - bool isLCHHBearish; - bool isLCLLBearish; - bool isLCSwitchedToBearish; - bool isLCHHSwitchedToBearish; - bool isLCLLSwitchedToBeraish; - - // - // HC ... - - // - bool isHCBullish; - bool isHCHHBullish; - bool isHCLLBullish; - bool isHCSwitchedToBullish; - bool isHCHHSwitchedToBullish; - bool isHCLLSwitchedToBullish; - - // - bool isHCBearish; - bool isHCHHBearish; - bool isHCLLBearish; - bool isHCSwitchedToBearish; - bool isHCHHSwitchedToBearish; - bool isHCLLSwitchedToBeraish; - - // - // XHK ... - - // - bool isHKBullish; - bool isHKBearish; - bool isClosedOverHK; - bool isClosedUnderHK; - bool isHKSwitchedToBullish; - bool isHKSwitchedToBearish; - - // - bool isSMHKBullish; - bool isSMHKBearish; - bool isClosedOverSMHK; - bool isClosedUnderSMHK; - bool isSMHKSwitchedToBullish; - bool isSMHKSwitchedToBearish; - - // - // XSTR ... - bool isTrendBullish; - bool isTrendBearish; - bool isTrendSwitchedToBullish; - bool isTrendSwitchedToBearish; - - // - // XTD ... - bool isTDBullish; - bool isTDBearish; - bool isTDSwitchedToBullish; - bool isTDSwitchedToBearish; - - // - // XCHE ... - bool isCHEBullish; - bool isCHEBearish; - bool isCHESwitchedToBullish; - bool isCHESwitchedToBearish; - - // - // XMC ... - bool isMCFastOverSlow; - bool isMCFastUnderSlow; - bool isMCFastOverVerifier; - bool isMCFastUnderVerifier; - bool isMCSlowOverVerifier; - bool isMCSlowUnderVerifier; - bool isMCFastCrossedOverSlow; - bool isMCFastCrossedUnderSlow; - bool isMCFastCrossedOverVerifier; - bool isMCFastCrossedUnderVerifier; - bool isMCSlowCrossedOverVerifier; - bool isMCSlowCrossedUnderVerifier; - - // - // XMRB ... - bool isMRBFastOverSlow; - bool isMRBFastUnderSlow; - bool isMRBFastCrossedOverSlow; - bool isMRBFastCrossedUnderSlow; - bool isMRBFastOverVerifier; - bool isMRBFastUnderVerifier; - bool isMRBFastCrossedtOverVerifier; - bool isMRBFastCrossedUnderVerifier; - bool isMRBSlowOverVerifier; - bool isMRBSlowUnderVerifier; - bool isMRBSlowCrossedtOverVerifier; - bool isMRBSlowCrossedUnderVerifier; - - // - // XDON ... - - // - bool isDONAttachedMaxLower; - bool isDONAttachedMinLower; - bool isDONCrossedOverMaxLower; - bool isDONCrossedUnderMaxLower; - bool isDONCrossedOverMinLower; - bool isDONCrossedUnderMinLower; - - // - bool isDONAttachedMaxUpper; - bool isDONAttachedMinUpper; - bool isDONCrossedOverMaxUpper; - bool isDONCrossedUnderMaxUpper; - bool isDONCrossedOverMinUpper; - bool isDONCrossedUnderMinUpper; - - // - // XICH ... - - // - bool isClosedOverKijunSen; - bool isClosedUnderKijunSen; - bool isTenkanSenOverKijunSen; - bool isTenkanSenUnderKijunSen; - bool isTenkanSenCrossedOverKijunSen; - bool isTenkanSenCrossedUnderKijunSen; - - // - bool isSenkouSpanAOverB; - bool isSenkouSpanAUnderB; - bool isSenkouSpanAOverLast; - bool isSenkouSpanAUnderLast; - bool isFutureSenkouSpanAOverB; - bool isFutureSenkouSpanAUnderB; - bool isFutureSenkouSpanAOverLast; - bool isFutureSenkouSpanAUnderLast; - - // - bool isSenkouSpanACrossedOverB; - bool isSenkouSpanACrossedUnderB; - bool isSenkouSpanACrossedOverLast; - bool isSenkouSpanACrossedUnderLast; - bool isFutureSenkouSpanACrossedOverB; - bool isFutureSenkouSpanACrossedUnderB; - bool isFutureSenkouSpanACrossedOverLast; - bool isFutureSenkouSpanACrossedUnderLast; - - // - // XOSC ... - - // - // SAR ... - // ATR ... - // RVI ... - // RSI ... - // CCI ... - // MACD ... - // STOCH ... - // BULLP ... - // BEARP ... - // STDDEV ... - // VOLUME ... - // MOMENTUM ... - - // - // Tools ... - - // - void Clear() - { - // - // Commons ... - time = 0; - cycle = NULL; - prefix = NULL; - symbol = NULL; - period = NULL; - hostPeriod = NULL; - - // - Clean(bars); - - // - // Candlestic ... - isLastBullish = false; - isLastBearish = false; - isCurrentBullish = false; - isCurrentBearish = false; - isCurrentMidLineOverLastHigh = false; - isCurrentMidLineUnderLastLow = false; - isCurrentMidLineOverLastUp = false; - isCurrentMidLineUnderLastDown = false; - isCurrentMidLineOverLastMidLine = false; - isCurrentMidLineUnderLastMidLine = false; - - // - // Buffers ... - Clean(bars); - Clean(asctLongs); - Clean(asctShorts); - Clean(hkBars); - Clean(smHKBars); - Clean(ichTenkanSens); - Clean(ichKijunSens); - Clean(ichChikouSpans); - Clean(ichSenkouSpanAs); - Clean(ichSenkouSpanBs); - Clean(ichFutureSenkouSpanAs); - Clean(ichFutureSenkouSpanBs); - Clean(mcFasts); - Clean(mcSlows); - Clean(mcVerifiers); - Clean(strTrends); - Clean(strStates); - Clean(cheLongExit1s); - Clean(cheLongExit2s); - Clean(cheShortExit1s); - Clean(cheShortExit2s); - Clean(oscAtrs); - Clean(oscRviMains); - Clean(oscRviSignals); - Clean(oscBullPs); - Clean(oscBearPs); - Clean(oscVolumes); - Clean(oscRsis); - Clean(oscCcis); - Clean(oscMomentums); - Clean(oscSars); - Clean(oscMacdMains); - Clean(oscMacdSignals); - Clean(oscStochMains); - Clean(oscStochSignals); - Clean(oscStddevs); - Clean(zigzags); - Clean(zigzagPVs); - Clean(mrbFasts); - Clean(mrb1Fasts); - Clean(mrb2Fasts); - Clean(mrb3Fasts); - Clean(mrb4Fasts); - Clean(mrb5Fasts); - Clean(mrb6Fasts); - Clean(mrbSlows); - Clean(mrb1Slows); - Clean(mrb2Slows); - Clean(mrb3Slows); - Clean(mrb4Slows); - Clean(mrb5Slows); - Clean(mrb6Slows); - Clean(donUpperOs); - Clean(donLowerOs); - Clean(donUpperCs); - Clean(donLowerCs); - Clean(donUpperHs); - Clean(donLowerHs); - Clean(donUpperLs); - Clean(donLowerLs); - Clean(pvPeaks); - Clean(pvVales); - Clean(pvResistances); - Clean(pvSupports); - Clean(pvFib1s); - Clean(pvFib2s); - Clean(pvFib3s); - Clean(pvFib4s); - Clean(pvFib5s); - Clean(pvSCHHs); - Clean(pvSCLLs); - Clean(pvMCHHs); - Clean(pvMCLLs); - Clean(pvLCHHs); - Clean(pvLCLLs); - Clean(pvHCHHs); - Clean(pvHCLLs); - Clean(tdBullishs); - Clean(tdBearishs); - Clean(tdSignals); - Clean(hullUps); - Clean(hullDowns); - Clean(sslcUps); - Clean(sslcDowns); - - // - // Buffers ... - ArraySetAsSeries(bars, true); - ArraySetAsSeries(hkBars, true); - ArraySetAsSeries(asctLongs, true); - ArraySetAsSeries(asctShorts, true); - ArraySetAsSeries(smHKBars, true); - ArraySetAsSeries(ichTenkanSens, true); - ArraySetAsSeries(ichKijunSens, true); - ArraySetAsSeries(ichChikouSpans, true); - ArraySetAsSeries(ichSenkouSpanAs, true); - ArraySetAsSeries(ichSenkouSpanBs, true); - ArraySetAsSeries(ichFutureSenkouSpanAs, true); - ArraySetAsSeries(ichFutureSenkouSpanBs, true); - ArraySetAsSeries(mcFasts, true); - ArraySetAsSeries(mcSlows, true); - ArraySetAsSeries(mcVerifiers, true); - ArraySetAsSeries(strTrends, true); - ArraySetAsSeries(strStates, true); - ArraySetAsSeries(cheLongExit1s, true); - ArraySetAsSeries(cheLongExit2s, true); - ArraySetAsSeries(cheShortExit1s, true); - ArraySetAsSeries(cheShortExit2s, true); - ArraySetAsSeries(oscAtrs, true); - ArraySetAsSeries(oscRviMains, true); - ArraySetAsSeries(oscRviSignals, true); - ArraySetAsSeries(oscBullPs, true); - ArraySetAsSeries(oscBearPs, true); - ArraySetAsSeries(oscVolumes, true); - ArraySetAsSeries(oscRsis, true); - ArraySetAsSeries(oscCcis, true); - ArraySetAsSeries(oscMomentums, true); - ArraySetAsSeries(oscSars, true); - ArraySetAsSeries(oscMacdMains, true); - ArraySetAsSeries(oscMacdSignals, true); - ArraySetAsSeries(oscStochMains, true); - ArraySetAsSeries(oscStochSignals, true); - ArraySetAsSeries(oscStddevs, true); - ArraySetAsSeries(zigzags, true); - ArraySetAsSeries(zigzagPVs, true); - ArraySetAsSeries(mrbFasts, true); - ArraySetAsSeries(mrb1Fasts, true); - ArraySetAsSeries(mrb2Fasts, true); - ArraySetAsSeries(mrb3Fasts, true); - ArraySetAsSeries(mrb4Fasts, true); - ArraySetAsSeries(mrb5Fasts, true); - ArraySetAsSeries(mrb6Fasts, true); - ArraySetAsSeries(mrbSlows, true); - ArraySetAsSeries(mrb1Slows, true); - ArraySetAsSeries(mrb2Slows, true); - ArraySetAsSeries(mrb3Slows, true); - ArraySetAsSeries(mrb4Slows, true); - ArraySetAsSeries(mrb5Slows, true); - ArraySetAsSeries(mrb6Slows, true); - ArraySetAsSeries(donUpperOs, true); - ArraySetAsSeries(donLowerOs, true); - ArraySetAsSeries(donUpperCs, true); - ArraySetAsSeries(donLowerCs, true); - ArraySetAsSeries(donUpperHs, true); - ArraySetAsSeries(donLowerHs, true); - ArraySetAsSeries(donUpperLs, true); - ArraySetAsSeries(donLowerLs, true); - ArraySetAsSeries(pvPeaks, true); - ArraySetAsSeries(pvVales, true); - ArraySetAsSeries(pvResistances, true); - ArraySetAsSeries(pvSupports, true); - ArraySetAsSeries(pvFib1s, true); - ArraySetAsSeries(pvFib2s, true); - ArraySetAsSeries(pvFib3s, true); - ArraySetAsSeries(pvFib4s, true); - ArraySetAsSeries(pvFib5s, true); - ArraySetAsSeries(pvSCHHs, true); - ArraySetAsSeries(pvSCLLs, true); - ArraySetAsSeries(pvMCHHs, true); - ArraySetAsSeries(pvMCLLs, true); - ArraySetAsSeries(pvLCHHs, true); - ArraySetAsSeries(pvLCLLs, true); - ArraySetAsSeries(pvHCHHs, true); - ArraySetAsSeries(pvHCLLs, true); - ArraySetAsSeries(tdBullishs, true); - ArraySetAsSeries(tdBearishs, true); - ArraySetAsSeries(tdSignals, true); - ArraySetAsSeries(hullUps, true); - ArraySetAsSeries(hullDowns, true); - ArraySetAsSeries(sslcUps, true); - ArraySetAsSeries(sslcDowns, true); - - // - // XZG ... - isZigZagInPeak = false; - isZigZagInVale = false; - - // - // XASCT ... - isASCTLong = false; - isASCTShort = false; - - // - // XHULL ... - isHullBullish = false; - isHullBearish = false; - isHullUpBullish = false; - isHullUpBearish = false; - isHullDownBullish = false; - isHullDownBearish = false; - isHullSwitchedToBullish = false; - isHullSwitchedToBearish = false; - - // - // XSSLC ... - isSSLCBullish = false; - isSSLCBearish = false; - isSSLCSwitchedToBullish = false; - isSSLCSwitchedToBearish = false; - - // - // XPV ... - - // - isNewPeak = false; - isNewPeakOverLast = false; - isNewPeakUnderLast = false; - - // - isNewVale = false; - isNewValeOverLast = false; - isNewValeUnderLast = false; - - // - isFiboIncreased = false; - isFiboDecreased = false; - isFiboSectionChanged = false; - - // - // SC ... - - // - isSCBullish = false; - isSCHHBullish = false; - isSCLLBullish = false; - isSCSwitchedToBullish = false; - isSCHHSwitchedToBullish = false; - isSCLLSwitchedToBullish = false; - - // - isSCBearish = false; - isSCHHBearish = false; - isSCLLBearish = false; - isSCSwitchedToBearish = false; - isSCHHSwitchedToBearish = false; - isSCLLSwitchedToBeraish = false; - - // - // MC ... - - // - isMCBullish = false; - isMCHHBullish = false; - isMCLLBullish = false; - isMCSwitchedToBullish = false; - isMCHHSwitchedToBullish = false; - isMCLLSwitchedToBullish = false; - - // - isMCBearish = false; - isMCHHBearish = false; - isMCLLBearish = false; - isMCSwitchedToBearish = false; - isMCHHSwitchedToBearish = false; - isMCLLSwitchedToBeraish = false; - - // - // LC ... - - // - isLCBullish = false; - isLCHHBullish = false; - isLCLLBullish = false; - isLCSwitchedToBullish = false; - isLCHHSwitchedToBullish = false; - isLCLLSwitchedToBullish = false; - - // - isLCBearish = false; - isLCHHBearish = false; - isLCLLBearish = false; - isLCSwitchedToBearish = false; - isLCHHSwitchedToBearish = false; - isLCLLSwitchedToBeraish = false; - - // - // HC ... - - // - isHCBullish = false; - isHCHHBullish = false; - isHCLLBullish = false; - isHCSwitchedToBullish = false; - isHCHHSwitchedToBullish = false; - isHCLLSwitchedToBullish = false; - - // - isHCBearish = false; - isHCHHBearish = false; - isHCLLBearish = false; - isHCSwitchedToBearish = false; - isHCHHSwitchedToBearish = false; - isHCLLSwitchedToBeraish = false; - - // - // XHK ... - isHKBullish = false; - isHKBearish = false; - isClosedOverHK = false; - isClosedUnderHK = false; - isHKSwitchedToBullish = false; - isHKSwitchedToBearish = false; - - // - isSMHKBullish = false; - isSMHKBearish = false; - isClosedOverSMHK = false; - isClosedUnderSMHK = false; - isSMHKSwitchedToBullish = false; - isSMHKSwitchedToBearish = false; - - // - // XSTR ... - isTrendBullish = false; - isTrendBearish = false; - isTrendSwitchedToBullish = false; - isTrendSwitchedToBearish = false; - - // - // XTD ... - isTDBullish = false; - isTDBearish = false; - isTDSwitchedToBullish = false; - isTDSwitchedToBearish = false; - - // - // XCHE ... - isCHEBullish = false; - isCHEBearish = false; - isCHESwitchedToBullish = false; - isCHESwitchedToBearish = false; - - // - // XMC ... - isMCFastOverSlow = false; - isMCFastUnderSlow = false; - isMCFastOverVerifier = false; - isMCFastUnderVerifier = false; - isMCSlowOverVerifier = false; - isMCSlowUnderVerifier = false; - isMCFastCrossedOverSlow = false; - isMCFastCrossedUnderSlow = false; - isMCFastCrossedOverVerifier = false; - isMCFastCrossedUnderVerifier = false; - isMCSlowCrossedOverVerifier = false; - isMCSlowCrossedUnderVerifier = false; - - // - // XMRB ... - isMRBFastOverSlow = false; - isMRBFastUnderSlow = false; - isMRBFastCrossedOverSlow = false; - isMRBFastCrossedUnderSlow = false; - isMRBFastOverVerifier = false; - isMRBFastUnderVerifier = false; - isMRBFastCrossedtOverVerifier = false; - isMRBFastCrossedUnderVerifier = false; - isMRBSlowOverVerifier = false; - isMRBSlowUnderVerifier = false; - isMRBSlowCrossedtOverVerifier = false; - isMRBSlowCrossedUnderVerifier = false; - - // - // XDON ... - - // - isDONAttachedMaxLower = false; - isDONAttachedMinLower = false; - isDONCrossedOverMaxLower = false; - isDONCrossedUnderMaxLower = false; - isDONCrossedOverMinLower = false; - isDONCrossedUnderMinLower = false; - - // - isDONAttachedMaxUpper = false; - isDONAttachedMinUpper = false; - isDONCrossedOverMaxUpper = false; - isDONCrossedUnderMaxUpper = false; - isDONCrossedOverMinUpper = false; - isDONCrossedUnderMinUpper = false; - - // - // XICH ... - - // - isClosedOverKijunSen = false; - isClosedUnderKijunSen = false; - isTenkanSenOverKijunSen = false; - isTenkanSenUnderKijunSen = false; - isTenkanSenCrossedOverKijunSen = false; - isTenkanSenCrossedUnderKijunSen = false; - - // - isSenkouSpanAOverB = false; - isSenkouSpanAUnderB = false; - isSenkouSpanAOverLast = false; - isSenkouSpanAUnderLast = false; - isFutureSenkouSpanAOverB = false; - isFutureSenkouSpanAUnderB = false; - isFutureSenkouSpanAOverLast = false; - isFutureSenkouSpanAUnderLast = false; - - // - isSenkouSpanACrossedOverB = false; - isSenkouSpanACrossedUnderB = false; - isSenkouSpanACrossedOverLast = false; - isSenkouSpanACrossedUnderLast = false; - isFutureSenkouSpanACrossedOverB = false; - isFutureSenkouSpanACrossedUnderB = false; - isFutureSenkouSpanACrossedOverLast = false; - isFutureSenkouSpanACrossedUnderLast = false; - } - - // - // Generate Score ... - void GenerateScore( - double &bullishScore, // Holds Bullish Score ... - double &bearishScore, // Holds Bearish Score ... - double multiplier = 1 // Score Multiplier ... - ) - { - // - double bullScore = 0; - double bearScore = 0; - - // - if (multiplier <= 0) - { - multiplier = 1; - } - - // - // XASCT ... - if (isASCTLong) - { - // - bullScore++; - bullScore++; - bearScore--; - } - if (isASCTShort) - { - // - bullScore--; - bearScore++; - bearScore++; - } - - // - // Candlestic ... - if (isLastBullish) - { - bullScore++; - } - if (isLastBearish) - { - bearScore++; - } - if (isCurrentBullish) - { - bullScore++; - } - if (isCurrentBearish) - { - bearScore++; - } - if (isCurrentMidLineOverLastHigh) - { - bullScore++; - } - if (isCurrentMidLineUnderLastLow) - { - bearScore++; - } - if (isCurrentMidLineOverLastUp) - { - bullScore++; - } - if (isCurrentMidLineUnderLastDown) - { - bearScore++; - } - if (isCurrentMidLineOverLastMidLine) - { - bullScore++; - } - if (isCurrentMidLineUnderLastMidLine) - { - bearScore++; - } - - // - // XZG ... - if (isZigZagInPeak) - { - bullScore++; - } - if (isZigZagInVale) - { - bearScore++; - } - - // - // XHULL ... - if (isHullBullish) - { - bullScore++; - } - if (isHullBearish) - { - bearScore++; - } - if (isHullUpBullish) - { - bullScore++; - } - if (isHullUpBearish) - { - bearScore++; - } - if (isHullDownBullish) - { - bullScore++; - } - if (isHullDownBearish) - { - bearScore++; - } - if (isHullSwitchedToBullish) - { - bullScore++; - } - if (isHullSwitchedToBearish) - { - bearScore++; - } - - // - // XSSLC ... - if (isSSLCBullish) - { - bullScore++; - } - if (isSSLCBearish) - { - bearScore++; - } - if (isSSLCSwitchedToBullish) - { - bullScore++; - } - if (isSSLCSwitchedToBearish) - { - bearScore++; - } - - // - // XPV ... - - // - if (isNewPeak) - { - bearScore++; - } - if (isNewPeakOverLast) - { - } - if (isNewPeakUnderLast) - { - } - - // - if (isNewVale) - { - bullScore++; - } - if (isNewValeOverLast) - { - } - if (isNewValeUnderLast) - { - } - - // - if (isFiboIncreased) - { - bullScore++; - } - if (isFiboDecreased) - { - bearScore++; - } - if (isFiboSectionChanged) - { - } - - // - // SC ... - - // - if (isSCBullish) - { - bullScore++; - } - if (isSCHHBullish) - { - bullScore++; - } - if (isSCLLBullish) - { - bullScore++; - } - if (isSCSwitchedToBullish) - { - bullScore++; - } - if (isSCHHSwitchedToBullish) - { - bullScore++; - } - if (isSCLLSwitchedToBullish) - { - bullScore++; - } - - // - if (isSCBearish) - { - bearScore++; - } - if (isSCHHBearish) - { - bearScore++; - } - if (isSCLLBearish) - { - bearScore++; - } - if (isSCSwitchedToBearish) - { - bearScore++; - } - if (isSCHHSwitchedToBearish) - { - bearScore++; - } - if (isSCLLSwitchedToBeraish) - { - bearScore++; - } - - // - // MC ... - - // - if (isMCBullish) - { - bullScore++; - } - if (isMCHHBullish) - { - bullScore++; - } - if (isMCLLBullish) - { - bullScore++; - } - if (isMCSwitchedToBullish) - { - bullScore++; - } - if (isMCHHSwitchedToBullish) - { - bullScore++; - } - if (isMCLLSwitchedToBullish) - { - bullScore++; - } - - // - if (isMCBearish) - { - bearScore++; - } - if (isMCHHBearish) - { - bearScore++; - } - if (isMCLLBearish) - { - bearScore++; - } - if (isMCSwitchedToBearish) - { - bearScore++; - } - if (isMCHHSwitchedToBearish) - { - bearScore++; - } - if (isMCLLSwitchedToBeraish) - { - bearScore++; - } - - // - // LC ... - - // - if (isLCBullish) - { - bullScore++; - } - if (isLCHHBullish) - { - bullScore++; - } - if (isLCLLBullish) - { - bullScore++; - } - if (isLCSwitchedToBullish) - { - bullScore++; - } - if (isLCHHSwitchedToBullish) - { - bullScore++; - } - if (isLCLLSwitchedToBullish) - { - bullScore++; - } - - // - if (isLCBearish) - { - bearScore++; - } - if (isLCHHBearish) - { - bearScore++; - } - if (isLCLLBearish) - { - bearScore++; - } - if (isLCSwitchedToBearish) - { - bearScore++; - } - if (isLCHHSwitchedToBearish) - { - bearScore++; - } - if (isLCLLSwitchedToBeraish) - { - bearScore++; - } - - // - // HC ... - - // - if (isHCBullish) - { - bullScore++; - } - if (isHCHHBullish) - { - bullScore++; - } - if (isHCLLBullish) - { - bullScore++; - } - if (isHCSwitchedToBullish) - { - bullScore++; - } - if (isHCHHSwitchedToBullish) - { - bullScore++; - } - if (isHCLLSwitchedToBullish) - { - bullScore++; - } - - // - if (isHCBearish) - { - bearScore++; - } - if (isHCHHBearish) - { - bearScore++; - } - if (isHCLLBearish) - { - bearScore++; - } - if (isHCSwitchedToBearish) - { - bearScore++; - } - if (isHCHHSwitchedToBearish) - { - bearScore++; - } - if (isHCLLSwitchedToBeraish) - { - bearScore++; - } - - // - // XHK ... - - // - if (isHKBullish) - { - bullScore++; - } - if (isHKBearish) - { - bearScore++; - } - if (isClosedOverHK) - { - bullScore++; - } - if (isClosedUnderHK) - { - bearScore++; - } - if (isHKSwitchedToBullish) - { - bullScore++; - } - if (isHKSwitchedToBearish) - { - bearScore++; - } - - // - if (isSMHKBullish) - { - bullScore++; - } - if (isSMHKBearish) - { - bearScore++; - } - if (isClosedOverSMHK) - { - bullScore++; - } - if (isClosedUnderSMHK) - { - bearScore++; - } - if (isSMHKSwitchedToBullish) - { - bullScore++; - } - if (isSMHKSwitchedToBearish) - { - bearScore++; - } - - // - // XSTR ... - if (isTrendBullish) - { - bullScore++; - } - if (isTrendBearish) - { - bearScore++; - } - if (isTrendSwitchedToBullish) - { - bullScore++; - } - if (isTrendSwitchedToBearish) - { - bearScore++; - } - - // - // XTD ... - if (isTDBullish) - { - bullScore++; - } - if (isTDBearish) - { - bearScore++; - } - if (isTDSwitchedToBullish) - { - bullScore++; - } - if (isTDSwitchedToBearish) - { - bearScore++; - } - - // - // XCHE ... - if (isCHEBullish) - { - bullScore++; - } - if (isCHEBearish) - { - bearScore++; - } - if (isCHESwitchedToBullish) - { - bullScore++; - } - if (isCHESwitchedToBearish) - { - bearScore++; - } - - // - // XMC ... - if (isMCFastOverSlow) - { - bullScore++; - } - if (isMCFastUnderSlow) - { - bearScore++; - } - if (isMCFastOverVerifier) - { - bullScore++; - } - if (isMCFastUnderVerifier) - { - bearScore++; - } - if (isMCSlowOverVerifier) - { - bullScore++; - } - if (isMCSlowUnderVerifier) - { - bearScore++; - } - if (isMCFastCrossedOverSlow) - { - bullScore++; - } - if (isMCFastCrossedUnderSlow) - { - bearScore++; - } - if (isMCFastCrossedOverVerifier) - { - bullScore++; - } - if (isMCFastCrossedUnderVerifier) - { - bearScore++; - } - if (isMCSlowCrossedOverVerifier) - { - bullScore++; - } - if (isMCSlowCrossedUnderVerifier) - { - bearScore++; - } - - // - // XMRB ... - if (isMRBFastOverSlow) - { - bullScore++; - } - if (isMRBFastUnderSlow) - { - bearScore++; - } - if (isMRBFastCrossedOverSlow) - { - bullScore++; - } - if (isMRBFastCrossedUnderSlow) - { - bearScore++; - } - if (isMRBFastOverVerifier) - { - bullScore++; - } - if (isMRBFastUnderVerifier) - { - bearScore++; - } - if (isMRBFastCrossedtOverVerifier) - { - bullScore++; - } - if (isMRBFastCrossedUnderVerifier) - { - bearScore++; - } - if (isMRBSlowOverVerifier) - { - bullScore++; - } - if (isMRBSlowUnderVerifier) - { - bearScore++; - } - if (isMRBSlowCrossedtOverVerifier) - { - bullScore++; - } - if (isMRBSlowCrossedUnderVerifier) - { - bearScore++; - } - - // - // XDON ... - - // - if (isDONAttachedMaxLower) - { - bullScore++; - } - if (isDONAttachedMinLower) - { - bullScore++; - } - if (isDONCrossedOverMaxLower) - { - bullScore++; - } - if (isDONCrossedUnderMaxLower) - { - bullScore++; - } - if (isDONCrossedOverMinLower) - { - bullScore++; - } - if (isDONCrossedUnderMinLower) - { - bullScore++; - } - - // - if (isDONAttachedMaxUpper) - { - bearScore++; - } - if (isDONAttachedMinUpper) - { - bearScore++; - } - if (isDONCrossedOverMaxUpper) - { - bearScore++; - } - if (isDONCrossedUnderMaxUpper) - { - bearScore++; - } - if (isDONCrossedOverMinUpper) - { - bearScore++; - } - if (isDONCrossedUnderMinUpper) - { - bearScore++; - } - - // - // XICH ... - - // - if (isClosedOverKijunSen) - { - bullScore++; - } - if (isClosedUnderKijunSen) - { - bearScore++; - } - if (isTenkanSenOverKijunSen) - { - bullScore++; - } - if (isTenkanSenUnderKijunSen) - { - bearScore++; - } - if (isTenkanSenCrossedOverKijunSen) - { - bullScore++; - } - if (isTenkanSenCrossedUnderKijunSen) - { - bearScore++; - } - - // - if (isSenkouSpanAOverB) - { - bullScore++; - } - if (isSenkouSpanAUnderB) - { - bearScore++; - } - if (isSenkouSpanAOverLast) - { - bullScore++; - } - if (isSenkouSpanAUnderLast) - { - bearScore++; - } - if (isFutureSenkouSpanAOverB) - { - bullScore++; - } - if (isFutureSenkouSpanAUnderB) - { - bearScore++; - } - if (isFutureSenkouSpanAOverLast) - { - bullScore++; - } - if (isFutureSenkouSpanAUnderLast) - { - bearScore++; - } - - // - if (isSenkouSpanACrossedOverB) - { - bullScore++; - } - if (isSenkouSpanACrossedUnderB) - { - bearScore++; - } - if (isSenkouSpanACrossedOverLast) - { - bullScore++; - } - if (isSenkouSpanACrossedUnderLast) - { - bearScore++; - } - if (isFutureSenkouSpanACrossedOverB) - { - bullScore++; - } - if (isFutureSenkouSpanACrossedUnderB) - { - bearScore++; - } - if (isFutureSenkouSpanACrossedOverLast) - { - bullScore++; - } - if (isFutureSenkouSpanACrossedUnderLast) - { - bearScore++; - } - - // - bullishScore = bullScore * multiplier; - bearishScore = bearScore * multiplier; - } - - // - // Generate Summary ... - string GenerateSummary( - const bool onlySummary = false, // Only Generate Conditions Summary - double multiplier = 1, // Score Multiplier - const string separator = "\n", // Separator - const bool ignoreFalseConditions = true // Ignore False Conditions - ) - { - // - string result = NULL; - - // - result = GenerateSummaryBody( - onlySummary, - multiplier, - separator, - ignoreFalseConditions - // - ); - - // - // Generating Full Result by Combining parts ... - result = - // - GetTitle() + separator + - "-----------------------------" + separator + - result + - "" - // - ; - - // - return result; - } - - // - string GenerateSummaryBody( - const bool onlySummary = false, // Only Generate Conditions Summary - double multiplier = 1, // Score Multiplier - const string separator = "\n", // Separator - const bool ignoreFalseConditions = true // Ignore False Conditions - ) - { - // - string result = NULL; - - // - double bullScore = 0; - double bearScore = 0; - GenerateScore( - bullScore, - bearScore, - multiplier // - ); - - // - // Common ... - string commonStr = - // - (onlySummary ? "" : "Commons: " + separator) + - (onlySummary ? "" : "-----------------------------" + separator) + - "Time: " + ToString(TimeCurrent()) + separator + - "-----------" + separator + - "Scores: " + separator + - "-----------" + separator + - "Bullish: " + ToString(bullScore) + separator + - "Bearish: " + ToString(bearScore) + separator + - "-----------------------------" + separator + - // - // TODO: Add Scores Later ... - separator + - "" - // - ; - - // - // Candlestick ... - string candlestickStr = - // - ToString("isLastBullish", isLastBullish, ignoreFalseConditions, separator) + - ToString("isLastBearish", isLastBearish, ignoreFalseConditions, separator) + - ToString("isCurrentBullish", isCurrentBullish, ignoreFalseConditions, separator) + - ToString("isCurrentBearish", isCurrentBearish, ignoreFalseConditions, separator) + - ToString("isCurrentMidLineOverLastHigh", isCurrentMidLineOverLastHigh, ignoreFalseConditions, separator) + - ToString("isCurrentMidLineUnderLastLow", isCurrentMidLineUnderLastLow, ignoreFalseConditions, separator) + - ToString("isCurrentMidLineOverLastUp", isCurrentMidLineOverLastUp, ignoreFalseConditions, separator) + - ToString("isCurrentMidLineUnderLastDown", isCurrentMidLineUnderLastDown, ignoreFalseConditions, separator) + - ToString("isCurrentMidLineOverLastMidLine", isCurrentMidLineOverLastMidLine, ignoreFalseConditions, separator) + - ToString("isCurrentMidLineUnderLastMidLine", isCurrentMidLineUnderLastMidLine, ignoreFalseConditions, separator) + - "" - // - ; - candlestickStr = SetLabel("XOHCL: ", candlestickStr, separator); - - // - // XASCT ... - string asctStr = - // - ToString("isASCTLong", isASCTLong, ignoreFalseConditions, separator) + - ToString("isASCTShort", isASCTShort, ignoreFalseConditions, separator) + - - "" - // - ; - asctStr = SetLabel("XASCT: ", asctStr, separator); - - // - // XZG ... - string zgStr = - // - ToString("isZigZagInPeak", isZigZagInPeak, ignoreFalseConditions, separator) + - ToString("isZigZagInVale", isZigZagInVale, ignoreFalseConditions, separator) + - "" - // - ; - zgStr = SetLabel("XZG: ", zgStr, separator); - - // - // XSTR ... - string strStr = - // - ToString("isTrendBullish", isTrendBullish, ignoreFalseConditions, separator) + - ToString("isTrendBearish", isTrendBearish, ignoreFalseConditions, separator) + - ToString("isTrendSwitchedToBullish", isTrendSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isTrendSwitchedToBearish", isTrendSwitchedToBearish, ignoreFalseConditions, separator) + - "" - // - ; - strStr = SetLabel("XSTR: ", strStr, separator); - - // - // XCHE ... - string cheStr = - // - ToString("isCHEBullish", isCHEBullish, ignoreFalseConditions, separator) + - ToString("isCHEBearish", isCHEBearish, ignoreFalseConditions, separator) + - ToString("isCHESwitchedToBullish", isCHESwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isCHESwitchedToBearish", isCHESwitchedToBearish, ignoreFalseConditions, separator) + - "" - // - ; - cheStr = SetLabel("XCHE: ", cheStr, separator); - - // - // XTD ... - string tdStr = - // - ToString("isTDBullish", isTDBullish, ignoreFalseConditions, separator) + - ToString("isTDBearish", isTDBearish, ignoreFalseConditions, separator) + - ToString("isTDSwitchedToBullish", isTDSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isTDSwitchedToBearish", isTDSwitchedToBearish, ignoreFalseConditions, separator) + - "" - // - ; - tdStr = SetLabel("XTD: ", tdStr, separator); - - // - // XSSLC ... - string sslcStr = - // - ToString("isSSLCBullish", isSSLCBullish, ignoreFalseConditions, separator) + - ToString("isSSLCBearish", isSSLCBearish, ignoreFalseConditions, separator) + - ToString("isSSLCSwitchedToBullish", isSSLCSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isSSLCSwitchedToBearish", isSSLCSwitchedToBearish, ignoreFalseConditions, separator) + - "" - // - ; - sslcStr = SetLabel("XSSLC: ", sslcStr, separator); - - // - // XHULL ... - string hullStr = - // - ToString("isHullBullish", isHullBullish, ignoreFalseConditions, separator) + - ToString("isHullBearish", isHullBearish, ignoreFalseConditions, separator) + - ToString("isHullUpBullish", isHullUpBullish, ignoreFalseConditions, separator) + - ToString("isHullUpBearish", isHullUpBearish, ignoreFalseConditions, separator) + - ToString("isHullDownBullish", isHullDownBullish, ignoreFalseConditions, separator) + - ToString("isHullDownBearish", isHullDownBearish, ignoreFalseConditions, separator) + - ToString("isHullSwitchedToBullish", isHullSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isHullSwitchedToBearish", isHullSwitchedToBearish, ignoreFalseConditions, separator) + - "" - // - ; - hullStr = SetLabel("XHULL: ", hullStr, separator); - - // - // XHK ... - string hkStr = - // - ToString("isHKBullish", isHKBullish, ignoreFalseConditions, separator) + - ToString("isHKBearish", isHKBearish, ignoreFalseConditions, separator) + - ToString("isClosedOverHK", isClosedOverHK, ignoreFalseConditions, separator) + - ToString("isClosedUnderHK", isClosedUnderHK, ignoreFalseConditions, separator) + - ToString("isHKSwitchedToBullish", isHKSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isHKSwitchedToBearish", isHKSwitchedToBearish, ignoreFalseConditions, separator) + - ToString("isSMHKBullish", isSMHKBullish, ignoreFalseConditions, separator) + - ToString("isSMHKBearish", isSMHKBearish, ignoreFalseConditions, separator) + - ToString("isClosedOverSMHK", isClosedOverSMHK, ignoreFalseConditions, separator) + - ToString("isClosedUnderSMHK", isClosedUnderSMHK, ignoreFalseConditions, separator) + - ToString("isSMHKSwitchedToBullish", isSMHKSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isSMHKSwitchedToBearish", isSMHKSwitchedToBearish, ignoreFalseConditions, separator) + - "" - // - ; - hkStr = SetLabel("XHK: ", hkStr, separator); - - // - // XDON ... - string donStr = - // - ToString("isDONAttachedMaxLower", isDONAttachedMaxLower, ignoreFalseConditions, separator) + - ToString("isDONAttachedMinLower", isDONAttachedMinLower, ignoreFalseConditions, separator) + - ToString("isDONCrossedOverMaxLower", isDONCrossedOverMaxLower, ignoreFalseConditions, separator) + - ToString("isDONCrossedUnderMaxLower", isDONCrossedUnderMaxLower, ignoreFalseConditions, separator) + - ToString("isDONCrossedOverMinLower", isDONCrossedOverMinLower, ignoreFalseConditions, separator) + - ToString("isDONCrossedUnderMinLower", isDONCrossedUnderMinLower, ignoreFalseConditions, separator) + - ToString("isDONAttachedMaxUpper", isDONAttachedMaxUpper, ignoreFalseConditions, separator) + - ToString("isDONAttachedMinUpper", isDONAttachedMinUpper, ignoreFalseConditions, separator) + - ToString("isDONCrossedOverMaxUpper", isDONCrossedOverMaxUpper, ignoreFalseConditions, separator) + - ToString("isDONCrossedUnderMaxUpper", isDONCrossedUnderMaxUpper, ignoreFalseConditions, separator) + - ToString("isDONCrossedOverMinUpper", isDONCrossedOverMinUpper, ignoreFalseConditions, separator) + - ToString("isDONCrossedUnderMinUpper", isDONCrossedUnderMinUpper, ignoreFalseConditions, separator) + - "" - // - ; - donStr = SetLabel("XDON: ", donStr, separator); - - // - // XMC ... - string mcStr = - // - ToString("isMCFastOverSlow", isMCFastOverSlow, ignoreFalseConditions, separator) + - ToString("isMCFastUnderSlow", isMCFastUnderSlow, ignoreFalseConditions, separator) + - ToString("isMCFastOverVerifier", isMCFastOverVerifier, ignoreFalseConditions, separator) + - ToString("isMCFastUnderVerifier", isMCFastUnderVerifier, ignoreFalseConditions, separator) + - ToString("isMCSlowOverVerifier", isMCSlowOverVerifier, ignoreFalseConditions, separator) + - ToString("isMCSlowUnderVerifier", isMCSlowUnderVerifier, ignoreFalseConditions, separator) + - ToString("isMCFastCrossedOverSlow", isMCFastCrossedOverSlow, ignoreFalseConditions, separator) + - ToString("isMCFastCrossedUnderSlow", isMCFastCrossedUnderSlow, ignoreFalseConditions, separator) + - ToString("isMCFastCrossedOverVerifier", isMCFastCrossedOverVerifier, ignoreFalseConditions, separator) + - ToString("isMCFastCrossedUnderVerifier", isMCFastCrossedUnderVerifier, ignoreFalseConditions, separator) + - ToString("isMCSlowCrossedOverVerifier", isMCSlowCrossedOverVerifier, ignoreFalseConditions, separator) + - ToString("isMCSlowCrossedUnderVerifier", isMCSlowCrossedUnderVerifier, ignoreFalseConditions, separator) + - "" - // - ; - mcStr = SetLabel("XMC: ", mcStr, separator); - - // - // XMRB ... - string mrbStr = - // - ToString("isMRBFastOverSlow", isMRBFastOverSlow, ignoreFalseConditions, separator) + - ToString("isMRBFastUnderSlow", isMRBFastUnderSlow, ignoreFalseConditions, separator) + - ToString("isMRBFastCrossedOverSlow", isMRBFastCrossedOverSlow, ignoreFalseConditions, separator) + - ToString("isMRBFastCrossedUnderSlow", isMRBFastCrossedUnderSlow, ignoreFalseConditions, separator) + - ToString("isMRBFastOverVerifier", isMRBFastOverVerifier, ignoreFalseConditions, separator) + - ToString("isMRBFastUnderVerifier", isMRBFastUnderVerifier, ignoreFalseConditions, separator) + - ToString("isMRBFastCrossedtOverVerifier", isMRBFastCrossedtOverVerifier, ignoreFalseConditions, separator) + - ToString("isMRBFastCrossedUnderVerifier", isMRBFastCrossedUnderVerifier, ignoreFalseConditions, separator) + - ToString("isMRBSlowOverVerifier", isMRBSlowOverVerifier, ignoreFalseConditions, separator) + - ToString("isMRBSlowUnderVerifier", isMRBSlowUnderVerifier, ignoreFalseConditions, separator) + - ToString("isMRBSlowCrossedtOverVerifier", isMRBSlowCrossedtOverVerifier, ignoreFalseConditions, separator) + - ToString("isMRBSlowCrossedUnderVerifier", isMRBSlowCrossedUnderVerifier, ignoreFalseConditions, separator) + - "" - // - ; - mrbStr = SetLabel("XMRB: ", mrbStr, separator); - - // - // XICH ... - string ichStr = - // - ToString("isClosedOverKijunSen", isClosedOverKijunSen, ignoreFalseConditions, separator) + - ToString("isClosedUnderKijunSen", isClosedUnderKijunSen, ignoreFalseConditions, 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("isSenkouSpanAOverLast", isSenkouSpanAOverLast, ignoreFalseConditions, separator) + - ToString("isSenkouSpanAUnderLast", isSenkouSpanAUnderLast, ignoreFalseConditions, separator) + - ToString("isFutureSenkouSpanAOverB", isFutureSenkouSpanAOverB, ignoreFalseConditions, separator) + - ToString("isFutureSenkouSpanAUnderB", isFutureSenkouSpanAUnderB, ignoreFalseConditions, separator) + - ToString("isFutureSenkouSpanAOverLast", isFutureSenkouSpanAOverLast, ignoreFalseConditions, separator) + - ToString("isFutureSenkouSpanAUnderLast", isFutureSenkouSpanAUnderLast, ignoreFalseConditions, separator) + - ToString("isSenkouSpanACrossedOverB", isSenkouSpanACrossedOverB, ignoreFalseConditions, separator) + - ToString("isSenkouSpanACrossedUnderB", isSenkouSpanACrossedUnderB, ignoreFalseConditions, separator) + - ToString("isSenkouSpanACrossedOverLast", isSenkouSpanACrossedOverLast, ignoreFalseConditions, separator) + - ToString("isSenkouSpanACrossedUnderLast", isSenkouSpanACrossedUnderLast, ignoreFalseConditions, separator) + - ToString("isFutureSenkouSpanACrossedOverB", isFutureSenkouSpanACrossedOverB, ignoreFalseConditions, separator) + - ToString("isFutureSenkouSpanACrossedUnderB", isFutureSenkouSpanACrossedUnderB, ignoreFalseConditions, separator) + - ToString("isFutureSenkouSpanACrossedOverLast", isFutureSenkouSpanACrossedOverLast, ignoreFalseConditions, separator) + - ToString("isFutureSenkouSpanACrossedUnderLast", isFutureSenkouSpanACrossedUnderLast, ignoreFalseConditions, separator) + - "" - // - ; - ichStr = SetLabel("XICH: ", ichStr, separator); - - // - // XPV ... - string pvStr = - // - 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) + - ToString("isFiboIncreased", isFiboIncreased, ignoreFalseConditions, separator) + - ToString("isFiboDecreased", isFiboDecreased, ignoreFalseConditions, separator) + - ToString("isFiboSectionChanged", isFiboSectionChanged, ignoreFalseConditions, separator) + - ToString("isSCBullish", isSCBullish, ignoreFalseConditions, separator) + - ToString("isSCHHBullish", isSCHHBullish, ignoreFalseConditions, separator) + - ToString("isSCLLBullish", isSCLLBullish, ignoreFalseConditions, separator) + - ToString("isSCSwitchedToBullish", isSCSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isSCHHSwitchedToBullish", isSCHHSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isSCLLSwitchedToBullish", isSCLLSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isSCBearish", isSCBearish, ignoreFalseConditions, separator) + - ToString("isSCHHBearish", isSCHHBearish, ignoreFalseConditions, separator) + - ToString("isSCLLBearish", isSCLLBearish, ignoreFalseConditions, separator) + - ToString("isSCSwitchedToBearish", isSCSwitchedToBearish, ignoreFalseConditions, separator) + - ToString("isSCHHSwitchedToBearish", isSCHHSwitchedToBearish, ignoreFalseConditions, separator) + - ToString("isSCLLSwitchedToBeraish", isSCLLSwitchedToBeraish, ignoreFalseConditions, separator) + - ToString("isMCBullish", isMCBullish, ignoreFalseConditions, separator) + - ToString("isMCHHBullish", isMCHHBullish, ignoreFalseConditions, separator) + - ToString("isMCLLBullish", isMCLLBullish, ignoreFalseConditions, separator) + - ToString("isMCSwitchedToBullish", isMCSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isMCHHSwitchedToBullish", isMCHHSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isMCLLSwitchedToBullish", isMCLLSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isMCBearish", isMCBearish, ignoreFalseConditions, separator) + - ToString("isMCHHBearish", isMCHHBearish, ignoreFalseConditions, separator) + - ToString("isMCLLBearish", isMCLLBearish, ignoreFalseConditions, separator) + - ToString("isMCSwitchedToBearish", isMCSwitchedToBearish, ignoreFalseConditions, separator) + - ToString("isMCHHSwitchedToBearish", isMCHHSwitchedToBearish, ignoreFalseConditions, separator) + - ToString("isMCLLSwitchedToBeraish", isMCLLSwitchedToBeraish, ignoreFalseConditions, separator) + - ToString("isLCBullish", isLCBullish, ignoreFalseConditions, separator) + - ToString("isLCHHBullish", isLCHHBullish, ignoreFalseConditions, separator) + - ToString("isLCLLBullish", isLCLLBullish, ignoreFalseConditions, separator) + - ToString("isLCSwitchedToBullish", isLCSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isLCHHSwitchedToBullish", isLCHHSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isLCLLSwitchedToBullish", isLCLLSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isLCBearish", isLCBearish, ignoreFalseConditions, separator) + - ToString("isLCHHBearish", isLCHHBearish, ignoreFalseConditions, separator) + - ToString("isLCLLBearish", isLCLLBearish, ignoreFalseConditions, separator) + - ToString("isLCSwitchedToBearish", isLCSwitchedToBearish, ignoreFalseConditions, separator) + - ToString("isLCHHSwitchedToBearish", isLCHHSwitchedToBearish, ignoreFalseConditions, separator) + - ToString("isLCLLSwitchedToBeraish", isLCLLSwitchedToBeraish, ignoreFalseConditions, separator) + - ToString("isHCBullish", isHCBullish, ignoreFalseConditions, separator) + - ToString("isHCHHBullish", isHCHHBullish, ignoreFalseConditions, separator) + - ToString("isHCLLBullish", isHCLLBullish, ignoreFalseConditions, separator) + - ToString("isHCSwitchedToBullish", isHCSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isHCHHSwitchedToBullish", isHCHHSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isHCLLSwitchedToBullish", isHCLLSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isHCBearish", isHCBearish, ignoreFalseConditions, separator) + - ToString("isHCHHBearish", isHCHHBearish, ignoreFalseConditions, separator) + - ToString("isHCLLBearish", isHCLLBearish, ignoreFalseConditions, separator) + - ToString("isHCSwitchedToBearish", isHCSwitchedToBearish, ignoreFalseConditions, separator) + - ToString("isHCHHSwitchedToBearish", isHCHHSwitchedToBearish, ignoreFalseConditions, separator) + - ToString("isHCLLSwitchedToBeraish", isHCLLSwitchedToBeraish, ignoreFalseConditions, separator) + - "" - // - ; - pvStr = SetLabel("XPV: ", pvStr, separator); - - // - result = - onlySummary - ? commonStr - : (commonStr + - candlestickStr + - asctStr + - zgStr + - strStr + - cheStr + - tdStr + - sslcStr + - hullStr + - hkStr + - donStr + - mcStr + - mrbStr + - ichStr + - pvStr + - "" // - ); - - // - return result; - } - - // - string GetTitle() - { - // - string result = NULL; - - // - result = - // - "[" + ToString(cycle) + "]: " + ToString(period) - // - ; - - // - return result; - } -}; - -// -// Signaller Class Base Implementation ... -class XSignallerDescriptor : public XSCBase -{ - // - // Public ... -public: - // - // Props ... - - // - ENUM_XSIGNAL_PROVIDERS name; // Signaller Name - - // - bool allowLong; // Allow Long Positions - bool allowShort; // Allow Short Positions - - // - double r2r; // Risk To Reward Ratio - - // - double staticVolumeLong; // Static Volume for Long - double staticVolumeShort; // Static Volume For Short - - // - int maxAllowedLong; // Max Allowed Same Time Long Open Positions - int maxAllowedShort; // Max Allowed Same Time Short Open Positions - - // - int delayBetweenTwoSameTypeSignals; // Delay between Two Same Type Signals - int maxAllowedOpenPositionAge; // Close Position if Still Alive bigger than this value - - // - double minRequiredProfitPerTrade; // Minimum Required Profit Per Trade for Hedging - double minRequiredProfitPerTradeVolumeFactor; // Calculate Required Profit Based on Volume Factor for Hedging - - // - bool openNextPositionOnProfit; // Open Next Signaller Position only When Previous Signals in Profit - bool ignoreProfitForOppositeSignals; // Ignore In Profit Policy when Opposite Signal Comming - - // - - // - // Constructor ... - void XSignallerDescriptor() - { - } - - // - // Tools ... - - // - // Cleanup ... - void Clean() - { - // - name = PROVIDER_NONE; - - // - allowLong = false; - allowShort = false; - - // - r2r = 0; - - // - staticVolumeLong = 0; - staticVolumeShort = 0; - - // - maxAllowedLong = 0; - maxAllowedShort = 0; - maxAllowedOpenPositionAge = 0; - delayBetweenTwoSameTypeSignals = 0; - - // - minRequiredProfitPerTrade = 0; - minRequiredProfitPerTradeVolumeFactor = 0; - - // - openNextPositionOnProfit = false; - ignoreProfitForOppositeSignals = false; - } - - // - // Enable Default Configurations ... - virtual void Default() - { - // - allowLong = true; - allowShort = true; - - // - r2r = 1; - - // - maxAllowedLong = 3; - maxAllowedShort = 3; - - // - staticVolumeLong = 0.01; - staticVolumeShort = 0.01; - - // - maxAllowedOpenPositionAge = 576; // Two Days on 5 Min - delayBetweenTwoSameTypeSignals = 12; // 1 Hour on 5 Min - - // - // Set 10 $ Per each Trade on 0.01 Volume - // is Enough for Hedging ... - minRequiredProfitPerTrade = 5; - minRequiredProfitPerTradeVolumeFactor = 0.01; - - // - openNextPositionOnProfit = true; - ignoreProfitForOppositeSignals = true; - } - - // - // Validate ... - bool IsValid() - { - // - bool result = false; - - // - result = - // - name != PROVIDER_NONE && - r2r > 0 && - (allowLong - ? staticVolumeLong > 0 - : true) && - (allowShort - ? staticVolumeShort > 0 - : true) - // - ; - - // - return result; - } - - // - // Retrieve Signaller Name as String ... - string GetName() - { - return ToString(name); - } - - // - // Check Hedge is Enable or Not ... - bool AllowHedge() - { - // - bool result = false; - - // - result = - // - minRequiredProfitPerTrade > 0 && - minRequiredProfitPerTradeVolumeFactor > 0 - // - ; - - // - return result; - } - - // - // Generate Signal ... - bool GenerateSignal( - XSignal &signal, // Result - string mSymbol, // Trading Symbol - ENUM_TIMEFRAMES mPeriod, // Trading TimeFrame - ENUM_POSITION_TYPE mType, // Long (Buy) or Short (Sell) - ENUM_X_ORDER_MODES mMode, // Execution Mode - double mEntry, // Entry Price - double mSL = 0, // Stop Loss - double mTP = 0 // Take Profit - ) - { - // - bool result = false; - - // - signal.Clean(); - - // - // Validate Model ... - result = IsValid(); - if (!result) - { - return result; - } - - // - bool isLong = IsLong(mType); - - // - // Validate Signal Type ... - result = isLong - ? allowLong && staticVolumeLong > 0 - : allowShort && staticVolumeShort > 0; - if (!result) - { - return result; - } - - // - double mVolume = isLong - ? staticVolumeLong - : staticVolumeShort; - - // - result = signal.Prepare( - mSymbol, - GetName(), - mPeriod, - mType, - mMode, - mEntry, - mVolume, - mSL, - mTP // - ); - - // - return result; - } - - // - // Generate Market Signal ... - bool GenerateMarketSignal( - XSignal &signal, // Result - string mSymbol, // Trading Symbol - ENUM_TIMEFRAMES mPeriod, // Trading TimeFrame - ENUM_POSITION_TYPE mType, // Long (Buy) or Short (Sell) - double mEntry, // Entry Price - double mSL = 0, // Stop Loss - double mTP = 0 // Take Profit - ) - { - // - bool result = false; - - // - signal.Clean(); - - // - // Validate Model ... - result = IsValid(); - if (!result) - { - return result; - } - - // - bool isLong = IsLong(mType); - - // - // Validate Signal Type ... - result = isLong - ? allowLong && staticVolumeLong > 0 - : allowShort && staticVolumeShort > 0; - if (!result) - { - return result; - } - - // - double mVolume = isLong - ? staticVolumeLong - : staticVolumeShort; - - // - result = signal.Prepare( - mSymbol, - GetName(), - mPeriod, - mType, - X_ORDER_MODE_MARKET, - mEntry, - mVolume, - mSL, - mTP // - ); - - // - return result; - } - - // - // Check Has Conditions opr Not ... - bool HasConditions( - X121MCycleConditions &conditions, // Market Conditions - bool &hasLong, // Hold Long Conditions Result - bool &hasShort, // Hold Short Conditions Result - double &sl, // Hold SL ... - double &tp // Hold TP ... - ) - { - // - bool result = false; - - // - hasLong = HasLongConditions(conditions, sl, tp); - hasShort = HasShortConditions(conditions, sl, tp); - - // - result = hasLong || hasShort; - - // - return result; - } - - // - // Check Has Long Conditions opr Not ... - virtual bool HasLongConditions( - X121MCycleConditions &conditions, // Market Conditions - double &sl, // Hold SL ... - double &tp // Hold TP ... - ) - { - return false; - } - - // - // Check Has Short Conditions opr Not ... - virtual bool HasShortConditions( - X121MCycleConditions &conditions, // Market Conditions - double &sl, // Hold SL ... - double &tp // Hold TP ... - ) - { - return false; - } - - // - // Check For Guards ... - virtual int HasGuard(XGuard &guards[]) - { - return 0; - } - - // - // Protected ... -protected: -}; - -// -// Market Class ... -class XSCX121Market : XSCBaseAlert -{ - // - // Public ... -public: - // - // Props ... - XSCXHKHelper hk; - XSCXMCHelper mc; - XSCXPVHelper pv; - XSCXZGHelper zg; - XSCXTDHelper td; - XSCXMRBHelper mrb; - XSCXSTRHelper str; - XSCXCHEHelper che; - XSCXOSCHelper osc; - XSCXICHHelper ich; - XSCXDONHelper don; - XSCXASCTHelper asct; - XSCXHULLHelper hull; - XSCXSSLCHelper sslc; - - // - // Properties ... - - // - // Retrieve Trading Symbol ... - string GetSymbol() - { - return mInputs.cycle.symbol; - } - - // - // Retrieve Cycle Time Frame ... - ENUM_TIMEFRAMES GetPeriod() - { - return mInputs.cycle.period; - } - - // - // Retrieve Market Host Time Frame ... - ENUM_TIMEFRAMES GetHostPeriod() - { - return mInputs.cycle.hostPeriod; - } - - // - // Count Total Available Bars in Market ... - int CountBars() - { - // - Update(0); - return mInputs.cycle.CountBars(); - } - - // - // Check Market is in new Bar ... - int IsNewBar() - { - // - Update(0); - return mInputs.cycle.IsNewBar(); - } - - // - // Retrieve Current Cycles Specific Bar ... - XOHCL GetBar(int barIndex) - { - // - Update(0); - return mInputs.cycle.GetBar(barIndex); - } - - // - // Retrieve Current Bar Index based on Host Period bar Index ... - int GetBarIndex(int barIndex) - { - // - Update(barIndex); - return mInputs.cycle.GetBarIndex(barIndex); - } - - // - // Retrieve Bar Time ... - datetime GetBarTime(int barIndex) - { - // - Update(0); - return mInputs.cycle.GetBarTime(barIndex); - } - - // - // Retrieve Current Market Config ... - bool GetInputs(X121MCycleInputs &inputs) - { - // - bool result = false; - - // - inputs = mInputs; - - // - result = inputs.IsValid(); - - // - return result; - } - - // - // Set Market Inputs and Re Initial ... - bool SetInputs( - X121MCycleInputs &inputs // Config - ) - { - // - return Init(inputs); - } - - // - // Tools ... - - // - void GetMarketConditions( - X121MCycleConditions &conditions, // Market Conditions Result - int barIndex = 0, // Specified Bar Index - int mNumberOfItems = 15 // Number of Reading Items - ) - { - // - conditions.Clear(); - - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - if (barIndex >= CountBars()) - { - barIndex = CountBars() + 2; - } - - // - if (mNumberOfItems <= 0) - { - mNumberOfItems = 2; - } - - // - // Set Commons ... - conditions.time = GetBarTime(barIndex); - conditions.cycle = mInputs.cycle.cycle; - conditions.prefix = mInputs.cycle.prefix; - conditions.symbol = mInputs.cycle.symbol; - conditions.period = mInputs.cycle.period; - conditions.hostPeriod = mInputs.cycle.hostPeriod; - - // - Clean(conditions.bars); - GetBars( - conditions.bars, - conditions.symbol, - conditions.period, - barIndex, - mNumberOfItems - // - ); - - // - int zIndex = barIndex; - int cIndex = zIndex + 1; - int pIndex = cIndex + 1; - int ppIndex = pIndex + 1; - - // - int start = zIndex; - int count = mNumberOfItems; - - // - // Filling Buffers ... - - // - // XASCT ... - - // - asct.CopyLong( - start, - count, - conditions.asctLongs // - ); - - // - asct.CopyShort( - start, - count, - conditions.asctShorts // - ); - - // - // XHULL ... - - // - hull.CopyUp( - start, - count, - conditions.hullUps // - ); - - // - hull.CopyDown( - start, - count, - conditions.hullDowns // - ); - - // - // XSSLC ... - - // - sslc.CopyUp( - start, - count, - conditions.sslcUps // - ); - - // - sslc.CopyDown( - start, - count, - conditions.sslcDowns // - ); - - // - // XHK ... - - // - hk.CopyAsOHCL( - start, - count, - conditions.hkBars // - ); - - // - hk.CopySMAsOHCL( - start, - count, - conditions.smHKBars // - ); - - // - // XICH ... - - // - ich.CopyTenkanSen( - start, - count, - conditions.ichTenkanSens // - ); - - // - ich.CopyKijunSen( - start, - count, - conditions.ichKijunSens // - ); - - // - ich.CopyChikouSpan( - start, - count, - conditions.ichChikouSpans // - ); - - // - ich.CopySenkouSpanA( - start, - count, - conditions.ichSenkouSpanAs // - ); - - // - ich.CopySenkouSpanB( - start, - count, - conditions.ichSenkouSpanBs // - ); - - // - ich.CopyFutureSenkouSpanA( - start, - count, - conditions.ichFutureSenkouSpanAs // - ); - - // - ich.CopyFutureSenkouSpanB( - start, - count, - conditions.ichFutureSenkouSpanBs // - ); - - // - // XMC ... - - // - mc.CopyFast( - start, - count, - conditions.mcFasts // - ); - - // - mc.CopySlow( - start, - count, - conditions.mcSlows // - ); - - // - mc.CopyVerifier( - start, - count, - conditions.mcVerifiers // - ); - - // - // XSTR ... - - // - str.CopyTrend( - start, - count, - conditions.strTrends // - ); - - // - str.CopyState( - start, - count, - conditions.strStates // - ); - - // - // XZG ... - - // - zg.CopyMain( - start, - count, - conditions.zigzags // - ); - - // - zg.CopyPeaksAndVales( - start, - count, - conditions.zigzagPVs // - ); - - // - // XMRB ... - - // - mrb.CopyFast( - start, - count, - conditions.mrbFasts // - ); - - // - mrb.CopySlow( - start, - count, - conditions.mrbSlows // - ); - - // - // Ribbon 1 ... - - // - mrb.CopyR1Fast( - start, - count, - conditions.mrb1Fasts // - ); - - // - mrb.CopyR1Slow( - start, - count, - conditions.mrb1Slows // - ); - - // - // Ribbon 2 ... - - // - mrb.CopyR2Fast( - start, - count, - conditions.mrb2Fasts // - ); - - // - mrb.CopyR2Slow( - start, - count, - conditions.mrb2Slows // - ); - - // - // Ribbon 3 ... - - // - mrb.CopyR3Fast( - start, - count, - conditions.mrb3Fasts // - ); - - // - mrb.CopyR3Slow( - start, - count, - conditions.mrb3Slows // - ); - - // - // Ribbon 4 ... - - // - mrb.CopyR4Fast( - start, - count, - conditions.mrb4Fasts // - ); - - // - mrb.CopyR4Slow( - start, - count, - conditions.mrb4Slows // - ); - - // - // Ribbon 5 ... - - // - mrb.CopyR5Fast( - start, - count, - conditions.mrb5Fasts // - ); - - // - mrb.CopyR5Slow( - start, - count, - conditions.mrb5Slows // - ); - - // - // Ribbon 6 ... - - // - mrb.CopyR6Fast( - start, - count, - conditions.mrb6Fasts // - ); - - // - mrb.CopyR6Slow( - start, - count, - conditions.mrb6Slows // - ); - - // - // XCHE ... - - // - che.CopyLongExit1( - start, - count, - conditions.cheLongExit1s // - ); - - // - che.CopyLongExit2( - start, - count, - conditions.cheLongExit2s // - ); - - // - che.CopyShortExit1( - start, - count, - conditions.cheShortExit1s // - ); - - // - che.CopyShortExit2( - start, - count, - conditions.cheShortExit2s // - ); - - // - // XTD ... - - // - td.CopyBullish( - start, - count, - conditions.tdBullishs // - ); - - // - td.CopyBearish( - start, - count, - conditions.tdBearishs // - ); - - // - td.CopySignal( - start, - count, - conditions.tdSignals // - ); - - // - // XDON ... - - // - don.CopyUpperO( - start, - count, - conditions.donUpperOs // - ); - - // - don.CopyLowerO( - start, - count, - conditions.donLowerOs // - ); - - // - don.CopyUpperC( - start, - count, - conditions.donUpperCs // - ); - - // - don.CopyLowerC( - start, - count, - conditions.donLowerCs // - ); - - // - don.CopyUpperH( - start, - count, - conditions.donUpperHs // - ); - - // - don.CopyLowerH( - start, - count, - conditions.donLowerHs // - ); - - // - don.CopyUpperL( - start, - count, - conditions.donUpperLs // - ); - - // - don.CopyLowerL( - start, - count, - conditions.donLowerLs // - ); - - // - // XPV ... - - // - pv.CopyPeak( - start, - count, - conditions.pvPeaks // - ); - - // - pv.CopyVale( - start, - count, - conditions.pvVales // - ); - - // - pv.CopyResistance( - start, - count, - conditions.pvResistances // - ); - - // - pv.CopySupport( - start, - count, - conditions.pvSupports // - ); - - // - pv.CopyFib1( - start, - count, - conditions.pvFib1s // - ); - - // - pv.CopyFib2( - start, - count, - conditions.pvFib2s // - ); - - // - pv.CopyFib3( - start, - count, - conditions.pvFib3s // - ); - - // - pv.CopyFib4( - start, - count, - conditions.pvFib4s // - ); - - // - pv.CopyFib5( - start, - count, - conditions.pvFib5s // - ); - - // - pv.CopySCHH( - start, - count, - conditions.pvSCHHs // - ); - - // - pv.CopySCLL( - start, - count, - conditions.pvSCLLs // - ); - - // - pv.CopyMCHH( - start, - count, - conditions.pvMCHHs // - ); - - // - pv.CopyMCLL( - start, - count, - conditions.pvMCLLs // - ); - - // - pv.CopyLCHH( - start, - count, - conditions.pvLCHHs // - ); - - // - pv.CopyLCLL( - start, - count, - conditions.pvLCLLs // - ); - - // - pv.CopyHCHH( - start, - count, - conditions.pvHCHHs // - ); - - // - pv.CopyHCLL( - start, - count, - conditions.pvHCLLs // - ); - - // - // XOSC ... - - // - // ATR ... - osc.CopyATR( - start, - count, - conditions.oscAtrs // - ); - - // - // VOLUE ... - osc.CopyVolume( - start, - count, - conditions.oscVolumes // - ); - - // - // MOMENTUM ... - osc.CopyMomentum( - start, - count, - conditions.oscMomentums // - ); - - // - // SAR ... - osc.CopySAR( - start, - count, - conditions.oscSars // - ); - - // - // RSI ... - osc.CopyRSI( - start, - count, - conditions.oscRsis // - ); - - // - // CCI ... - osc.CopyCCI( - start, - count, - conditions.oscCcis // - ); - - // - // STDDEV ... - osc.CopySTDDEV( - start, - count, - conditions.oscStddevs // - ); - - // - // BULLPOWER ... - osc.CopyBullPower( - start, - count, - conditions.oscBullPs // - ); - - // - // BEARPOWER ... - osc.CopyBearPower( - start, - count, - conditions.oscBearPs // - ); - - // - // RVI ... - - // - osc.CopyRVI( - start, - count, - conditions.oscRviMains // - ); - - // - osc.CopyRVISignal( - start, - count, - conditions.oscRviSignals // - ); - - // - // MACD ... - - // - osc.CopyMACD( - start, - count, - conditions.oscMacdMains // - ); - - // - osc.CopyMACDSignal( - start, - count, - conditions.oscMacdSignals // - ); - - // - // STOCH ... - - // - osc.CopySTOCH( - start, - count, - conditions.oscStochMains // - ); - - // - osc.CopySTOCHSignal( - start, - count, - conditions.oscStochSignals // - ); - - // - // Now we Have all Buffers ... - // Going to Extract Market Conditions Variables ... - - // - XOHCL zBar = conditions.bars[zIndex]; - XOHCL cBar = conditions.bars[cIndex]; - XOHCL pBar = conditions.bars[pIndex]; - - // - // Candlestic ... - // - bool isLastBullish = - // - cBar.IsBullish() - // - ; - - // - bool isLastBearish = - // - cBar.IsBearish() - // - ; - - // - bool isCurrentBullish = - // - zBar.IsBullish() - // - ; - - // - bool isCurrentBearish = - // - zBar.IsBearish() - // - ; - - // - bool isCurrentMidLineOverLastHigh = - // - zBar.GetMid() > cBar.high; - // - ; - - // - bool isCurrentMidLineUnderLastLow = - // - zBar.GetMid() < cBar.low - // - ; - - // - bool isCurrentMidLineOverLastUp = - // - zBar.GetMid() > cBar.GetUp() - // - ; - - // - bool isCurrentMidLineUnderLastDown = - // - zBar.GetMid() < cBar.GetDown() - // - ; - - // - bool isCurrentMidLineOverLastMidLine = - // - zBar.GetMid() > cBar.GetMid() - // - ; - - // - bool isCurrentMidLineUnderLastMidLine = - // - zBar.GetMid() < cBar.GetMid() - // - ; - - // - // XHK ... - - // - XOHCL zHKBar = conditions.hkBars[zIndex]; - XOHCL cHKBar = conditions.hkBars[cIndex]; - XOHCL pHKBar = conditions.hkBars[pIndex]; - - // - bool isHKBullish = cHKBar.IsBullish(); - bool isHKBearish = cHKBar.IsBearish(); - bool isClosedOverHK = cBar.close > cHKBar.high; - bool isClosedUnderHK = cBar.close < cHKBar.low; - bool isHKSwitchedToBullish = cHKBar.IsBullish() && !pHKBar.IsBullish(); - bool isHKSwitchedToBearish = cHKBar.IsBearish() && !pHKBar.IsBearish(); - - // - XOHCL zSMHKBar = conditions.smHKBars[zIndex]; - XOHCL cSMHKBar = conditions.smHKBars[cIndex]; - XOHCL pSMHKBar = conditions.smHKBars[pIndex]; - - // - bool isSMHKBullish = cSMHKBar.IsBullish(); - bool isSMHKBearish = cSMHKBar.IsBearish(); - bool isClosedOverSMHK = cBar.close > cSMHKBar.high; - bool isClosedUnderSMHK = cBar.close < cSMHKBar.low; - bool isSMHKSwitchedToBullish = cSMHKBar.IsBullish() && !pSMHKBar.IsBullish(); - bool isSMHKSwitchedToBearish = cSMHKBar.IsBearish() && !pSMHKBar.IsBearish(); - - // - // XASCT ... - - // - bool isASCTLong = conditions.asctLongs[zIndex] > 0; - bool isASCTShort = conditions.asctShorts[zIndex] > 0; - - // - // XSSLC ... - - // - bool isSSLCBullish = conditions.sslcUps[cIndex] > conditions.sslcDowns[cIndex]; - bool isSSLCBullishPrev = conditions.sslcUps[pIndex] > conditions.sslcDowns[pIndex]; - - // - bool isSSLCBearish = conditions.sslcDowns[cIndex] > conditions.sslcUps[cIndex]; - bool isSSLCBearishPrev = conditions.sslcDowns[pIndex] > conditions.sslcUps[pIndex]; - - // - bool isSSLCSwitchedToBullish = isSSLCBullish && - !isSSLCBullishPrev; - bool isSSLCSwitchedToBearish = isSSLCBearish && - !isSSLCBearishPrev; - - // - // XHULL ... - - // - bool isHullUpBullish = conditions.hullUps[cIndex] > conditions.hullUps[pIndex]; - bool isHullUpBullishPrev = conditions.hullUps[pIndex] > conditions.hullUps[ppIndex]; - - // - bool isHullUpBearish = conditions.hullUps[cIndex] < conditions.hullUps[pIndex]; - bool isHullUpBearishPrev = conditions.hullUps[pIndex] < conditions.hullUps[ppIndex]; - - // - bool isHullDownBullish = conditions.hullDowns[cIndex] > conditions.hullDowns[pIndex]; - bool isHullDownBullishPrev = conditions.hullDowns[pIndex] > conditions.hullDowns[ppIndex]; - - // - bool isHullDownBearish = conditions.hullDowns[cIndex] < conditions.hullDowns[pIndex]; - bool isHullDownBearishPrev = conditions.hullDowns[pIndex] < conditions.hullDowns[ppIndex]; - - // - bool isHullBullish = isHullUpBullish && isHullDownBullish; - bool isHullBullishPrev = isHullUpBullishPrev && isHullDownBullishPrev; - - // - bool isHullBearish = isHullUpBearish && isHullDownBearish; - bool isHullBearishPrev = isHullUpBearishPrev && isHullDownBearishPrev; - - bool isHullSwitchedToBullish = isHullBullish && - !isHullBullishPrev; - bool isHullSwitchedToBearish = isHullBearish && - !isHullBearishPrev; - - // - // XICH ... - - // - bool isClosedOverKijunSen = cBar.close > conditions.ichKijunSens[cIndex]; - bool isClosedUnderKijunSen = cBar.close < conditions.ichKijunSens[cIndex]; - bool isTenkanSenOverKijunSen = conditions.ichTenkanSens[cIndex] > conditions.ichKijunSens[cIndex]; - bool isTenkanSenUnderKijunSen = conditions.ichTenkanSens[cIndex] < conditions.ichKijunSens[cIndex]; - - // - bool isTenkanSenOverKijunSenPrev = conditions.ichTenkanSens[pIndex] > conditions.ichKijunSens[pIndex]; - bool isTenkanSenUnderKijunSenPrev = conditions.ichTenkanSens[pIndex] < conditions.ichKijunSens[pIndex]; - - // - bool isTenkanSenCrossedOverKijunSen = isTenkanSenOverKijunSen && - !isTenkanSenOverKijunSenPrev; - bool isTenkanSenCrossedUnderKijunSen = isTenkanSenUnderKijunSen && - !isTenkanSenUnderKijunSenPrev; - - // - bool isSenkouSpanAOverB = conditions.ichSenkouSpanAs[cIndex] > conditions.ichSenkouSpanBs[cIndex]; - bool isSenkouSpanAUnderB = conditions.ichSenkouSpanAs[cIndex] < conditions.ichSenkouSpanBs[cIndex]; - - // - bool isSenkouSpanAOverBPrev = conditions.ichSenkouSpanAs[pIndex] > conditions.ichSenkouSpanBs[pIndex]; - bool isSenkouSpanAUnderBPrev = conditions.ichSenkouSpanAs[pIndex] < conditions.ichSenkouSpanBs[pIndex]; - - // - bool isSenkouSpanAOverLast = conditions.ichSenkouSpanAs[cIndex] > conditions.ichSenkouSpanAs[pIndex]; - bool isSenkouSpanAUnderLast = conditions.ichSenkouSpanAs[cIndex] < conditions.ichSenkouSpanAs[pIndex]; - - // - bool isSenkouSpanAOverLastPrev = conditions.ichSenkouSpanAs[pIndex] > conditions.ichSenkouSpanAs[ppIndex]; - bool isSenkouSpanAUnderLastPrev = conditions.ichSenkouSpanAs[pIndex] < conditions.ichSenkouSpanAs[ppIndex]; - - // - bool isFutureSenkouSpanAOverB = conditions.ichFutureSenkouSpanAs[cIndex] > conditions.ichFutureSenkouSpanBs[cIndex]; - bool isFutureSenkouSpanAUnderB = conditions.ichFutureSenkouSpanAs[cIndex] < conditions.ichFutureSenkouSpanBs[cIndex]; - - // - bool isFutureSenkouSpanAOverBPrev = conditions.ichFutureSenkouSpanAs[pIndex] > conditions.ichFutureSenkouSpanBs[pIndex]; - bool isFutureSenkouSpanAUnderBPrev = conditions.ichFutureSenkouSpanAs[pIndex] < conditions.ichFutureSenkouSpanBs[pIndex]; - - // - bool isFutureSenkouSpanAOverLast = conditions.ichFutureSenkouSpanAs[cIndex] > conditions.ichFutureSenkouSpanAs[pIndex]; - bool isFutureSenkouSpanAUnderLast = conditions.ichFutureSenkouSpanAs[cIndex] < conditions.ichFutureSenkouSpanAs[pIndex]; - - // - bool isFutureSenkouSpanAOverLastPrev = conditions.ichFutureSenkouSpanAs[pIndex] > conditions.ichFutureSenkouSpanAs[ppIndex]; - bool isFutureSenkouSpanAUnderLastPrev = conditions.ichFutureSenkouSpanAs[pIndex] < conditions.ichFutureSenkouSpanAs[ppIndex]; - - // - bool isSenkouSpanACrossedOverB = isSenkouSpanAOverB && - !isSenkouSpanAOverBPrev; - bool isSenkouSpanACrossedUnderB = isSenkouSpanAUnderB && - !isSenkouSpanAUnderBPrev; - bool isSenkouSpanACrossedOverLast = isSenkouSpanAOverLast && - !isSenkouSpanAOverLastPrev; - bool isSenkouSpanACrossedUnderLast = isSenkouSpanAUnderLast && - !isSenkouSpanAUnderLastPrev; - bool isFutureSenkouSpanACrossedOverB = isFutureSenkouSpanAOverB && - !isFutureSenkouSpanAOverBPrev; - bool isFutureSenkouSpanACrossedUnderB = isFutureSenkouSpanAUnderB && - !isFutureSenkouSpanAUnderBPrev; - bool isFutureSenkouSpanACrossedOverLast = isFutureSenkouSpanAOverLast && - !isFutureSenkouSpanAOverLastPrev; - bool isFutureSenkouSpanACrossedUnderLast = isFutureSenkouSpanAUnderLast && - !isFutureSenkouSpanAUnderLastPrev; - - // - // XMC ... - - // - bool isMCFastOverSlow = conditions.mcFasts[cIndex] > conditions.mcSlows[cIndex]; - bool isMCFastUnderSlow = conditions.mcFasts[cIndex] < conditions.mcSlows[cIndex]; - - // - bool isMCFastOverSlowPrev = conditions.mcFasts[pIndex] > conditions.mcSlows[pIndex]; - bool isMCFastUnderSlowPrev = conditions.mcFasts[pIndex] < conditions.mcSlows[pIndex]; - - // - bool isMCFastOverVerifier = conditions.mcFasts[cIndex] > conditions.mcVerifiers[cIndex]; - bool isMCFastUnderVerifier = conditions.mcFasts[cIndex] < conditions.mcVerifiers[cIndex]; - - // - bool isMCFastOverVerifierPrev = conditions.mcFasts[pIndex] > conditions.mcVerifiers[pIndex]; - bool isMCFastUnderVerifierPrev = conditions.mcFasts[pIndex] < conditions.mcVerifiers[pIndex]; - - // - bool isMCSlowOverVerifier = conditions.mcSlows[cIndex] > conditions.mcVerifiers[cIndex]; - bool isMCSlowUnderVerifier = conditions.mcSlows[cIndex] < conditions.mcVerifiers[cIndex]; - - // - bool isMCSlowOverVerifierPrev = conditions.mcSlows[pIndex] > conditions.mcVerifiers[pIndex]; - bool isMCSlowUnderVerifierPrev = conditions.mcSlows[pIndex] < conditions.mcVerifiers[pIndex]; - - // - bool isMCFastCrossedOverSlow = isMCFastOverSlow && - !isMCFastOverSlowPrev; - bool isMCFastCrossedUnderSlow = isMCFastUnderSlow && - !isMCFastUnderSlowPrev; - bool isMCFastCrossedOverVerifier = isMCFastOverVerifier && - !isMCFastOverVerifierPrev; - bool isMCFastCrossedUnderVerifier = isMCFastUnderVerifier && - !isMCFastUnderVerifierPrev; - bool isMCSlowCrossedOverVerifier = isMCSlowOverVerifier && - !isMCSlowOverVerifierPrev; - bool isMCSlowCrossedUnderVerifier = isMCSlowUnderVerifier && - !isMCSlowUnderVerifierPrev; - - // - // XSTR ... - - // - bool isTrendBullish = str.IsBullish(conditions.strStates[cIndex]); - bool isTrendBearish = str.IsBearish(conditions.strStates[cIndex]); - bool isTrendSwitchedToBullish = str.IsBullish(conditions.strStates[cIndex]) && - !str.IsBullish(conditions.strStates[pIndex]); - bool isTrendSwitchedToBearish = str.IsBearish(conditions.strStates[cIndex]) && - !str.IsBearish(conditions.strStates[pIndex]); - - // - // XZG ... - - // - bool isZigZagInPeak = conditions.zigzags[cIndex] < conditions.zigzagPVs[cIndex]; - bool isZigZagInVale = conditions.zigzags[cIndex] > conditions.zigzagPVs[cIndex]; - - // - // XMRB ... - - // - bool isMRBFastOverSlow = conditions.mrbFasts[cIndex] > conditions.mrbSlows[cIndex]; - bool isMRBFastUnderSlow = conditions.mrbFasts[cIndex] < conditions.mrbSlows[cIndex]; - - // - bool isMRBFastOverSlowPrev = conditions.mrbFasts[pIndex] > conditions.mrbSlows[pIndex]; - bool isMRBFastUnderSlowPrev = conditions.mrbFasts[pIndex] < conditions.mrbSlows[pIndex]; - - // - bool isMRBFastCrossedOverSlow = isMRBFastOverSlow && - !isMRBFastOverSlowPrev; - bool isMRBFastCrossedUnderSlow = isMRBFastUnderSlow && - !isMRBFastUnderSlowPrev; - - // - bool isMRBFastOverVerifier = conditions.mrbFasts[cIndex] > conditions.mcVerifiers[cIndex]; - bool isMRBFastUnderVerifier = conditions.mrbFasts[cIndex] < conditions.mcVerifiers[cIndex]; - - // - bool isMRBFastOverVerifierPrev = conditions.mrbFasts[pIndex] > conditions.mcVerifiers[pIndex]; - bool isMRBFastUnderVerifierPrev = conditions.mrbFasts[pIndex] < conditions.mcVerifiers[pIndex]; - - // - bool isMRBFastCrossedtOverVerifier = isMRBFastOverVerifier && - !isMRBFastOverVerifierPrev; - bool isMRBFastCrossedUnderVerifier = isMRBFastUnderVerifier && - !isMRBFastUnderVerifierPrev; - - // - bool isMRBSlowOverVerifier = conditions.mrbSlows[cIndex] > conditions.mcVerifiers[cIndex]; - bool isMRBSlowUnderVerifier = conditions.mrbSlows[cIndex] < conditions.mcVerifiers[cIndex]; - - // - bool isMRBSlowOverVerifierPrev = conditions.mrbSlows[pIndex] > conditions.mcVerifiers[pIndex]; - bool isMRBSlowUnderVerifierPrev = conditions.mrbSlows[pIndex] < conditions.mcVerifiers[pIndex]; - - // - bool isMRBSlowCrossedtOverVerifier = isMRBSlowOverVerifier && - !isMRBSlowOverVerifierPrev; - bool isMRBSlowCrossedUnderVerifier = isMRBSlowUnderVerifier && - !isMRBSlowUnderVerifierPrev; - - // - // XCHE ... - - // - bool isCHEBullish = NotEmpty(conditions.cheLongExit1s[cIndex]) && - NotEmpty(conditions.cheLongExit2s[cIndex]); - bool isCHEBearish = NotEmpty(conditions.cheShortExit1s[cIndex]) && - NotEmpty(conditions.cheShortExit2s[cIndex]); - - // - bool isCHEBullishPrev = NotEmpty(conditions.cheLongExit1s[pIndex]) && - NotEmpty(conditions.cheLongExit2s[pIndex]); - bool isCHEBearishPrev = NotEmpty(conditions.cheShortExit1s[pIndex]) && - NotEmpty(conditions.cheShortExit2s[pIndex]); - - // - bool isCHESwitchedToBullish = isCHEBullish && - !isCHEBullishPrev; - bool isCHESwitchedToBearish = isCHEBearish && - !isCHEBearishPrev; - - // - // XTD ... - - // - bool isTDBullish = conditions.tdBullishs[cIndex] > conditions.tdBearishs[cIndex]; - bool isTDBearish = conditions.tdBearishs[cIndex] > conditions.tdBullishs[cIndex]; - - // - bool isTDBullishPrev = conditions.tdBullishs[pIndex] > conditions.tdBearishs[pIndex]; - bool isTDBearishPrev = conditions.tdBearishs[pIndex] > conditions.tdBullishs[pIndex]; - - // - bool isTDSwitchedToBullish = isTDBullish && - !isTDBullishPrev; - bool isTDSwitchedToBearish = isTDBearish && - !isTDBearishPrev; - - // - // XDON ... - - // - double cDonMaxUpper = don.GetMaxUpper(cIndex); - double pDonMaxUpper = don.GetMaxUpper(pIndex); - - // - double cDonMinUpper = don.GetMinUpper(cIndex); - double pDonMinUpper = don.GetMinUpper(pIndex); - - // - double cDonMaxLower = don.GetMaxLower(cIndex); - double pDonMaxLower = don.GetMaxLower(pIndex); - - // - double cDonMinLower = don.GetMinLower(cIndex); - double pDonMinLower = don.GetMinLower(pIndex); - - // - bool isDONAttachedMaxLower = cBar.low <= cDonMaxLower; - bool isDONAttachedMinLower = cBar.low <= cDonMinLower; - - // - bool isDONAttachedMaxLowerPrev = pBar.low <= pDonMaxLower; - bool isDONAttachedMinLowerPrev = pBar.low <= pDonMinLower; - - // - bool isDONCrossedOverMaxLower = !isDONAttachedMaxLower && - isDONAttachedMaxLowerPrev; - bool isDONCrossedUnderMaxLower = isDONAttachedMaxLower && - !isDONAttachedMaxLowerPrev; - - // - bool isDONCrossedOverMinLower = !isDONAttachedMinLower && - isDONAttachedMinLowerPrev; - bool isDONCrossedUnderMinLower = isDONAttachedMinLower && - !isDONAttachedMinLowerPrev; - - // - bool isDONAttachedMaxUpper = cBar.high >= cDonMaxUpper; - bool isDONAttachedMinUpper = cBar.high >= cDonMinUpper; - - // - bool isDONAttachedMaxUpperPrev = pBar.high >= pDonMaxUpper; - bool isDONAttachedMinUpperPrev = pBar.high >= pDonMinUpper; - - // - bool isDONCrossedOverMaxUpper = isDONAttachedMaxUpper && - !isDONAttachedMaxUpperPrev; - bool isDONCrossedUnderMaxUpper = !isDONAttachedMaxUpper && - isDONAttachedMaxUpperPrev; - - // - bool isDONCrossedOverMinUpper = isDONAttachedMinUpper && - !isDONAttachedMinUpperPrev; - bool isDONCrossedUnderMinUpper = !isDONAttachedMinUpper && - isDONAttachedMinUpperPrev; - - // - // XPV ... - - // - bool isNewPeak = conditions.pvPeaks[cIndex] != conditions.pvPeaks[pIndex]; - bool isNewPeakOverLast = isNewPeak && - conditions.pvPeaks[cIndex] > conditions.pvPeaks[pIndex]; - bool isNewPeakUnderLast = isNewPeak && - conditions.pvPeaks[cIndex] < conditions.pvPeaks[pIndex]; - - // - bool isNewVale = conditions.pvVales[cIndex] != conditions.pvVales[pIndex]; - bool isNewValeOverLast = isNewVale && - conditions.pvVales[cIndex] > conditions.pvVales[pIndex]; - bool isNewValeUnderLast = isNewVale && - conditions.pvVales[cIndex] < conditions.pvVales[pIndex]; - - // - bool isFiboIncreased = - // - conditions.pvFib1s[cIndex] > conditions.pvFib1s[pIndex] && - conditions.pvFib2s[cIndex] > conditions.pvFib2s[pIndex] && - conditions.pvFib3s[cIndex] > conditions.pvFib3s[pIndex] && - conditions.pvFib4s[cIndex] > conditions.pvFib4s[pIndex] && - conditions.pvFib5s[cIndex] > conditions.pvFib5s[pIndex] - // - ; - bool isFiboDecreased = - // - conditions.pvFib1s[cIndex] < conditions.pvFib1s[pIndex] && - conditions.pvFib2s[cIndex] < conditions.pvFib2s[pIndex] && - conditions.pvFib3s[cIndex] < conditions.pvFib3s[pIndex] && - conditions.pvFib4s[cIndex] < conditions.pvFib4s[pIndex] && - conditions.pvFib5s[cIndex] < conditions.pvFib5s[pIndex] - // - ; - - bool isFiboSectionChanged = - // - (isFiboDecreased && - isNewPeakUnderLast) - // - || - // - (isFiboIncreased && - isNewValeOverLast) - // - ; - - // - // SC ... - - // - bool isSCHHBullish = conditions.pvSCHHs[cIndex] > conditions.pvSCHHs[pIndex]; - bool isSCLLBullish = conditions.pvSCLLs[cIndex] > conditions.pvSCLLs[pIndex]; - - // - bool isSCHHBullishPrev = conditions.pvSCHHs[pIndex] > conditions.pvSCHHs[ppIndex]; - bool isSCLLBullishPrev = conditions.pvSCLLs[pIndex] > conditions.pvSCLLs[ppIndex]; - - // - bool isSCBullish = isSCHHBullish && - isSCLLBullish; - - // - bool isSCBullishPrev = isSCHHBullishPrev && - isSCLLBullishPrev; - - // - bool isSCHHSwitchedToBullish = isSCHHBullish && - !isSCHHBullishPrev; - bool isSCLLSwitchedToBullish = isSCLLBullish && - !isSCLLBullishPrev; - - // - bool isSCHHBearish = conditions.pvSCHHs[cIndex] < conditions.pvSCHHs[pIndex]; - bool isSCLLBearish = conditions.pvSCLLs[cIndex] < conditions.pvSCLLs[pIndex]; - - // - bool isSCHHBearishPrev = conditions.pvSCHHs[pIndex] < conditions.pvSCHHs[ppIndex]; - bool isSCLLBearishPrev = conditions.pvSCLLs[pIndex] < conditions.pvSCLLs[ppIndex]; - - // - bool isSCBearish = isSCHHBearish && - isSCLLBearish; - - // - bool isSCBearishPrev = isSCHHBearishPrev && - isSCLLBearishPrev; - - // - bool isSCHHSwitchedToBearish = isSCHHBearish && - !isSCHHBearishPrev; - bool isSCLLSwitchedToBeraish = isSCLLBearish && - !isSCLLBearishPrev; - - // - bool isSCSwitchedToBullish = - // - (isSCHHSwitchedToBullish && - !isSCLLBearish) - // - || - // - (isSCLLSwitchedToBullish && - !isSCHHBearish) - // - ; - - // - bool isSCSwitchedToBearish = - // - (isSCHHSwitchedToBearish && - !isSCLLBullish) - // - || - // - (isSCLLSwitchedToBeraish && - !isSCHHBullish) - // - ; - - // - // MC ... - - // - bool isMCHHBullish = conditions.pvMCHHs[cIndex] > conditions.pvMCHHs[pIndex]; - bool isMCLLBullish = conditions.pvMCLLs[cIndex] > conditions.pvMCLLs[pIndex]; - - // - bool isMCHHBullishPrev = conditions.pvMCHHs[pIndex] > conditions.pvMCHHs[ppIndex]; - bool isMCLLBullishPrev = conditions.pvMCLLs[pIndex] > conditions.pvMCLLs[ppIndex]; - - // - bool isMCBullish = isMCHHBullish && - isMCLLBullish; - - // - bool isMCBullishPrev = isMCHHBullishPrev && - isMCLLBullishPrev; - - // - bool isMCHHSwitchedToBullish = isMCHHBullish && - !isMCHHBullishPrev; - bool isMCLLSwitchedToBullish = isMCLLBullish && - !isMCLLBullishPrev; - - // - bool isMCHHBearish = conditions.pvMCHHs[cIndex] < conditions.pvMCHHs[pIndex]; - bool isMCLLBearish = conditions.pvMCLLs[cIndex] < conditions.pvMCLLs[pIndex]; - - // - bool isMCHHBearishPrev = conditions.pvMCHHs[pIndex] < conditions.pvMCHHs[ppIndex]; - bool isMCLLBearishPrev = conditions.pvMCLLs[pIndex] < conditions.pvMCLLs[ppIndex]; - - // - bool isMCBearish = isMCHHBearish && - isMCLLBearish; - - // - bool isMCBearishPrev = isMCHHBearishPrev && - isMCLLBearishPrev; - - // - bool isMCHHSwitchedToBearish = isMCHHBearish && - !isMCHHBearishPrev; - bool isMCLLSwitchedToBeraish = isMCLLBearish && - !isMCLLBearishPrev; - - // - bool isMCSwitchedToBullish = - // - (isMCHHSwitchedToBullish && - !isMCLLBearish) - // - || - // - (isMCLLSwitchedToBullish && - !isMCHHBearish) - // - ; - - // - bool isMCSwitchedToBearish = - // - (isMCHHSwitchedToBearish && - !isMCLLBullish) - // - || - // - (isMCLLSwitchedToBeraish && - !isMCHHBullish) - // - ; - - // - // LC ... - - // - bool isLCHHBullish = conditions.pvLCHHs[cIndex] > conditions.pvLCHHs[pIndex]; - bool isLCLLBullish = conditions.pvLCLLs[cIndex] > conditions.pvLCLLs[pIndex]; - - // - bool isLCHHBullishPrev = conditions.pvLCHHs[pIndex] > conditions.pvLCHHs[ppIndex]; - bool isLCLLBullishPrev = conditions.pvLCLLs[pIndex] > conditions.pvLCLLs[ppIndex]; - - // - bool isLCBullish = isLCHHBullish && - isLCLLBullish; - - // - bool isLCBullishPrev = isLCHHBullishPrev && - isLCLLBullishPrev; - - // - bool isLCHHSwitchedToBullish = isLCHHBullish && - !isLCHHBullishPrev; - bool isLCLLSwitchedToBullish = isLCLLBullish && - !isLCLLBullishPrev; - - // - bool isLCHHBearish = conditions.pvLCHHs[cIndex] < conditions.pvLCHHs[pIndex]; - bool isLCLLBearish = conditions.pvLCLLs[cIndex] < conditions.pvLCLLs[pIndex]; - - // - bool isLCHHBearishPrev = conditions.pvLCHHs[pIndex] < conditions.pvLCHHs[ppIndex]; - bool isLCLLBearishPrev = conditions.pvLCLLs[pIndex] < conditions.pvLCLLs[ppIndex]; - - // - bool isLCBearish = isLCHHBearish && - isLCLLBearish; - - // - bool isLCBearishPrev = isLCHHBearishPrev && - isLCLLBearishPrev; - - // - bool isLCHHSwitchedToBearish = isLCHHBearish && - !isLCHHBearishPrev; - bool isLCLLSwitchedToBeraish = isLCLLBearish && - !isLCLLBearishPrev; - - // - bool isLCSwitchedToBullish = - // - (isLCHHSwitchedToBullish && - !isLCLLBearish) - // - || - // - (isLCLLSwitchedToBullish && - !isLCHHBearish) - // - ; - - // - bool isLCSwitchedToBearish = - // - (isLCHHSwitchedToBearish && - !isLCLLBullish) - // - || - // - (isLCLLSwitchedToBeraish && - !isLCHHBullish) - // - ; - - // - // HC ... - - // - bool isHCHHBullish = conditions.pvHCHHs[cIndex] > conditions.pvHCHHs[pIndex]; - bool isHCLLBullish = conditions.pvHCLLs[cIndex] > conditions.pvHCLLs[pIndex]; - - // - bool isHCHHBullishPrev = conditions.pvHCHHs[pIndex] > conditions.pvHCHHs[ppIndex]; - bool isHCLLBullishPrev = conditions.pvHCLLs[pIndex] > conditions.pvHCLLs[ppIndex]; - - // - bool isHCBullish = isHCHHBullish && - isHCLLBullish; - - // - bool isHCBullishPrev = isHCHHBullishPrev && - isHCLLBullishPrev; - - // - bool isHCHHSwitchedToBullish = isHCHHBullish && - !isHCHHBullishPrev; - bool isHCLLSwitchedToBullish = isHCLLBullish && - !isHCLLBullishPrev; - - // - bool isHCHHBearish = conditions.pvHCHHs[cIndex] < conditions.pvHCHHs[pIndex]; - bool isHCLLBearish = conditions.pvHCLLs[cIndex] < conditions.pvHCLLs[pIndex]; - - // - bool isHCHHBearishPrev = conditions.pvHCHHs[pIndex] < conditions.pvHCHHs[ppIndex]; - bool isHCLLBearishPrev = conditions.pvHCLLs[pIndex] < conditions.pvHCLLs[ppIndex]; - - // - bool isHCBearish = isHCHHBearish && - isHCLLBearish; - - // - bool isHCBearishPrev = isHCHHBearishPrev && - isHCLLBearishPrev; - - // - bool isHCHHSwitchedToBearish = isHCHHBearish && - !isHCHHBearishPrev; - bool isHCLLSwitchedToBeraish = isHCLLBearish && - !isHCLLBearishPrev; - - // - bool isHCSwitchedToBullish = - // - (isHCHHSwitchedToBullish && - !isHCLLBearish) - // - || - // - (isHCLLSwitchedToBullish && - !isHCHHBearish) - // - ; - - // - bool isHCSwitchedToBearish = - // - (isHCHHSwitchedToBearish && - !isHCLLBullish) - // - || - // - (isHCLLSwitchedToBeraish && - !isHCHHBullish) - // - ; - - // - // Setting Conditional Variables ... - - // - conditions.isLastBullish = isLastBullish; - conditions.isLastBearish = isLastBearish; - conditions.isCurrentBullish = isCurrentBullish; - conditions.isCurrentBearish = isCurrentBearish; - conditions.isCurrentMidLineOverLastHigh = isCurrentMidLineOverLastHigh; - conditions.isCurrentMidLineUnderLastLow = isCurrentMidLineUnderLastLow; - conditions.isCurrentMidLineOverLastUp = isCurrentMidLineOverLastUp; - conditions.isCurrentMidLineUnderLastDown = isCurrentMidLineUnderLastDown; - conditions.isCurrentMidLineOverLastMidLine = isCurrentMidLineOverLastMidLine; - conditions.isCurrentMidLineUnderLastMidLine = isCurrentMidLineUnderLastMidLine; - - // - conditions.isASCTLong = isASCTLong; - conditions.isASCTShort = isASCTShort; - - // - conditions.isSSLCBullish = isSSLCBullish; - conditions.isSSLCBearish = isSSLCBearish; - conditions.isSSLCSwitchedToBullish = isSSLCSwitchedToBullish; - conditions.isSSLCSwitchedToBearish = isSSLCSwitchedToBearish; - - // - conditions.isHullBullish = isHullBullish; - conditions.isHullBearish = isHullBearish; - conditions.isHullUpBullish = isHullUpBullish; - conditions.isHullUpBearish = isHullUpBearish; - conditions.isHullDownBullish = isHullDownBullish; - conditions.isHullDownBearish = isHullDownBearish; - conditions.isHullSwitchedToBullish = isHullSwitchedToBullish; - conditions.isHullSwitchedToBearish = isHullSwitchedToBearish; - - // - conditions.isHKBullish = isHKBullish; - conditions.isHKBearish = isHKBearish; - conditions.isClosedOverHK = isClosedOverHK; - conditions.isClosedUnderHK = isClosedUnderHK; - conditions.isHKSwitchedToBullish = isHKSwitchedToBullish; - conditions.isHKSwitchedToBearish = isHKSwitchedToBearish; - - // - conditions.isSMHKBullish = isSMHKBullish; - conditions.isSMHKBearish = isSMHKBearish; - conditions.isClosedOverSMHK = isClosedOverSMHK; - conditions.isClosedUnderSMHK = isClosedUnderSMHK; - conditions.isSMHKSwitchedToBullish = isSMHKSwitchedToBullish; - conditions.isSMHKSwitchedToBearish = isSMHKSwitchedToBearish; - - // - conditions.isClosedOverKijunSen = isClosedOverKijunSen; - conditions.isClosedUnderKijunSen = isClosedUnderKijunSen; - conditions.isTenkanSenOverKijunSen = isTenkanSenOverKijunSen; - conditions.isTenkanSenUnderKijunSen = isTenkanSenUnderKijunSen; - conditions.isTenkanSenCrossedOverKijunSen = isTenkanSenCrossedOverKijunSen; - conditions.isTenkanSenCrossedUnderKijunSen = isTenkanSenCrossedUnderKijunSen; - - // - conditions.isSenkouSpanAOverB = isSenkouSpanAOverB; - conditions.isSenkouSpanAUnderB = isSenkouSpanAUnderB; - conditions.isSenkouSpanAOverLast = isSenkouSpanAOverLast; - conditions.isSenkouSpanAUnderLast = isSenkouSpanAUnderLast; - conditions.isFutureSenkouSpanAOverB = isFutureSenkouSpanAOverB; - conditions.isFutureSenkouSpanAUnderB = isFutureSenkouSpanAUnderB; - conditions.isFutureSenkouSpanAOverLast = isFutureSenkouSpanAOverLast; - conditions.isFutureSenkouSpanAUnderLast = isFutureSenkouSpanAUnderLast; - - // - conditions.isSenkouSpanACrossedOverB = isSenkouSpanACrossedOverB; - conditions.isSenkouSpanACrossedUnderB = isSenkouSpanACrossedUnderB; - conditions.isSenkouSpanACrossedOverLast = isSenkouSpanACrossedOverLast; - conditions.isSenkouSpanACrossedUnderLast = isSenkouSpanACrossedUnderLast; - conditions.isFutureSenkouSpanACrossedOverB = isFutureSenkouSpanACrossedOverB; - conditions.isFutureSenkouSpanACrossedUnderB = isFutureSenkouSpanACrossedUnderB; - conditions.isFutureSenkouSpanACrossedOverLast = isFutureSenkouSpanACrossedOverLast; - conditions.isFutureSenkouSpanACrossedUnderLast = isFutureSenkouSpanACrossedUnderLast; - - // - conditions.isMCFastOverSlow = isMCFastOverSlow; - conditions.isMCFastUnderSlow = isMCFastUnderSlow; - conditions.isMCFastOverVerifier = isMCFastOverVerifier; - conditions.isMCFastUnderVerifier = isMCFastUnderVerifier; - conditions.isMCSlowOverVerifier = isMCSlowOverVerifier; - conditions.isMCSlowUnderVerifier = isMCSlowUnderVerifier; - conditions.isMCFastCrossedOverSlow = isMCFastCrossedOverSlow; - conditions.isMCFastCrossedUnderSlow = isMCFastCrossedUnderSlow; - conditions.isMCFastCrossedOverVerifier = isMCFastCrossedOverVerifier; - conditions.isMCFastCrossedUnderVerifier = isMCFastCrossedUnderVerifier; - conditions.isMCSlowCrossedOverVerifier = isMCSlowCrossedOverVerifier; - conditions.isMCSlowCrossedUnderVerifier = isMCSlowCrossedUnderVerifier; - - // - conditions.isTrendBullish = isTrendBullish; - conditions.isTrendBearish = isTrendBearish; - conditions.isTrendSwitchedToBullish = isTrendSwitchedToBullish; - conditions.isTrendSwitchedToBearish = isTrendSwitchedToBearish; - - // - conditions.isZigZagInPeak = isZigZagInPeak; - conditions.isZigZagInVale = isZigZagInVale; - - // - conditions.isMRBFastOverSlow = isMRBFastOverSlow; - conditions.isMRBFastUnderSlow = isMRBFastUnderSlow; - conditions.isMRBFastCrossedOverSlow = isMRBFastCrossedOverSlow; - conditions.isMRBFastCrossedUnderSlow = isMRBFastCrossedUnderSlow; - conditions.isMRBFastOverVerifier = isMRBFastOverVerifier; - conditions.isMRBFastUnderVerifier = isMRBFastUnderVerifier; - conditions.isMRBFastCrossedtOverVerifier = isMRBFastCrossedtOverVerifier; - conditions.isMRBFastCrossedUnderVerifier = isMRBFastCrossedUnderVerifier; - conditions.isMRBSlowOverVerifier = isMRBSlowOverVerifier; - conditions.isMRBSlowUnderVerifier = isMRBSlowUnderVerifier; - conditions.isMRBSlowCrossedtOverVerifier = isMRBSlowCrossedtOverVerifier; - conditions.isMRBSlowCrossedUnderVerifier = isMRBSlowCrossedUnderVerifier; - - // - conditions.isCHEBullish = isCHEBullish; - conditions.isCHEBearish = isCHEBearish; - conditions.isCHESwitchedToBullish = isCHESwitchedToBullish; - conditions.isCHESwitchedToBearish = isCHESwitchedToBearish; - - // - conditions.isTDBullish = isTDBullish; - conditions.isTDBearish = isTDBearish; - conditions.isTDSwitchedToBullish = isTDSwitchedToBullish; - conditions.isTDSwitchedToBearish = isTDSwitchedToBearish; - - // - conditions.isDONAttachedMaxLower = isDONAttachedMaxLower; - conditions.isDONAttachedMinLower = isDONAttachedMinLower; - conditions.isDONCrossedOverMaxLower = isDONCrossedOverMaxLower; - conditions.isDONCrossedUnderMaxLower = isDONCrossedUnderMaxLower; - conditions.isDONCrossedOverMinLower = isDONCrossedOverMinLower; - conditions.isDONCrossedUnderMinLower = isDONCrossedUnderMinLower; - - // - conditions.isDONAttachedMaxUpper = isDONAttachedMaxUpper; - conditions.isDONAttachedMinUpper = isDONAttachedMinUpper; - conditions.isDONCrossedOverMaxUpper = isDONCrossedOverMaxUpper; - conditions.isDONCrossedUnderMaxUpper = isDONCrossedUnderMaxUpper; - conditions.isDONCrossedOverMinUpper = isDONCrossedOverMinUpper; - conditions.isDONCrossedUnderMinUpper = isDONCrossedUnderMinUpper; - - // - conditions.isNewPeak = isNewPeak; - conditions.isNewPeakOverLast = isNewPeakOverLast; - conditions.isNewPeakUnderLast = isNewPeakUnderLast; - - // - conditions.isNewVale = isNewVale; - conditions.isNewValeOverLast = isNewValeOverLast; - conditions.isNewValeUnderLast = isNewValeUnderLast; - - // - conditions.isFiboIncreased = isFiboIncreased; - conditions.isFiboDecreased = isFiboDecreased; - conditions.isFiboSectionChanged = isFiboSectionChanged; - - // - conditions.isSCBullish = isSCBullish; - conditions.isSCHHBullish = isSCHHBullish; - conditions.isSCLLBullish = isSCLLBullish; - conditions.isSCSwitchedToBullish = isSCSwitchedToBullish; - conditions.isSCHHSwitchedToBullish = isSCHHSwitchedToBullish; - conditions.isSCLLSwitchedToBullish = isSCLLSwitchedToBullish; - - // - conditions.isSCBearish = isSCBearish; - conditions.isSCHHBearish = isSCHHBearish; - conditions.isSCLLBearish = isSCLLBearish; - conditions.isSCSwitchedToBearish = isSCSwitchedToBearish; - conditions.isSCHHSwitchedToBearish = isSCHHSwitchedToBearish; - conditions.isSCLLSwitchedToBeraish = isSCLLSwitchedToBeraish; - - // - conditions.isMCBullish = isMCBullish; - conditions.isMCHHBullish = isMCHHBullish; - conditions.isMCLLBullish = isMCLLBullish; - conditions.isMCSwitchedToBullish = isMCSwitchedToBullish; - conditions.isMCHHSwitchedToBullish = isMCHHSwitchedToBullish; - conditions.isMCLLSwitchedToBullish = isMCLLSwitchedToBullish; - - // - conditions.isMCBearish = isMCBearish; - conditions.isMCHHBearish = isMCHHBearish; - conditions.isMCLLBearish = isMCLLBearish; - conditions.isMCSwitchedToBearish = isMCSwitchedToBearish; - conditions.isMCHHSwitchedToBearish = isMCHHSwitchedToBearish; - conditions.isMCLLSwitchedToBeraish = isMCLLSwitchedToBeraish; - - // - conditions.isLCBullish = isLCBullish; - conditions.isLCHHBullish = isLCHHBullish; - conditions.isLCLLBullish = isLCLLBullish; - conditions.isLCSwitchedToBullish = isLCSwitchedToBullish; - conditions.isLCHHSwitchedToBullish = isLCHHSwitchedToBullish; - conditions.isLCLLSwitchedToBullish = isLCLLSwitchedToBullish; - - // - conditions.isLCBearish = isLCBearish; - conditions.isLCHHBearish = isLCHHBearish; - conditions.isLCLLBearish = isLCLLBearish; - conditions.isLCSwitchedToBearish = isLCSwitchedToBearish; - conditions.isLCHHSwitchedToBearish = isLCHHSwitchedToBearish; - conditions.isLCLLSwitchedToBeraish = isLCLLSwitchedToBeraish; - - // - conditions.isHCBullish = isHCBullish; - conditions.isHCHHBullish = isHCHHBullish; - conditions.isHCLLBullish = isHCLLBullish; - conditions.isHCSwitchedToBullish = isHCSwitchedToBullish; - conditions.isHCHHSwitchedToBullish = isHCHHSwitchedToBullish; - conditions.isHCLLSwitchedToBullish = isHCLLSwitchedToBullish; - - // - conditions.isHCBearish = isHCBearish; - conditions.isHCHHBearish = isHCHHBearish; - conditions.isHCLLBearish = isHCLLBearish; - conditions.isHCSwitchedToBearish = isHCSwitchedToBearish; - conditions.isHCHHSwitchedToBearish = isHCHHSwitchedToBearish; - conditions.isHCLLSwitchedToBeraish = isHCLLSwitchedToBeraish; - } - - // - // Initial Market Cycle ... - bool Init( - X121MCycleInputs &inputs // Inputs for Initialization - ) - { - // - bool result = false; - - // - // Validate Input ... - result = inputs.IsValid(); - if (!result) - { - return result; - } - - // - mInputs = inputs; - - // - string symbol = mInputs.cycle.symbol; - ENUM_TIMEFRAMES period = mInputs.cycle.period; - - // - // Init Helpers ... - - // - // XASCT ... - result = asct.Init( - symbol, - period, - mInputs.asctInputs - // - ); - if (!result) - { - return result; - } - - // - // XHULL ... - result = hull.Init( - symbol, - period, - mInputs.hullInputs - // - ); - if (!result) - { - return result; - } - - // - // XSSLC ... - result = sslc.Init( - symbol, - period, - mInputs.sslcInputs - // - ); - if (!result) - { - return result; - } - - // - // XHK ... - result = hk.Init( - symbol, - period, - mInputs.hkInputs - // - ); - if (!result) - { - return result; - } - - // - // XMC ... - result = mc.Init( - symbol, - period, - mInputs.mcInputs - // - ); - if (!result) - { - return result; - } - - // - // XPV ... - result = pv.Init( - symbol, - period, - mInputs.pvInputs - // - ); - if (!result) - { - return result; - } - - // - // XZG ... - result = zg.Init( - symbol, - period, - mInputs.zgInputs - // - ); - if (!result) - { - return result; - } - - // - // XTD ... - result = td.Init( - symbol, - period, - mInputs.tdInputs - // - ); - if (!result) - { - return result; - } - - // - // XMRB ... - result = mrb.Init( - symbol, - period, - mInputs.mrbInputs - // - ); - if (!result) - { - return result; - } - - // - // XSTR ... - result = str.Init( - symbol, - period, - mInputs.strInputs - // - ); - if (!result) - { - return result; - } - - // - // XCHE ... - result = che.Init( - symbol, - period, - mInputs.cheInputs - // - ); - if (!result) - { - return result; - } - - // - // XOSC ... - result = osc.Init( - symbol, - period, - mInputs.oscInputs - // - ); - if (!result) - { - return result; - } - - // - // XICH ... - result = ich.Init( - symbol, - period, - mInputs.ichInputs - // - ); - if (!result) - { - return result; - } - - // - // XDON ... - result = don.Init( - symbol, - period, - mInputs.donInputs - // - ); - if (!result) - { - return result; - } - - // - return result; - } - - // - // Draw Tools ... - // - // Completely Draw Bars ... - void Draw( - long chartID, // Chart ID ... - int subWindow, // Chart Sub Window ... - int &offset // Distance used for Labels ... - ) - { - // - if (mInputs.drawCBar || mInputs.drawPBar) - { - // - DrawOHCL( - chartID, - subWindow, - mInputs.drawLabels, - !mInputs.drawCBar && mInputs.drawPBar, - !mInputs.drawPBar && mInputs.drawCBar, - offset - // - ); - - // - if (mInputs.drawLabels) - { - offset += 3; - } - } - - // - if (mInputs.drawCBarMid || mInputs.drawPBarMid) - { - // - DrawMidLine( - chartID, - subWindow, - mInputs.drawLabels, - !mInputs.drawCBarMid && mInputs.drawPBarMid, - !mInputs.drawPBarMid && mInputs.drawCBarMid, - offset - // - ); - - // - if (mInputs.drawLabels) - { - // - if (mInputs.drawCBarMid) - { - offset++; - } - - // - if (mInputs.drawPBarMid) - { - offset++; - } - } - } - } - - // - // Draw Functions ... - // - // Draw Middle Line of Cycle ... - void DrawOHCL( - long chartID, - int subWindow, - bool drawLabel = false, // Specify Draw Label of Mid Line or not ... - bool drawOnlyPrev = false, // Specify Draw Only Prev Bar of Cycle ... - bool drawOnlyCurrent = false, // Specify Draw Only Current Bar of Cycle ... - int offset = 0 // Distance used for Labels ... - ) - { - // - if (offset < 0) - { - offset = 0; - } - - // - string baseTag = ToString(mInputs.cycle.cycle); - - // - XOHCL cBar = GetBar(0); - XOHCL pBar = GetBar(1); - - // - datetime fromCDate = GetBarTime(0); - datetime fromPDate = GetBarTime(1); - - // - datetime cTime = TimeCurrent(); - - // - // Try to Draw ... - - // - bool canDrawPrev = !drawOnlyCurrent; - bool canDrawCurrent = !drawOnlyPrev; - - // - // Set Cycles Color based on Current Candle ... - - // - bool isCBarBullish = - cBar.IsBullish(); - - // - bool isPBarBullish = - pBar.IsBearish(); - - // - color clrTemoBullishColor = mInputs.cBarDrawSpecs.openStyle.clr; - color clrTemoBearishColor = mInputs.cBarDrawSpecs.closeStyle.clr; - - // - color cBarSelectedColor = isCBarBullish ? clrTemoBullishColor : clrTemoBearishColor; - color pBarSelectedColor = isPBarBullish ? clrTemoBullishColor : clrTemoBearishColor; - - // - mInputs.cBarDrawSpecs.openStyle.clr = cBarSelectedColor; - mInputs.cBarDrawSpecs.openStyle.labelColor = cBarSelectedColor; - - // - mInputs.cBarDrawSpecs.closeStyle.clr = cBarSelectedColor; - mInputs.cBarDrawSpecs.closeStyle.labelColor = cBarSelectedColor; - - // - mInputs.pBarDrawSpecs.openStyle.clr = pBarSelectedColor; - mInputs.pBarDrawSpecs.openStyle.labelColor = pBarSelectedColor; - - // - mInputs.pBarDrawSpecs.closeStyle.clr = pBarSelectedColor; - mInputs.pBarDrawSpecs.closeStyle.labelColor = pBarSelectedColor; - - // - if (canDrawPrev) - { - offset++; - } - - // - // Label ... - if (drawLabel) - { - // - if (canDrawPrev) - { - // - // Draw Prev Bar Lables ... - - // - DrawXOHCLLabel( - chartID, - subWindow, - pBar, - mInputs.pBarDrawSpecs, - "P", - cTime, - offset - 1 - // - ); - - // - offset += 3; - } - - // - if (canDrawCurrent) - { - // - // Draw Current Bar Lables ... - - // - DrawXOHCLLabel( - chartID, - subWindow, - cBar, - mInputs.cBarDrawSpecs, - "C", - cTime, - offset - // - ); - } - } - - // - // Line ... - - // - if (canDrawPrev) - { - // - // Draw Cycle Prev Bar ... - DrawXOHCLContent( - chartID, - subWindow, - pBar, - mInputs.pBarDrawSpecs, - "P", - fromPDate - // - ); - } - - // - if (canDrawCurrent) - { - // - // Draw Cycle Current Bar ... - DrawXOHCLContent( - chartID, - subWindow, - cBar, - mInputs.cBarDrawSpecs, - "C", - fromCDate - // - ); - } - } - - // - // Draw Middle Line of Cycle ... - void DrawMidLine( - long chartID, - int subWindow, - bool drawLabel = false, // Specify Draw Label of Mid Line or not ... - bool drawOnlyPrev = false, // Specify Draw Only Prev Bar of Cycle ... - bool drawOnlyCurrent = false, // Specify Draw Only Current Bar of Cycle ... - int offset = 0 // Distance used for Labels ... - ) - { - // - if (offset < 0) - { - offset = 0; - } - - // - // Calculate Mid Line ... - XOHCL cBar = GetBar(0); - double cMidLine = cBar.GetMid(); - - // - XOHCL pBar = GetBar(1); - double pMidLine = pBar.GetMid(); - - // - string baseTag = ToString(mInputs.cycle.cycle); - - // - string midCTag = baseTag + "|MID|C|"; - string midPTag = baseTag + "|MID|P|"; - - // - string midCLblTag = midCTag + "lbl"; - string midPLblTag = midPTag + "lbl"; - - // - datetime fromCDate = GetBarTime(0); - datetime fromPDate = GetBarTime(1); - - // - datetime cTime = TimeCurrent(); - - // - // Try to Draw ... - - // - bool canDrawPrev = !drawOnlyCurrent; - bool canDrawCurrent = !drawOnlyPrev; - - // - if (canDrawPrev) - { - offset++; - } - - // - // Label ... - if (drawLabel) - { - // - if (canDrawPrev) - { - // - // Draw Prev Candle MidLine Lable ... - DrawLabel( - chartID, - subWindow, - mInputs.pBarMidDrawSpecs, - midPLblTag, - cTime, - pMidLine, - offset // - ); - } - - // - if (canDrawCurrent) - { - // - // Draw Current Candle MidLine Label ... - DrawLabel( - chartID, - subWindow, - mInputs.cBarMidDrawSpecs, - midCLblTag, - cTime, - cMidLine, - offset - 1 // - ); - } - } - - // - // Line ... - - // - if (canDrawPrev) - { - // - // Draw Prev Candle MidLine ... - DrawLine( - chartID, - subWindow, - mInputs.pBarMidDrawSpecs, - midPTag, - fromPDate, - pMidLine // - ); - } - - // - if (canDrawCurrent) - { - // - // Draw Current Candle MidLine ... - DrawLine( - chartID, - subWindow, - mInputs.cBarMidDrawSpecs, - midCTag, - fromCDate, - cMidLine // - ); - } - } - - // - // Protected ... -protected: - // - // Private ... -private: - // - // Props ... - - // - X121MCycleInputs mInputs; - - // - // Tools ... - - // - bool Update(int hostBarIndex = 0) - { - return mInputs.cycle.Update(hostBarIndex); - } - - // - // Draw Functions ... - - // - // Draw OHCL Labels ... - void DrawXOHCLLabel( - long chartID, - int subWindow, - XOHCL &bar, // Specify Cycle XOHCL Model to Draw ... - XOHCLDrawSpecification &specs, // Specify Cycle XOHCL Draw Specifications ... - string baseTag, // Specify a Unique Tag ... - datetime time, // Draw Time ... - int offset = 0 // - ) - { - // - // Open ... - string openTag = mInputs.cycle.prefix + "_" + baseTag + "_O_lbl"; - DrawLabel( - chartID, - subWindow, - specs.openStyle, - openTag, - time, - bar.open, - offset - // - ); - - // - // High ... - string highTag = mInputs.cycle.prefix + "_" + baseTag + "_H_lbl"; - DrawLabel( - chartID, - subWindow, - specs.highStyle, - highTag, - time, - bar.high, - offset + 1 - // - ); - - // - // Close ... - string closeTag = mInputs.cycle.prefix + "_" + baseTag + "_C_lbl"; - DrawLabel( - chartID, - subWindow, - specs.closeStyle, - closeTag, - time, - bar.close, - offset + 2 - // - ); - - // - // Low ... - string lowTag = mInputs.cycle.prefix + "_" + baseTag + "_L_lbl"; - DrawLabel( - chartID, - subWindow, - specs.lowStyle, - lowTag, - time, - bar.low, - offset + 3 - // - ); - } - - // - // Draw XOHCL Content ... - void DrawXOHCLContent( - long chartID, - int subWindow, - XOHCL &bar, // Specify Cycle XOHCL Model to Draw ... - XOHCLDrawSpecification &specs, // Specify Cycle XOHCL Draw Specifications ... - string baseTag, // Specify a Unique Tag ... - datetime time // Draw Time ... - ) - { - // - // Open ... - string openTag = mInputs.cycle.prefix + "_" + baseTag + "_O"; - DrawLine( - chartID, - subWindow, - specs.openStyle, - openTag, - time, - bar.open - // - ); - - // - // High ... - string highTag = mInputs.cycle.prefix + "_" + baseTag + "_H"; - DrawLine( - chartID, - subWindow, - specs.highStyle, - highTag, - time, - bar.high - // - ); - - // - // Close ... - string closeTag = mInputs.cycle.prefix + "_" + baseTag + "_C"; - DrawLine( - chartID, - subWindow, - specs.closeStyle, - closeTag, - time, - bar.close - // - ); - - // - // Low ... - string lowTag = mInputs.cycle.prefix + "_" + baseTag + "_L"; - DrawLine( - chartID, - subWindow, - specs.lowStyle, - lowTag, - time, - bar.low - // - ); - } - - // - // Draw Label Using Specifications ... - void DrawLabel( - long chartID, - int subWindow, - XDrawSpecifications &specs, - string tag, - datetime time, - double price, - int offset = 0 // - ) - { - // - if (offset < 0) - { - offset = 0; - } - - // - int offsetSeconds = PeriodSeconds(mInputs.cycle.hostPeriod) * offset; - - // - string value = specs.label; - - // - DrawText( - chartID, - tag, - subWindow, - time - offsetSeconds, - price, - specs.label, - specs.labelFont, - specs.labelFontSize, - specs.labelColor, - specs.labelAngel, - specs.labelAnchor, - specs.back, - specs.selection, - specs.hidden, - specs.zOrder // - ); - } - - // - // Draw TrendLine Using Specifications ... - void DrawLine( - long chartID, - int subWindow, - XDrawSpecifications &specs, - string tag, - datetime fromDate, - double fromPrice, - datetime toDate = NULL, - double toPrice = 0 // - ) - { - // - if (toPrice <= 0) - { - toPrice = fromPrice; - } - - // - if (toDate == 0 || toDate == NULL) - { - toDate = TimeCurrent(); - } - - // - DrawTrendLine( - chartID, - tag, - subWindow, - fromDate, - fromPrice, - toDate, - toPrice, - specs.clr, - specs.style, - specs.width, - specs.back, - specs.selection, - specs.rayRight, - specs.hidden, - specs.zOrder // - ); - } -}; - -// -// Tools ... - -// -struct X121MarketCycleDescriptor -{ - // - string symbol; // Trading Symbol - ENUM_TIMEFRAMES hostPeriod; // Host Period - ENUM_X_MARKET_CYCLES cycle; // Init Cycle - ENUM_TIMEFRAMES period; // Cycle Period - ENUM_X_PERIOD_METHOD periodMethod; // Cycle Period Method - string prefix; // Prefix - bool useDefaults; // Use Inputs Default Settings ... - - // - X121MCycleInputs inputs; // Inputs - - // - XSCX121Market *market; // Market - - // - // Tools ... - - // - bool Init() - { - // - bool result = false; - - // - result = inputs.Init( - symbol, - hostPeriod, - cycle, - period, - periodMethod, - prefix, - useDefaults // - ); - if (!result) - { - return result; - } - - // - - // - // Instantiate Market ... - market = new XSCX121Market(); - - // - // Initialize Market ... - result = market.Init(inputs); - - // - return result; - } - - // - bool Init( - string mSymbol, // Trading Symbol - ENUM_TIMEFRAMES mHostPeriod, // Host Period - ENUM_X_MARKET_CYCLES mCycle, // Init Cycle - ENUM_TIMEFRAMES mPeriod, // Cycle Period - ENUM_X_PERIOD_METHOD mPeriodMethod, // Cycle Period Method - string mPrefix = "", // Prefix - bool mUseDefaults = true // Use Inputs Default Settings ... - ) - { - // - bool result = false; - - // - result = - // - IsValid(mSymbol) && - IsValid(mHostPeriod) && - IsValid(mPeriodMethod, mPeriod) - // - ; - if (!result) - { - return result; - } - - // - this.cycle = mCycle; - this.symbol = mSymbol; - this.period = mPeriod; - this.prefix = mPrefix; - this.hostPeriod = mHostPeriod; - this.useDefaults = mUseDefaults; - this.periodMethod = mPeriodMethod; - - // - result = this.Init(); - - // - return result; - } -}; - -// -// Custom Draws ... - -// -// Custom Struct Draws ... -bool DrawSupRes( - XOHCLSupRes &item, // Struct item to Draw ... - XDrawSpecifications &supSpecs, // Supports specs ... - XDrawSpecifications &resSpecs, // Resistances specs ... - long chartID = 0, - int subWindow = 0, - string prefix = "SupRes" // -) -{ - // - bool result = false; - - // - result = item.IsValid(); - if (!result) - { - return result; - } - - // - datetime cTime = TimeCurrent(); - datetime pTime = TimeCurrent() - PeriodSeconds(PERIOD_M10); - - // - // Support ... - int supCount = item.CountSupports(); - bool canDrawSups = IsValidSize(supCount) && supSpecs.draw; - if (canDrawSups) - { - // - for (int i = 0; i < supCount; i++) - { - // - double iSup = item.sup[i]; - - // - string supName = prefix + "_" + "Sup_" + ToString(iSup); - - // - DrawTrendLine( - chartID, - supName, - subWindow, - pTime, - iSup, - cTime, - iSup, - supSpecs.clr, - supSpecs.style, - supSpecs.width, - supSpecs.back, - supSpecs.selection, - supSpecs.rayRight, - supSpecs.hidden, - supSpecs.zOrder // - ); - - // - if (IsValid(supSpecs.label)) - { - // - DrawText( - chartID, - supName + "_lbl", - subWindow, - cTime, - iSup, - supSpecs.label, - supSpecs.labelFont, - supSpecs.labelFontSize, - supSpecs.labelColor, - supSpecs.labelAngel, - supSpecs.labelAnchor, - supSpecs.back, - supSpecs.selection, - supSpecs.hidden, - supSpecs.zOrder // - ); - } - } - } - - // - // Resistance ... - int resCount = item.CountResistances(); - bool canDrawRess = IsValidSize(supCount) && supSpecs.draw; - if (canDrawRess) - { - // - for (int i = 0; i < resCount; i++) - { - // - double iRes = item.res[i]; - - // - string resName = prefix + "_" + "Res_" + ToString(iRes); - - // - DrawTrendLine( - chartID, - resName, - subWindow, - pTime, - iRes, - cTime, - iRes, - resSpecs.clr, - resSpecs.style, - resSpecs.width, - resSpecs.back, - resSpecs.selection, - resSpecs.rayRight, - resSpecs.hidden, - resSpecs.zOrder // - ); - - // - if (IsValid(resSpecs.label)) - { - // - DrawText( - chartID, - resName + "_lbl", - subWindow, - cTime, - iRes, - resSpecs.label, - resSpecs.labelFont, - resSpecs.labelFontSize, - resSpecs.labelColor, - resSpecs.labelAngel, - resSpecs.labelAnchor, - resSpecs.back, - resSpecs.selection, - resSpecs.hidden, - resSpecs.zOrder // - ); - } - } - } - - // - result = canDrawSups || canDrawRess; - - // - return result; -} - -// \ No newline at end of file diff --git a/Classes/x-saherelm.xdata-collector.class.mq5 b/Classes/x-saherelm.xdata-collector.class.mq5 deleted file mode 100644 index 81608659..00000000 --- a/Classes/x-saherelm.xdata-collector.class.mq5 +++ /dev/null @@ -1,481 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Class Library -// ---------------------------------------------- -// Name: XSCDataCollector -// Description: provides Data Collection 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.base.class.mq5" - -// -template -class XSCDataCollector : public XSCBase -{ - // - // Public ... -public: - // - // Props ... - - // - // Constructors ... - void XSCDataCollector( - string path = NULL, // Base Folder for Data Store - string fileName = NULL // File Name for Data Store - ) - { - // - if (!IsValid(path)) - { - path = GetType(); - } - - // - if (!IsValid(fileName)) - { - fileName = GetType() + ".txt"; - } - - // - Path(path); - FileName(fileName); - } - - // - // Deconstructor ... - void ~XSCDataCollector() {} - - // - // Properties ... - - // - bool Path(string value) - { - // - bool result = false; - - // - result = IsValid(value); - if (!result) - { - return result; - } - - // - result = value != mPath; - if (!result) - { - return result; - } - - // - mPath = value; - - // - return result; - } - - // - string Path() - { - return mPath; - } - - // - bool FileName(string value) - { - // - bool result = false; - - // - result = IsValid(value); - if (!result) - { - return result; - } - - // - result = value != mFileName; - if (!result) - { - return result; - } - - // - mFileName = value; - - // - return result; - } - - // - string FileName() - { - return mFileName; - } - - // - // Tools ... - - // - // Clear Exists Collected Data ... - void Clear() - { - // - ResetLastError(); - - // - string dataStorePath = GetStorePath(); - - // - // Check Data Store Exists or not ... - bool isExists = FileIsExist(dataStorePath); - if (!isExists) - { - return; - } - - // - FileDelete(dataStorePath); - } - - // - // Collect All Stored Items ... - int Collect( - T &items[] // Hold Result - ) - { - // - int result = 0; - - // - Clean(items); - - // - // Reading Store Whole Content ... - - // - string storePath = GetStorePath(); - int mFileHandler = FileOpen( - storePath, - FILE_READ | FILE_TXT); - result = mFileHandler != INVALID_HANDLE; - if (!result) - { - return result; - } - - // - // Parse Store Content and Read Data ... - while (!FileIsEnding(mFileHandler)) - { - // - // Each Line Represent One Model ... - string content = FileReadString(mFileHandler); - - // - T iItem; - bool isValid = iItem.ParseModel(content); - if (isValid) - { - // - AddRef( - iItem, - items - // - ); - } - } - - // - // Close File ... - FileClose(mFileHandler); - - // - result = ArraySize(items); - - // - return result; - } - - // - // Add Item ... - bool Add( - T &item // Item to Store - ) - { - // - bool result = false; - - // - result = item.IsModelValid(); - if (!result) - { - return result; - } - - // - string content = item.ToModelString(); - result = IsValid(content); - if (!result) - { - return result; - } - - // - string storePath = GetStorePath(); - int mFileHandler = FileOpen( - storePath, - FILE_READ | FILE_WRITE | FILE_TXT); - result = mFileHandler != INVALID_HANDLE; - if (!result) - { - return result; - } - - // - FileSeek(mFileHandler, 0, SEEK_END); - FileWrite(mFileHandler, content); - FileFlush(mFileHandler); - FileClose(mFileHandler); - - // - return result; - } - - // - // Add Item ... - bool Add( - string content // Content - ) - { - // - bool result = false; - - // - result = IsValid(content); - if (!result) - { - return result; - } - - // - string storePath = GetStorePath(); - int mFileHandler = FileOpen( - storePath, - FILE_READ | FILE_WRITE | FILE_TXT); - result = mFileHandler != INVALID_HANDLE; - if (!result) - { - return result; - } - - // - FileSeek(mFileHandler, 0, SEEK_END); - FileWrite(mFileHandler, content); - FileFlush(mFileHandler); - FileClose(mFileHandler); - - // - return result; - } - - // - // Add Items ... - int Add( - T &items[] // Items to Add ... - ) - { - // - int result = 0; - - // - int itemsCount = ArraySize(items); - if (itemsCount <= 0) - { - return result; - } - - // - for (int i = 0; i < itemsCount; i++) - { - // - T iItem = items[i]; - - // - if (!iItem.IsModelValid()) - { - continue; - } - - // - bool isAdded = Add(iItem); - if (isAdded) - { - result++; - } - } - - // - return result; - } - - // - // Remove Item ... - bool Remove( - T &item // Item to Remove - ) - { - // - bool result = false; - - // - result = item.IsModelValid(); - if (!result) - { - return result; - } - - // - T items[]; - int itemsCount = Collect(items); - if (itemsCount <= 0) - { - return result; - } - - // - int itemIndex = item.FindIndex(items); - result = ArrayRemove( - items, - itemIndex, - 1); - if (!result) - { - return result; - } - - // - Clear(); - - // - int itemsAdded = Add(items); - - // - result = itemsAdded == ArraySize(items); - - // - return result; - } - - // - // Protected ... -protected: - // - // Tools ... - - // - // Retrieve Type of Class as String ... - string GetType() - { - // - string mType = (string) typename(T); - - // - string result = mType; - - // - string parts[]; - int partsCount = SplitContent( - parts, - result, - " " - // - ); - if (partsCount <= 0) - { - // - result = mType; - return result; - } - - // - bool hasLastPart = GetLastItem( - result, - parts - // - ); - if (!hasLastPart) - { - // - result = mType; - return result; - } - - // - return result; - } - - // - // Pricate ... -private: - // - // Props ... - - // - string mPath; // Path - string mFileName; // Data Store File Name - - // - // Tools ... - - // - // Generate Full File Path ... - string GetFilePath(string fileName) - { - // - string result = ""; - - // - result = - // - Path() + "\\" + fileName - // - ; - - // - return result; - } - - // - // Retrieve Data Store File Address ... - string GetStorePath() - { - // - string result = NULL; - - // - result = GetFilePath(mFileName); - - // - return result; - } -}; - -// \ No newline at end of file diff --git a/Classes/x-saherelm.xea.class.mq5 b/Classes/x-saherelm.xea.class.mq5 index 79ca38f0..6feb0c5a 100644 --- a/Classes/x-saherelm.xea.class.mq5 +++ b/Classes/x-saherelm.xea.class.mq5 @@ -819,452 +819,6 @@ struct XPositionTrack // Type Definitions for XPosition Tracker Events ... typedef void (*TOnPositionState)(const XPositionTrack &track); -// -// an Struct for Holding Event Handled Items for Position Tracker ... -struct XPositionTrackerState -{ - // - XPositionTrack inProfits[]; - XPositionTrack inDrawdowns[]; - - // - XPositionTrack onProfits[]; - XPositionTrack onDrawdowns[]; - - // - XPositionTrackerState() - { - Clean(); - } - - // - // Tools ... - - // - // Cleanup ... - void Clean() - { - // - Clean(inProfits); - Clean(inDrawdowns); - - // - Clean(onProfits); - Clean(onDrawdowns); - } -}; - -// -// Position Tracker Class ... -class XSCPositionTracker -{ - // - // Public ... -public: - // - // Props ... - - // - // Constructor ... - void XSCPositionTracker(bool cleanStore = false) - { - // - XSCDataCollector mBase; - - // - if (cleanStore) - { - mBase.Clear(); - } - } - - // - // Tools ... - - // - // Cleaning Store ... - void Clear() - { - // - XSCDataCollector mBase; - - // - mBase.Clear(); - } - - // - // Collect All Store ... - int Collect(XPositionTrack &result[]) - { - // - int mResult = 0; - - // - XSCDataCollector mBase; - - // - mResult = mBase.Collect(result); - - // - return mResult; - } - - // - // Add Item To Store ... - bool Add(XPositionTrack &item) - { - // - bool result = false; - - // - XSCDataCollector mBase; - - // - result = mBase.Add(item); - - // - return result; - } - - // - // Add Item(s) To Store ... - int Add(XPositionTrack &items[]) - { - // - int result = 0; - - // - XSCDataCollector mBase; - - // - result = mBase.Add(items); - - // - return result; - } - - // - // Remove an Item from Store ... - bool Remove(XPositionTrack &item) - { - // - bool result = false; - - // - XSCDataCollector mBase; - - // - result = mBase.Remove(item); - - // - return result; - } - - // - // Custom Functions ... - - // - // Sync all Content using Specific Trader Class ... - int Sync( - XPositionTrackerState &state, // Hold all Changes State ... - XSCTrade *mTrader // XSCTrade Instance for Synchronize ... - ) - { - // - int result = 0; - - // - XPosition positions[]; - int positionsCount = mTrader.GetPositions(positions); - - // - ulong trackTickets[]; - XPositionTrack trackers[]; - int trackersCount = Collect(trackers); - - // - // Nothing to Do ... - if (positionsCount <= 0 && trackersCount <= 0) - { - return result; - } - - // - // Collect Exists Trackers Ticket's For Managing ... - for (int i = 0; i < trackersCount; i++) - { - // - XPositionTrack iTrack = trackers[i]; - - // - bool isValid = iTrack.IsValid(); - if (isValid) - { - // - AddSpecific( - iTrack.ticket, - trackTickets // - ); - } - } - - // - // Clear Tracker Store for Update Later ... - Clear(); - - // - // Collect All Required to Add/Update Trackers here ... - XPositionTrack syncedTracks[]; - - // - // a Flag for Synchronization Performance ... - bool hasTracker = trackersCount > 0; - - // - // Loop through Position for Managing Trackers ... - for (int i = 0; i < positionsCount; i++) - { - // - XPosition iPosition = positions[i]; - - // - // if there isn't any Track before ... - if (!hasTracker) - { - // - XPositionTrack iTrack; - bool isInited = iTrack.Init(iPosition); - if (isInited) - { - // - AddRef( - iTrack, - syncedTracks // - ); - - // - FillState( - iTrack, - state // - ); - } - - // - continue; - } - - // - // if there was some tracks ... - - // - // Try to Find Position Ticket in Track Tickets ... - int iTicketIdx = FindIndex( - iPosition.ticket, - trackTickets // - ); - bool isTrackedBefore = iTicketIdx >= 0; - - // - // Add new Track ... - if (!isTrackedBefore) - { - // - XPositionTrack iTrack; - bool isInited = iTrack.Init(iPosition); - if (isInited) - { - // - AddRef( - iTrack, - syncedTracks // - ); - - // - FillState( - iTrack, - state // - ); - } - } - // - // Update Exists Track ... - else - { - // - XPositionTrack iTrack = trackers[iTicketIdx]; - bool isUpdated = iTrack.Update(iPosition); - if (isUpdated) - { - // - AddRef( - iTrack, - syncedTracks // - ); - - // - FillState( - iTrack, - state // - ); - } - } - } - - // - // Check Synced Tracks ... - int syncedTracksCount = ArraySize(syncedTracks); - if (syncedTracksCount <= 0) - { - return result; - } - - // - result = Add(syncedTracks); - - // - return result; - } - - // - // Event Handlers ... - - // - // Add Profit Event Handler ... - void AddOnProfitEventHandler(TOnPositionState handler) - { - // - AddSpecific( - handler, - mOnProfitEventHandlers // - ); - } - - // - // Add Drawdown Event Handler ... - void AddOnDrawdownEventHandler(TOnPositionState handler) - { - // - AddSpecific( - handler, - mOnDrawdownEventHandlers // - ); - } - - // - // Protected ... -protected: - // - // Tools ... - - // - // Event Handlers ... - - // - // OnProfit ... - void NotifyOnProfitEvent(XPositionTrack &track) - { - // - int count = ArraySize(mOnProfitEventHandlers); - if (count <= 0) - { - return; - } - - // - for (int i = 0; i < count; i++) - { - // - TOnPositionState iHandler = mOnProfitEventHandlers[i]; - iHandler(track); - } - } - - // - // OnDrawdown ... - void NotifyOnDrawdownEvent(XPositionTrack &track) - { - // - int count = ArraySize(mOnDrawdownEventHandlers); - if (count <= 0) - { - return; - } - - // - for (int i = 0; i < count; i++) - { - // - TOnPositionState iHandler = mOnDrawdownEventHandlers[i]; - iHandler(track); - } - } - - // - // Private ... -private: - // - // Props ... - - // - TOnPositionState mOnProfitEventHandlers[]; - TOnPositionState mOnDrawdownEventHandlers[]; - - // - void FillState( - XPositionTrack &track, - XPositionTrackerState &state // - ) - { - // - // In Profit ... - bool isInProfit = track.profit[0] > 0; - if (isInProfit) - { - // - AddRef( - track, - state.inProfits // - ); - } - - // - // In Drawdown ... - bool isInDrawdown = track.profit[0] < 0; - if (isInDrawdown) - { - // - AddRef( - track, - state.inDrawdowns // - ); - } - - // - // On Profit ... - bool isOnProfit = track.IsCrossedInProfit(); - if (isOnProfit) - { - // - AddRef( - track, - state.onProfits // - ); - } - - // - // On Drawdown ... - bool isOnDrawdown = track.IsCrossedInDrawdown(); - if (isOnDrawdown) - { - // - AddRef( - track, - state.onDrawdowns // - ); - } - } -}; - // class XSCPositionHolder { @@ -2212,18 +1766,6 @@ public: { mTrader.AddOnTradeStateChangedEventHandler(mOnTradeStateChangedHandler); } - - // - // Instantiate XPositionTracker Class ... - mPositionTracker = new XSCPositionTracker(); - - // - // Do Synchronisation after Instantiate everything ... - XPositionTrackerState state; - mPositionTracker.Sync( - state, - mTrader // - ); } // @@ -2232,7 +1774,6 @@ public: { // delete mTrader; - delete mPositionTracker; } // @@ -2605,7 +2146,6 @@ protected: // // Trade Class Instance ... XSCTrade *mTrader; - XSCPositionTracker *mPositionTracker; // // Check in Test Mode or not ... @@ -3025,85 +2565,6 @@ protected: } } - // - // Synchronize Positions and Position Tracker ... - void SyncPositionTracker() - { - // - // Check Syncing Interval ... - - // - static datetime lastSyncPositionTracker = NULL; - datetime cTime = TimeCurrent(); - - // - int syncInterval = PeriodSeconds(PERIOD_M5); - int lastDiff = (int)cTime - (int)lastSyncPositionTracker; - - // - bool canSync = - // - lastSyncPositionTracker == NULL - ? true - : lastDiff >= syncInterval - // - ; - if (!canSync) - { - return; - } - - // - lastSyncPositionTracker = cTime; - - // - // Do Sync ... - - // - XPositionTrackerState state; - int synced = mPositionTracker.Sync( - state, - mTrader // - ); - if (synced > 0) - { - // - // Check State and Do What we Want ... - int onProfitsCount = ArraySize(state.onProfits); - int onDrawdownCount = ArraySize(state.onDrawdowns); - - // - // Do What we want whe a Position Dropped to Prefit ... - if (onProfitsCount > 0) - { - // - for (int i = 0; i < onProfitsCount; i++) - { - // - XPositionTrack iTrack = state.onProfits[i]; - - // - OnPositionGoingInProfit(iTrack); - } - } - - // - // Do what we want when a Position Dropped to Drawdown ... - if (onDrawdownCount > 0) - { - // - for (int i = 0; i < onDrawdownCount; i++) - { - // - XPositionTrack iTrack = state.onDrawdowns[i]; - - // - OnPositionGoingToDrawdown(iTrack); - } - } - } - } - // // Guards ... diff --git a/Classes/x-saherelm.xind.class.mq5 b/Classes/x-saherelm.xind.class.mq5 deleted file mode 100644 index 4ac14119..00000000 --- a/Classes/x-saherelm.xind.class.mq5 +++ /dev/null @@ -1,891 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Class Library -// ---------------------------------------------- -// Name: XSCBaseInd -// Description: provides all Indicator 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.base.class.mq5" -#include "../Libraries/x-saherelm.draw.lib.mq5" -#include "../Classes/x-saherelm.xalert.class.mq5" - -// -// Definitions ... - -// -struct XBuffer -{ - // - string title; // Buffer Title - string symbol; // Buffer Symbol - double values[]; // Buffer Values - ENUM_TIMEFRAMES period; // Buffer Period - datetime times[]; // Buffer Values Time - - // - // Constructor ... - XBuffer() - { - Clean(); - } - - // - // Tools ... - bool Init( - string mTitle, // Title - string mSymbol, // Symbol - ENUM_TIMEFRAMES mPeriod // TimeFrame - ) - { - // - bool result = false; - - // - result = IsValid(mTitle) && - IsValid(mSymbol) && - IsValid(mPeriod); - if (!result) - { - return result; - } - - // - Clean(); - - // - this.symbol = mSymbol; - this.period = mPeriod; - - // - result = StringToLower(mTitle); - if (!result) - { - return result; - } - - // - this.title = mTitle; - - // - result = IsValid(); - - // - return result; - } - - // - // Cleanup ... - void Clean() - { - // - Clean(values); - Clean(times); - - // - title = NULL; - symbol = NULL; - period = NULL; - } - - // - // Validate ... - bool IsValid() - { - // - bool result = false; - - // - result = - // - IsValid(title) && - IsValid(period) && - IsValid(symbol) - // - ; - - // - return result; - } - - // - // Check Owwn ... - bool IsOwn( - string mTitle // Checking Title - ) - { - // - bool result = false; - - // - result = IsValid(mTitle); - if (!result) - { - return result; - } - - // - result = StringToLower(mTitle); - if (!result) - { - return result; - } - - // - result = this.title == mTitle; - - // - return result; - } - - // - // Count Size ... - int Count() - { - return ArraySize(values); - } - - // - // Add Value to Buffer ... - int Add( - int index, - double value // - ) - { - // - int result = -1; - - // - if (!IsValid()) - { - return result; - } - - // - if (index > 0) - { - Add(value, values); - } - else - { - values[Count() - 1] = value; - } - - // - result = Count(); - - // - return result; - } - - // - // Get Specified Index Value ... - double Get( - int index // Specified Index - ) - { - // - double result = EMPTY_VALUE; - - // - NormalizeIndex( - index, - values // - ); - - // - result = values[index]; - - // - return result; - } - - // - // Remove Specified Index Value ... - bool Remove(int index) - { - // - bool result = false; - - // - int count = Count(); - result = IsValidSize(count); - if (!result) - { - return result; - } - - // - result = index > 0 && index < count - 1; - if (!result) - { - return result; - } - - // - result = ArrayRemove( - values, - index, - 1 // - ); - - // - return result; - } -}; - -// -class XSCBaseBufferClass : public XSCBaseAlert -{ - // - // Public ... -public: - // - // Virtual ... - - // - // Validate ... - virtual bool IsValid() - { - return false; - } - - // - // Calculations ... - virtual void Calculate() {} - - // - // Protected ... -protected: - // - // Props ... - - // - // Indicators Buffers ... - XBuffer mBuffers[]; - - // - // Buffer Management ... - - // - // Count Registered Buffers ... - int CountBuffers() - { - return ArraySize(mBuffers); - } - - // - // Retrieve Specified Buffer Index ... - int GetBufferIndex( - string title // Specified Buffer Title - ) - { - // - int result = -1; - - // - if (!IsSpecifiedValid(title)) - { - return result; - } - - // - int buffersCount = CountBuffers(); - if (!IsValidSize(buffersCount)) - { - return result; - } - - // - for (int i = 0; i < buffersCount; i++) - { - // - XBuffer iBuffer = mBuffers[i]; - - // - bool isOwn = iBuffer.IsOwn(title); - if (isOwn) - { - // - result = i; - break; - } - } - - // - return result; - } - - // - // Check Contains Specific Buffer or not ... - bool HasBuffer( - string title // Specified Buffer Title - ) - { - // - bool result = false; - - // - int bufferIndex = GetBufferIndex(title); - result = bufferIndex >= 0; - - // - return result; - } - - // - // Retrieve Specified Buffer ... - bool GetBuffer( - string title, // Specified Buffer Title - XBuffer &buffer // Hold Result - ) - { - // - bool result = false; - - // - int idx = GetBufferIndex(title); - result = idx >= 0; - if (!result) - { - return result; - } - - // - buffer = mBuffers[idx]; - - // - result = buffer.IsValid(); - - // - return result; - } - - // - // Register Specified Buffer ... - bool SetBuffer( - XBuffer &buffer // Specified Buffer for Registration - ) - { - // - bool result = false; - - // - // Validate buffer ... - result = buffer.IsValid(); - if (!result) - { - return result; - } - - // - // Check Buffer Doesn't Exists before ... - int idx = GetBufferIndex(buffer.title); - result = idx == -1; - if (!result) - { - return result; - } - - // - AddRef( - buffer, - mBuffers // - ); - - // - return result; - } - - // - double GetBufferValue( - string mTitle, // Required Buffer Title - int index // Bar Index - ) - { - // - double result = EMPTY_VALUE; - - // - // Validate State ... - if (!IsValid()) - { - return result; - } - - // - int bufferIDX = GetBufferIndex(mTitle); - if (bufferIDX < 0) - { - return result; - } - - // - Calculate(); - - // - result = mBuffers[bufferIDX].Get(index); - - // - return result; - } - - // - int CopyBufferValue( - string mTitle, - double &buffer[], - int start, - int count // - ) - { - // - int result = 0; - - // - if (!IsValid()) - { - return result; - } - - // - int sourceIDX = GetBufferIndex(mTitle); - if (sourceIDX < 0) - { - return result; - } - - // - Calculate(); - - // - result = ArrayCopy( - buffer, - mBuffers[sourceIDX].values, - start, - start, - count // - ); - - // - return result; - } -}; - -// -// Base Indicator Class ... -class XSCBaseInd : public XSCBaseAlert -{ - // - // Public ... -public: - // - // Props ... - - // - // Indicators Buffers ... - XBuffer mBuffers[]; - - // - // Constructor(s) ... - void XSCBaseInd( - string symbol, // Trading Symbol - ENUM_TIMEFRAMES period // Trading TimeFrame - ) : XSCBaseAlert() - { - // - mSymbol = symbol; - mPeriod = period; - - // - mCalculatedBars = 0; - } - - // - // Deconstructor ... - void ~XSCBaseInd() {} - - // - // Property Getter(s) / Setter(s) ... - - // - string GetSymbol() - { - return mSymbol; - } - - // - ENUM_TIMEFRAMES GetPeriod() - { - return mPeriod; - } - - // - // Overrides ... - - // - virtual string GetTag(); - - // - virtual string GetToken(); - - // - virtual void DeInit(int reason); // Indicator DeInitialization - - // - // Validate Inputs ... - virtual bool IsValidInputs() - { - return false; - } - - // - // Calculate ... - virtual void Calculate() {} - - // - // Tools ... - - // - datetime GetBarTime( - datetime time = NULL // - ) - { - // - NormalizeTime(time); - - // - datetime result = GetPeriodStartTime( - mSymbol, - mPeriod, - time // - ); - - // - return result; - } - - // - int GetBarIndex( - datetime time = NULL // - ) - { - // - datetime iBarTime = GetBarTime(time); - - // - int result = iBarShift( - mSymbol, - mPeriod, - iBarTime // - ); - - // - return result; - } - - // - // Retrieve Calculate Bars ... - int GetCalculatedBars() - { - return mCalculatedBars; - } - - // - // Count available Bars ... - int CountBars() - { - // - return iBars( - mSymbol, - mPeriod // - ); - } - - // - // Validate Indicator States ... - bool IsValid() - { - // - bool result = false; - - // - result = IsValidInputs(); - if (!result) - { - return result; - } - - // - result = - // - IsSpecifiedValid(mSymbol) && - IsSpecifiedValid(mPeriod) - // - ; - - // - return result; - } - - // - // Calculate Limit ... - // this means Required Bars for Calculation ... - int CountLimit() - { - // - int result = 0; - - // - int totalBars = CountBars(); - int calculatedBars = GetCalculatedBars(); - result = MathAbs(totalBars - calculatedBars); - - // - return result; - } - - // - // Buffer Registrations ... - - // - // Count Registered Buffers ... - int CountBuffers() - { - return ArraySize(mBuffers); - } - - // - // Retrieve Specified Buffer Index ... - int GetBufferIndex( - string title // Specified Buffer Title - ) - { - // - int result = -1; - - // - if (!IsSpecifiedValid(title)) - { - return result; - } - - // - int buffersCount = CountBuffers(); - if (!IsValidSize(buffersCount)) - { - return result; - } - - // - for (int i = 0; i < buffersCount; i++) - { - // - XBuffer iBuffer = mBuffers[i]; - - // - bool isOwn = iBuffer.IsOwn(title); - if (isOwn) - { - // - result = i; - break; - } - } - - // - return result; - } - - // - // Check Contains Specific Buffer or not ... - bool HasBuffer( - string title // Specified Buffer Title - ) - { - // - bool result = false; - - // - int bufferIndex = GetBufferIndex(title); - result = bufferIndex >= 0; - - // - return result; - } - - // - // Retrieve Specified Buffer ... - bool GetBuffer( - string title, // Specified Buffer Title - XBuffer &buffer // Hold Result - ) - { - // - bool result = false; - - // - int idx = GetBufferIndex(title); - result = idx >= 0; - if (!result) - { - return result; - } - - // - buffer = mBuffers[idx]; - - // - result = buffer.IsValid(); - - // - return result; - } - - // - // Register Specified Buffer ... - bool SetBuffer( - XBuffer &buffer // Specified Buffer for Registration - ) - { - // - bool result = false; - - // - // Validate buffer ... - result = buffer.IsValid(); - if (!result) - { - return result; - } - - // - // Check Buffer Doesn't Exists before ... - int idx = GetBufferIndex(buffer.title); - result = idx == -1; - if (!result) - { - return result; - } - - // - AddRef( - buffer, - mBuffers // - ); - - // - return result; - } - - // - double GetBufferValue( - string mTitle, // Required Buffer Title - int index // Bar Index - ) - { - // - double result = EMPTY_VALUE; - - // - // Validate State ... - if (!IsValid()) - { - return result; - } - - // - int bufferIDX = GetBufferIndex(mTitle); - if (bufferIDX < 0) - { - return result; - } - - // - Calculate(); - - // - result = mBuffers[bufferIDX].Get(index); - - // - return result; - } - - // - int CopyBufferValue( - string mTitle, - double &buffer[], - int start, - int count // - ) - { - // - int result = 0; - - // - if (!IsValid()) - { - return result; - } - - // - int sourceIDX = GetBufferIndex(mTitle); - if (sourceIDX < 0) - { - return result; - } - - // - Calculate(); - - // - result = ArrayCopy( - buffer, - mBuffers[sourceIDX].values, - start, - start, - count // - ); - - // - return result; - } - - // - // Protected ... -protected: - // - // Props ... - - // - string mSymbol; // Trading Symbol - ENUM_TIMEFRAMES mPeriod; // Trading TimeFrame - - // - int mCalculatedBars; // Calculated Bars - - // - // Tools ... - - // - // Private ... -private: - // - // Props ... -}; - -// \ No newline at end of file diff --git a/Classes/x-saherelm.xprovider.class.mq5 b/Classes/x-saherelm.xprovider.class.mq5 deleted file mode 100644 index d9043108..00000000 --- a/Classes/x-saherelm.xprovider.class.mq5 +++ /dev/null @@ -1,170 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Class Library -// ---------------------------------------------- -// Name: XSCBaseProvider -// Description: provides all Base Provider -// 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 - -// -// Includes ... -#include "../Classes/x-saherelm.xalert.class.mq5" -#include "../Libraries/x-saherelm.xtrade.lib.mq5" - -// -// Class ... - -// -// Base Provider Class ... -class XSCBaseProvider : public XSCBaseAlert -{ - // - // Public ... -public: - // - // Props ... - - // - // Constructor ... - XSCBaseProvider( - string symbol, // Trading Symbol - ENUM_TIMEFRAMES period // Trading Period - ) - { - // - // Initialize Cycle ... - mCycle.Init( - symbol, - period, - X_MARKET_CYCLE_SHORT, - X_PERIOD_MANUALLY, - period, - "HOST Period" - // - ); - } - - // - // Deconstructor ... - ~XSCBaseProvider() - { - DeInit(); - } - - // - // Properties Gettr(s) / Setter(s) ... - - // - // DeInit all Requirements ... - virtual void DeInit(); - - // - // Functions ... - - // - string GetSymbol() - { - return mCycle.symbol; - } - - // - ENUM_TIMEFRAMES GetPeriod() - { - return mCycle.hostPeriod; - } - - // - // Count Bars ... - int CountBars() - { - // - return mCycle - .CountBars(); - } - - // - // Check New Bar ... - bool IsNewBar() - { - // - return mCycle - .IsNewBar(); - } - - // - // Can Ignore Process ... - bool CanIgnoreProcess() - { - // - bool result = false; - - // - result = - // - IsRunningOnTestMode() - ? !IsNewBar() - : !IsNewBar() && mWaitsUntilNewBar - // - ; - - // - if (!result) - { - mWaitsUntilNewBar = false; - } - - // - return result; - } - - // - // Toggle Waititng Until New Candle ... - void ToggleWaitingUntilNewBar() - { - mWaitsUntilNewBar = !mWaitsUntilNewBar; - } - - // - void SetWaitsUntilNewBar(bool value) - { - mWaitsUntilNewBar = value; - } - - // - // Protected ... -protected: - // - // Props ... - - // - XMarketCycle mCycle; - - // - bool mWaitsUntilNewBar; - - // - // Private ... -private: - // - // Props ... - - // - // Tools ... -}; - -// -// Tools ... diff --git a/Experts/x-be-test.mq5 b/Experts/x-be-test.mq5 deleted file mode 100644 index 29b09a9f..00000000 --- a/Experts/x-be-test.mq5 +++ /dev/null @@ -1,351 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center XSAMPLE MQL5 Expert Advisor -// ------------------------------------------------- -// Name: XSAMPLE -// Description: an Exper Advisor which used RSI and MA -// to Analyse Market ... -// -// Maintainer: -// ------------ -// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) -// -//////////////////////////////////////////////////////x -// -// Global Properties ... -#property copyright "Copyright 2023, SaherElm IT Center" -#property link "https://saherelm.ir" -#property version "1.00" -#property description "SaherElm XSAMPLE" -#property strict - -// -#include "../Libraries/x-saherelm.draw.lib.mq5" -#include "../Classes/x-saherelm.xalert.class.mq5" -#include "../Classes/x-saherelm.xtrade.class.mq5" -#include "../Libraries/x-saherelm.common.lib.mq5" - -// -#define ShortName "XSAMPLE" - -// -int swingLifeTime = 20; -ENUM_TIMEFRAMES destPEriod = PERIOD_H4; - -// -XOHCL hSwing0; -XOHCL hSwing1; - -// -XOHCL lSwing0; -XOHCL lSwing1; - -// -XSCAlert *mAlert; -XSCTrade *mTrader; - -// -XBarTracker xBarTracker; -XMarketCycle xDestCycle; - -// -// Initialization ... -int OnInit() -{ - // - drawPrefix = ShortName; - - // - if (!InitialEA()) - { - return INIT_PARAMETERS_INCORRECT; - } - - // - // Init Succeed ... - return INIT_SUCCEEDED; -} - -// -// DeInitialization ... -void OnDeinit(const int reason) -{ - // - // REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function - // REASON_REMOVE 1 Program removed from a chart - // REASON_RECOMPILE 2 Program recompiled - // REASON_CHARTCHANGE 3 A symbol or a chart period is changed - // REASON_CHARTCLOSE 4 Chart closed - // REASON_PARAMETERS 5 Inputs changed by a user - // REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings - // REASON_TEMPLATE 7 Another chart template applied - // REASON_INITFAILED 8 The OnInit() handler returned a non-zero value - // REASON_CLOSE 9 Terminal closed - - // - // De Initialize XSampleEA Providers ... -} - -// -// On Tick Handler ... -void OnTick() -{ - // - if (!xBarTracker.IsNewBar()) - { - return; - } - - // - xDestCycle.Update(0); - - // - Analyze(); -} - -// -// - -// -bool InitialEA() -{ - // - bool result = false; - - // - mAlert = new XSCAlert(); - mAlert.SetLogAlerts(true); - mAlert.SetPrefix(ShortName); - mAlert.SetEnableAlerts(true); - mAlert.SetPushAlerts(false); - mAlert.SetMailAlerts(false); - mAlert.SetTerminalAlerts(false); - - // - mTrader = new XSCTrade( - 10, - 78692110, - 0, - 0, - 0 // - ); - - // - result = xBarTracker.Init( - _Symbol, - _Period // - ); - if (!result) - { - return result; - } - - // - result = xDestCycle.Init( - _Symbol, - _Period, - X_MARKET_CYCLE_MEDIUM, - X_PERIOD_MANUALLY, - destPEriod, - "DEST" // - ); - if (!result) - { - return result; - } - - // - result = true; - - // - return result; -} - -// -void Analyze() -{ - // - XOHCL cBar; - cBar.Init( - _Symbol, - _Period, - 1 // - ); - - // - FindSwings(cBar); -} - -// -void FindSwings(XOHCL &bar) -{ - // - // High Swings ... - - // - if (!hSwing0.IsValid()) - { - // - int index = bar.FindSwing(X_SWING_HIGH, 10); - - // - if (index >= 0) - { - // - bool isInited = hSwing0.Init( - bar.symbol, - bar.period, - index // - ); - } - } - - // - if (hSwing0.IsValid() && !hSwing1.IsValid()) - { - // - int index = bar.FindNextSwing(X_SWING_HIGH, hSwing0.Index(), 10); - - // - if (index >= 0) - { - // - index += hSwing0.Index(); - - // - bool isInited = hSwing1.Init( - bar.symbol, - bar.period, - index // - ); - } - } - - // - // Draw Swings ... - if (hSwing0.IsValid() && hSwing1.IsValid()) - { - // - DrawSwing( - hSwing1, - X_PRICE_HIGH, - hSwing0, - X_PRICE_HIGH, - clrAqua, - "HH" // - ); - } - - // - // Low Swings ... - - // - if (!lSwing0.IsValid()) - { - // - int index = bar.FindSwing(X_SWING_LOW, 10); - - // - if (index >= 0) - { - // - bool isInited = lSwing0.Init( - bar.symbol, - bar.period, - index // - ); - } - } - - // - if (lSwing0.IsValid() && !lSwing1.IsValid()) - { - // - int index = bar.FindNextSwing(X_SWING_LOW, lSwing0.Index(), 10); - - // - if (index >= 0) - { - // - index += lSwing0.Index(); - - // - bool isInited = lSwing1.Init( - bar.symbol, - bar.period, - index // - ); - } - } - - // - // Draw Swings ... - if (lSwing0.IsValid() && lSwing1.IsValid()) - { - // - DrawSwing( - lSwing1, - X_PRICE_LOW, - lSwing0, - X_PRICE_LOW, - clrMagenta, - "LL" // - ); - } -} - -// -// Draw Line ... - -// -void DrawSwing( - XOHCL &bar1, // From (Old) ... - ENUM_X_PRICE price1, // How to Select Bar 1 Price ... - XOHCL &bar0, // To (New) ... - ENUM_X_PRICE price0, // How to Select Bar 0 Price ... - color clr, - string prefix, - bool forceRemove = false // -) -{ - // - long chartID = ChartID(); - - // - double b1Price = bar1.GetPrice(price1); - double b0Price = bar0.GetPrice(price0); - - // - string lName = prefix + "Swing_" + - ToString(b1Price) + "_TO_" + - ToString(b0Price); - - // - if (IsDrawExists(prefix) && forceRemove) - { - RemoveDraws(prefix); - } - - // - // if (IsDrawExists(lName)) - // { - // return; - // } - - // - DrawTrendLine( - chartID, - lName, - 0, - bar1.time, - b1Price, - bar0.time, - b0Price, - clr, - STYLE_SOLID, - 2, - false, - false, - true // - ); -} diff --git a/Experts/x-test.x121ea.mq5 b/Experts/x-test.x121ea.mq5 deleted file mode 100644 index c46a9fe1..00000000 --- a/Experts/x-test.x121ea.mq5 +++ /dev/null @@ -1,1136 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center X121EA MQL5 Expert Advisor -// ------------------------------------------------- -// Name: X121EA -// Description: an Exper Advisor which used RSI and MA -// to Analyse Market ... -// -// Maintainer: -// ------------ -// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) -// -//////////////////////////////////////////////////////x -// -// Global Properties ... -#property copyright "Copyright 2023, SaherElm IT Center" -#property link "https://saherelm.ir" -#property version "1.00" -#property description "SaherElm X121EA" -#property strict - -// -#define ShortName "X121EA" - -// -#include "../Classes/x-saherelm.x121.xea.class.mq5" -#include "../Signallers/x-saherelm.x92.signaller.class.mq5" -#include "../Signallers/x-saherelm.xsp.signaller.class.mq5" -#include "../Signallers/x-saherelm.x110.signaller.class.mq5" -#include "../Signallers/x-saherelm.x121.signaller.class.mq5" -#include "../Signallers/x-saherelm.x128.signaller.class.mq5" -#include "../Signallers/x-saherelm.x786.signaller.class.mq5" - -// -// "EURUSDb,USDCHFb,USDJPYb,XAUUSDb" -// "EURUSDb,USDCHFb,USDJPYb,GBPUSDb,XAUUSDb,AUDUSDb,USDCADb,NZDUSDb" - -// -// Inputs ... -input long x121EAMagicNumber = 78692110; // Magic Number -input int x121EASlippage = 10; // Slippgae -input string x121EASymbols = "EURUSDb"; // Symbols -// -input bool x121EAAllowLong = true; // Allow Long Trades -input bool x121EAAllowShort = true; // Allow Short Trades -input double x121EAMaxAllowedDrawdownFactor = 0.002; // Max Allowed Drawdown Factor -input double x121EAVolume = 0.01; // Static Volume -input double x121EAR2R = 1; // Risk to Reward Ratio - -// -// Vars ... -string x121EASymbol; -ENUM_TIMEFRAMES x121EAPeriod; - -// -MqlTick x121EATick; - -// -// X121EA ... -XSCX121EA *mX121EA; - -// -// Event Handlers ... - -// -// Initialization ... -int OnInit() -{ - // - if (x121EASymbol == NULL || StringLen(x121EASymbol) <= 0) - { - x121EASymbol = _Symbol; - } - - // - if (x121EAPeriod == NULL) - { - x121EAPeriod = _Period; - } - - // - // Validate Inputs ... - if (!X121EAValidateInputs()) - { - return INIT_PARAMETERS_INCORRECT; - } - - // - // Initial EA ... - if (!InitialEA()) - { - return INIT_PARAMETERS_INCORRECT; - } - - // - // TesterHideIndicators(true); - - // - mX121EA.Alert(ShortName + " Initialized Sccessfully ..."); - - // - // Init Succeed ... - return INIT_SUCCEEDED; -} - -// -// DeInitialization ... -void OnDeinit(const int reason) -{ - // - // REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function - // REASON_REMOVE 1 Program removed from a chart - // REASON_RECOMPILE 2 Program recompiled - // REASON_CHARTCHANGE 3 A symbol or a chart period is changed - // REASON_CHARTCLOSE 4 Chart closed - // REASON_PARAMETERS 5 Inputs changed by a user - // REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings - // REASON_TEMPLATE 7 Another chart template applied - // REASON_INITFAILED 8 The OnInit() handler returned a non-zero value - // REASON_CLOSE 9 Terminal closed - - // - // De Initialize X121EA Providers ... - mX121EA.Alert(ShortName + " Deinitialized ..."); -} - -// -// On Tick Handler ... -void OnTick() -{ - // - // Reading Tick ... - if (!SymbolInfoTick(x121EASymbol, x121EATick)) - { - return; - } - - // - mX121EA.OnTick(); -} - -// -// Custom Functions ... - -// -// Validate Variables nd Inputs ... -bool X121EAValidateInputs() -{ - // - bool result = false; - - // - result = - // - x121EASlippage > 0 && - x121EAMagicNumber > 0 - // - ; - - // - return result; -} - -// -// Initialize Specific Providers ... -bool InitialEA() -{ - // - bool result = false; - - // - // Here We Have to Initial 4 instance of X5Provider ... - // - EURUSD/M5; - // - USDCHF/M5; - // - USDJPY/M5; - // - XAUUSD/M5; - - // - result = IsValid(x121EASymbols); - if (!result) - { - return result; - } - - // - string symbols[]; - int symbolsCount = SplitContent( - symbols, - x121EASymbols); - result = symbolsCount > 0; - if (!result) - { - return result; - } - - // - // Instantiate X121EA Class ... - mX121EA = new XSCX121EA( - x121EASlippage, // Slippgae - x121EAMagicNumber // Magic Number - ); - - // - mX121EA.SetAlertPrefix(ShortName); - - // - // Prepare Providers and Add them into mX121EA class ... - for (int i = 0; i < symbolsCount; i++) - { - // - // Requirements ... - string iSymbol = symbols[i]; - ENUM_TIMEFRAMES iPeriod = PERIOD_M5; - - // - // Define Structure ... - X121ProviderDescriptor iDescriptor; - - // - iDescriptor.symbol = iSymbol; - iDescriptor.period = iPeriod; - - // - // Attach Signallers ... - - // - // X786 Signaller ... - X786Signaller *x786Signaller = new X786Signaller(); - x786Signaller.Default(); - x786Signaller.r2r = x121EAR2R; - x786Signaller.maxAllowedLong = 1; - x786Signaller.maxAllowedShort = 1; - x786Signaller.allowLong = x121EAAllowLong; - x786Signaller.allowShort = x121EAAllowShort; - x786Signaller.maxAllowedOpenPositionAge = 0; - x786Signaller.minRequiredProfitPerTrade = 0; - x786Signaller.openNextPositionOnProfit = false; - x786Signaller.staticVolumeLong = x121EAVolume; - x786Signaller.staticVolumeShort = x121EAVolume; - x786Signaller.delayBetweenTwoSameTypeSignals = 6; - - // - // X121 Signaller ... - X121Signaller *x121Signaller = new X121Signaller(); - x121Signaller.Default(); - x121Signaller.r2r = x121EAR2R; - x121Signaller.maxAllowedLong = 1; - x121Signaller.maxAllowedShort = 1; - x121Signaller.allowLong = x121EAAllowLong; - x121Signaller.allowShort = x121EAAllowShort; - x121Signaller.maxAllowedOpenPositionAge = 0; - x121Signaller.minRequiredProfitPerTrade = 0; - x121Signaller.openNextPositionOnProfit = false; - x121Signaller.staticVolumeLong = x121EAVolume; - x121Signaller.staticVolumeShort = x121EAVolume; - x121Signaller.delayBetweenTwoSameTypeSignals = 6; - - // - // X110 Signaller ... - X110Signaller *x110Signaller = new X110Signaller(); - x110Signaller.Default(); - x110Signaller.r2r = x121EAR2R; - x110Signaller.maxAllowedLong = 1; - x110Signaller.maxAllowedShort = 1; - x110Signaller.allowLong = x121EAAllowLong; - x110Signaller.allowShort = x121EAAllowShort; - x110Signaller.maxAllowedOpenPositionAge = 0; - x110Signaller.minRequiredProfitPerTrade = 0; - x110Signaller.openNextPositionOnProfit = false; - x110Signaller.staticVolumeLong = x121EAVolume; - x110Signaller.staticVolumeShort = x121EAVolume; - x110Signaller.delayBetweenTwoSameTypeSignals = 6; - - // - // X92 Signaller ... - X92Signaller *x92Signaller = new X92Signaller(); - x92Signaller.Default(); - x92Signaller.r2r = x121EAR2R; - x92Signaller.SetSymbol(iSymbol); - x92Signaller.SetPeriod(iPeriod); - x92Signaller.maxAllowedLong = 1; - x92Signaller.maxAllowedShort = 1; - x92Signaller.allowLong = x121EAAllowLong; - x92Signaller.allowShort = x121EAAllowShort; - x92Signaller.maxAllowedOpenPositionAge = 0; - x92Signaller.minRequiredProfitPerTrade = 0; - x92Signaller.openNextPositionOnProfit = false; - x92Signaller.staticVolumeLong = x121EAVolume; - x92Signaller.staticVolumeShort = x121EAVolume; - x92Signaller.delayBetweenTwoSameTypeSignals = 6; - - // - // X128 Signaller ... - X128Signaller *x128Signaller = new X128Signaller(); - x128Signaller.Default(); - x128Signaller.r2r = x121EAR2R; - x128Signaller.maxAllowedLong = 1; - x128Signaller.maxAllowedShort = 1; - x128Signaller.allowLong = false; // x121EAAllowLong; - x128Signaller.allowShort = false; // x121EAAllowShort; - x128Signaller.maxAllowedOpenPositionAge = 0; - x128Signaller.minRequiredProfitPerTrade = 0; - x128Signaller.openNextPositionOnProfit = false; - x128Signaller.staticVolumeLong = x121EAVolume; - x128Signaller.staticVolumeShort = x121EAVolume; - x128Signaller.delayBetweenTwoSameTypeSignals = 6; - - // - // XSP Signaller ... - XSPSignaller *xSPSignaller = new XSPSignaller(); - xSPSignaller.Default(); - xSPSignaller.maxAllowedLong = 0; - xSPSignaller.maxAllowedShort = 0; - xSPSignaller.allowLong = false; // x121EAAllowLong; - xSPSignaller.allowShort = false; // x121EAAllowShort; - xSPSignaller.maxAllowedOpenPositionAge = 0; - xSPSignaller.minRequiredProfitPerTrade = 0; - xSPSignaller.openNextPositionOnProfit = false; - xSPSignaller.staticVolumeLong = x121EAVolume; - xSPSignaller.staticVolumeShort = x121EAVolume; - xSPSignaller.delayBetweenTwoSameTypeSignals = 6; - - // - Clean(iDescriptor.signallers); - - // - int idx = 0; - ArrayResize(iDescriptor.signallers, 3); - - // - iDescriptor.signallers[idx] = x786Signaller; - idx++; - iDescriptor.signallers[idx] = x121Signaller; - idx++; - iDescriptor.signallers[idx] = x110Signaller; - idx++; - // iDescriptor.signallers[idx] = x92Signaller; - // idx++; - // iDescriptor.signallers[idx] = x128Signaller; - // idx++; - // iDescriptor.signallers[idx] = xSPSignaller; - // idx++; - - // - // Set Inputs to Default ... - iDescriptor.inputs.Default(); - - // - // Prepare Input Requirements ... - - // - iDescriptor.inputs.symbol = iSymbol; - iDescriptor.inputs.period = iPeriod; - - // - ConfigureDescriptor(iDescriptor); - - // - ApplyPreDefineConfigurations(iDescriptor); - - // - // Init Inputs ... - result = iDescriptor.inputs.Init(); - if (!result) - { - return result; - } - - // - // Validate Inputs ... - bool isInputsValid = iDescriptor.inputs.IsValid(); - if (!isInputsValid) - { - continue; - } - - // - result = mX121EA.AddProvider(iDescriptor); - if (!result) - { - break; - } - } - - // - return result; -} - -// -// Configurators ... - -// -// Configuring Descriptors ... -void ConfigureDescriptor( - X121ProviderDescriptor &iDescriptor // -) -{ - // - // XASCT ... - iDescriptor.inputs.asctInputs.showLongs = false; - iDescriptor.inputs.asctInputs.showShorts = false; - - // - // XHK ... - iDescriptor.inputs.hkInputs.drawHikenAshi = false; - iDescriptor.inputs.hkInputs.drawSmoothedHikenAshi = false; - - // - // XHULL ... - iDescriptor.inputs.hullInputs.showUpZone = false; - iDescriptor.inputs.hullInputs.showDownZone = false; - - // - // XSSLC ... - iDescriptor.inputs.sslcInputs.showUp = false; - iDescriptor.inputs.sslcInputs.showDown = false; - - // - // XMRB ... - iDescriptor.inputs.mrbInputs.showFastMa = false; - iDescriptor.inputs.mrbInputs.showSlowMa = false; - iDescriptor.inputs.mrbInputs.showRibbon = false; - - // - // XMC ... - iDescriptor.inputs.mcInputs.showFastMa = false; - iDescriptor.inputs.mcInputs.showSlowMa = false; - iDescriptor.inputs.mcInputs.showVerifierMa = false; - - // - // XICH ... - iDescriptor.inputs.ichInputs.showKumo = false; - iDescriptor.inputs.ichInputs.showKijunSen = false; - iDescriptor.inputs.ichInputs.showTenkanSen = false; - iDescriptor.inputs.ichInputs.showChikouSpan = false; - iDescriptor.inputs.ichInputs.showSenkouSpanA = false; - iDescriptor.inputs.ichInputs.showSenkouSpanB = false; - iDescriptor.inputs.ichInputs.showKijunSenPlus = false; - iDescriptor.inputs.ichInputs.showKijunSenNegative = false; - - // - // XCHE ... - iDescriptor.inputs.cheInputs.showLongExit1Line = false; - iDescriptor.inputs.cheInputs.showShortExit1Line = false; - iDescriptor.inputs.cheInputs.showLongExit2Line = false; - iDescriptor.inputs.cheInputs.showShortExit2Line = false; - - // - // XPV ... - iDescriptor.inputs.pvInputs.showPeaksAndVales = false; - iDescriptor.inputs.pvInputs.showLevels = false; - iDescriptor.inputs.pvInputs.showConsolidations = false; - iDescriptor.inputs.pvInputs.showFibo1Levels = false; - iDescriptor.inputs.pvInputs.showFibo2Levels = false; - iDescriptor.inputs.pvInputs.showFibo3Levels = false; - iDescriptor.inputs.pvInputs.showFibo4Levels = false; - iDescriptor.inputs.pvInputs.showFibo5Levels = false; - - // - // XZG ... - iDescriptor.inputs.zgInputs.showZigZag = false; - iDescriptor.inputs.zgInputs.showPeaksAndVales = false; - - // - // XDON ... - iDescriptor.inputs.donInputs.showOpen = false; - iDescriptor.inputs.donInputs.showHigh = false; - iDescriptor.inputs.donInputs.showClose = false; - iDescriptor.inputs.donInputs.showLow = false; - - // - // XSTR ... - iDescriptor.inputs.strInputs.showTrends = false; - iDescriptor.inputs.strInputs.fillTrends = false; - - // - // Short MArket ... - iDescriptor.inputs.sMarketPeriod = NULL; - iDescriptor.inputs.sMarketMethod = X_PERIOD_AUTO; - - // - // Medium Market ... - iDescriptor.inputs.mMarketPeriod = NULL; - iDescriptor.inputs.mMarketMethod = X_PERIOD_AUTO; - - // - // Long Market ... - iDescriptor.inputs.lMarketPeriod = NULL; - iDescriptor.inputs.lMarketMethod = X_PERIOD_AUTO; - - // - int fontSize = 12; - double fontAngel = 90; - string fontName = "Arial"; - ENUM_ANCHOR_POINT fontAnchor = ANCHOR_LEFT_UPPER; - - // - // Current Market ... - ConfigureCurrentMarketDrawSpecs( - // - iDescriptor, - // - "Current", - // - false, // Draw Labels ... - false, // Draw C Bar ... - false, // Draw P Bar ... - false, // Draw C Bar Mid Line ... - false, // Draw P Bar Mid Line ... - // - fontSize, - fontAngel, - fontName, - fontAnchor // , - // - // cBarPrefix - // pBarPrefix - // openLabel - // closeLabel - // highLabel - // lowLabel - // midLineLabel - ); - - // - // Short Market ... - ConfigureShortMarketDrawSpecs( - // - iDescriptor, - // - iDescriptor.inputs.sMarketPeriod, - iDescriptor.inputs.sMarketMethod, - // - "Short", - // - false, // Draw Labels ... - false, // Draw C Bar ... - false, // Draw P Bar ... - false, // Draw C Bar Mid Line ... - false, // Draw P Bar Mid Line ... - // - fontSize, - fontAngel, - fontName, - fontAnchor // , - // - // cBarPrefix - // pBarPrefix - // openLabel - // closeLabel - // highLabel - // lowLabel - // midLineLabel - ); - - // - // Medium Market ... - ConfigureMediumMarketDrawSpecs( - // - iDescriptor, - // - iDescriptor.inputs.mMarketPeriod, - iDescriptor.inputs.mMarketMethod, - // - "Medium", - // - false, // Draw Labels ... - false, // Draw C Bar ... - false, // Draw P Bar ... - false, // Draw C Bar Mid Line ... - false, // Draw P Bar Mid Line ... - // - fontSize, - fontAngel, - fontName, - fontAnchor // , - // - // cBarPrefix - // pBarPrefix - // openLabel - // closeLabel - // highLabel - // lowLabel - // midLineLabel - ); - - // - // Long Market ... - ConfigureLongMarketDrawSpecs( - // - iDescriptor, - // - iDescriptor.inputs.lMarketPeriod, - iDescriptor.inputs.lMarketMethod, - // - "Long", - // - false, // Draw Labels ... - false, // Draw C Bar ... - false, // Draw P Bar ... - false, // Draw C Bar Mid Line ... - false, // Draw P Bar Mid Line ... - // - fontSize, - fontAngel, - fontName, - fontAnchor // , - // - // cBarPrefix - // pBarPrefix - // openLabel - // closeLabel - // highLabel - // lowLabel - // midLineLabel - ); - - // - // Hind Market ... - ConfigureHindMarketDrawSpecs( - // - iDescriptor, - // - iDescriptor.inputs.hMarketPeriod, - iDescriptor.inputs.hMarketMethod, - // - "Hind", - // - false, // Draw Labels ... - false, // Draw C Bar ... - false, // Draw P Bar ... - false, // Draw C Bar Mid Line ... - false, // Draw P Bar Mid Line ... - // - fontSize, - fontAngel, - fontName, - fontAnchor // , - // - // cBarPrefix - // pBarPrefix - // openLabel - // closeLabel - // highLabel - // lowLabel - // midLineLabel - ); -} - -// -// Current ... -void ConfigureCurrentMarketDrawSpecs( - X121ProviderDescriptor &iDescriptor, - string prefix = "Current", - bool drawLabels = false, - bool drawCBar = false, - bool drawPBar = false, - bool drawCBarMid = false, - bool drawPBarMid = false, - int fontSize = 12, - double fontAngel = 90, - string fontName = "Arial", - ENUM_ANCHOR_POINT fontAnchor = ANCHOR_LEFT_UPPER, - string cBarPrefix = "C", - string pBarPrefix = "P", - string openLabel = "O", - string closeLabel = "C", - string highLabel = "H", - string lowLabel = "L", - string midLineLabel = "Mid" // -) -{ - // - ConfigureMarketDrawSpecs( - iDescriptor.inputs.cMarketInputs, - // - drawLabels, - drawCBar, - drawPBar, - drawCBarMid, - drawPBarMid, - fontSize, - fontAngel, - fontName, - fontAnchor, - prefix, - cBarPrefix, - pBarPrefix, - openLabel, - closeLabel, - highLabel, - lowLabel, - midLineLabel // - ); -} - -// -// Short ... -void ConfigureShortMarketDrawSpecs( - X121ProviderDescriptor &iDescriptor, - ENUM_TIMEFRAMES period = NULL, - ENUM_X_PERIOD_METHOD method = X_PERIOD_AUTO, - string prefix = "Short", - bool drawLabels = false, - bool drawCBar = false, - bool drawPBar = false, - bool drawCBarMid = false, - bool drawPBarMid = false, - int fontSize = 12, - double fontAngel = 90, - string fontName = "Arial", - ENUM_ANCHOR_POINT fontAnchor = ANCHOR_LEFT_UPPER, - string cBarPrefix = "C", - string pBarPrefix = "P", - string openLabel = "O", - string closeLabel = "C", - string highLabel = "H", - string lowLabel = "L", - string midLineLabel = "Mid" // -) -{ - // - // Short Market ... - iDescriptor.inputs.sMarketPeriod = period; - iDescriptor.inputs.sMarketMethod = method; - - // - ConfigureMarketDrawSpecs( - iDescriptor.inputs.sMarketInputs, - // - drawLabels, - drawCBar, - drawPBar, - drawCBarMid, - drawPBarMid, - fontSize, - fontAngel, - fontName, - fontAnchor, - prefix, - cBarPrefix, - pBarPrefix, - openLabel, - closeLabel, - highLabel, - lowLabel, - midLineLabel // - ); -} - -// -// Medium ... -void ConfigureMediumMarketDrawSpecs( - X121ProviderDescriptor &iDescriptor, - ENUM_TIMEFRAMES period = NULL, - ENUM_X_PERIOD_METHOD method = X_PERIOD_AUTO, - string prefix = "Medium", - bool drawLabels = false, - bool drawCBar = false, - bool drawPBar = false, - bool drawCBarMid = false, - bool drawPBarMid = false, - int fontSize = 12, - double fontAngel = 90, - string fontName = "Arial", - ENUM_ANCHOR_POINT fontAnchor = ANCHOR_LEFT_UPPER, - string cBarPrefix = "C", - string pBarPrefix = "P", - string openLabel = "O", - string closeLabel = "C", - string highLabel = "H", - string lowLabel = "L", - string midLineLabel = "Mid" // -) -{ - // - // Medium Market ... - iDescriptor.inputs.mMarketPeriod = period; - iDescriptor.inputs.mMarketMethod = method; - - // - ConfigureMarketDrawSpecs( - iDescriptor.inputs.mMarketInputs, - // - drawLabels, - drawCBar, - drawPBar, - drawCBarMid, - drawPBarMid, - fontSize, - fontAngel, - fontName, - fontAnchor, - prefix, - cBarPrefix, - pBarPrefix, - openLabel, - closeLabel, - highLabel, - lowLabel, - midLineLabel // - ); -} - -// -// Long ... -void ConfigureLongMarketDrawSpecs( - X121ProviderDescriptor &iDescriptor, - ENUM_TIMEFRAMES period = NULL, - ENUM_X_PERIOD_METHOD method = X_PERIOD_AUTO, - string prefix = "Long", - bool drawLabels = false, - bool drawCBar = false, - bool drawPBar = false, - bool drawCBarMid = false, - bool drawPBarMid = false, - int fontSize = 12, - double fontAngel = 90, - string fontName = "Arial", - ENUM_ANCHOR_POINT fontAnchor = ANCHOR_LEFT_UPPER, - string cBarPrefix = "C", - string pBarPrefix = "P", - string openLabel = "O", - string closeLabel = "C", - string highLabel = "H", - string lowLabel = "L", - string midLineLabel = "Mid" // -) -{ - // - // Long Market ... - iDescriptor.inputs.lMarketPeriod = period; - iDescriptor.inputs.lMarketMethod = method; - - // - ConfigureMarketDrawSpecs( - iDescriptor.inputs.lMarketInputs, - // - drawLabels, - drawCBar, - drawPBar, - drawCBarMid, - drawPBarMid, - fontSize, - fontAngel, - fontName, - fontAnchor, - prefix, - cBarPrefix, - pBarPrefix, - openLabel, - closeLabel, - highLabel, - lowLabel, - midLineLabel // - ); -} - -// -// Hind ... -void ConfigureHindMarketDrawSpecs( - X121ProviderDescriptor &iDescriptor, - ENUM_TIMEFRAMES period = NULL, - ENUM_X_PERIOD_METHOD method = X_PERIOD_AUTO, - string prefix = "Hind", - bool drawLabels = false, - bool drawCBar = false, - bool drawPBar = false, - bool drawCBarMid = false, - bool drawPBarMid = false, - int fontSize = 12, - double fontAngel = 90, - string fontName = "Arial", - ENUM_ANCHOR_POINT fontAnchor = ANCHOR_LEFT_UPPER, - string cBarPrefix = "C", - string pBarPrefix = "P", - string openLabel = "O", - string closeLabel = "C", - string highLabel = "H", - string lowLabel = "L", - string midLineLabel = "Mid" // -) -{ - // - // Hind Market ... - iDescriptor.inputs.hMarketPeriod = period; - iDescriptor.inputs.hMarketMethod = method; - - // - ConfigureMarketDrawSpecs( - iDescriptor.inputs.hMarketInputs, - // - drawLabels, - drawCBar, - drawPBar, - drawCBarMid, - drawPBarMid, - fontSize, - fontAngel, - fontName, - fontAnchor, - prefix, - cBarPrefix, - pBarPrefix, - openLabel, - closeLabel, - highLabel, - lowLabel, - midLineLabel // - ); -} - -// -// Configure Market ... -void ConfigureMarketDrawSpecs( - X121MCycleInputs &inputs, - bool drawLabels = false, - bool drawCBar = false, - bool drawPBar = false, - bool drawCBarMid = false, - bool drawPBarMid = false, - int fontSize = 12, - double fontAngel = 90, - string fontName = "Arial", - ENUM_ANCHOR_POINT fontAnchor = ANCHOR_LEFT_UPPER, - string prefix = "", - string cBarPrefix = "C", - string pBarPrefix = "P", - string openLabel = "O", - string closeLabel = "C", - string highLabel = "H", - string lowLabel = "L", - string midLineLabel = "Mid" // -) -{ - inputs.drawLabels = drawLabels; - inputs.drawCBar = drawCBar; - inputs.drawPBar = drawPBar; - inputs.drawCBarMid = drawCBarMid; - inputs.drawPBarMid = drawPBarMid; - inputs.cBarDrawSpecs.Default(); - inputs.pBarDrawSpecs.Default(); - - // - if (drawCBarMid) - { - inputs.cBarMidDrawSpecs.clr = clrYellow; - } - - // - if (drawPBarMid) - { - inputs.pBarMidDrawSpecs.clr = clrYellow; - } - - // - if (drawLabels) - { - // - string cBarStr = prefix + " " + cBarPrefix + " "; - string pBarStr = prefix + " " + pBarPrefix + " "; - - // - if (drawCBar) - { - // - inputs.cBarDrawSpecs.openStyle.Label( - cBarStr + openLabel, - inputs.cBarDrawSpecs.openStyle.clr, - fontName, - fontSize, - fontAnchor, - fontAngel // - ); - - // - inputs.cBarDrawSpecs.highStyle.Label( - cBarStr + highLabel, - inputs.cBarDrawSpecs.highStyle.clr, - fontName, - fontSize, - fontAnchor, - fontAngel // - ); - - // - inputs.cBarDrawSpecs.closeStyle.Label( - cBarStr + closeLabel, - inputs.cBarDrawSpecs.closeStyle.clr, - fontName, - fontSize, - fontAnchor, - fontAngel // - ); - - // - inputs.cBarDrawSpecs.lowStyle.Label( - cBarStr + lowLabel, - inputs.cBarDrawSpecs.lowStyle.clr, - fontName, - fontSize, - fontAnchor, - fontAngel // - ); - } - - // - if (drawPBar) - { - // - inputs.pBarDrawSpecs.openStyle.Label( - pBarStr + openLabel, - inputs.pBarDrawSpecs.openStyle.clr, - fontName, - fontSize, - fontAnchor, - fontAngel // - ); - - // - inputs.pBarDrawSpecs.highStyle.Label( - pBarStr + highLabel, - inputs.pBarDrawSpecs.highStyle.clr, - fontName, - fontSize, - fontAnchor, - fontAngel // - ); - - // - inputs.pBarDrawSpecs.closeStyle.Label( - pBarStr + closeLabel, - inputs.pBarDrawSpecs.closeStyle.clr, - fontName, - fontSize, - fontAnchor, - fontAngel // - ); - - // - inputs.pBarDrawSpecs.lowStyle.Label( - pBarStr + lowLabel, - inputs.pBarDrawSpecs.lowStyle.clr, - fontName, - fontSize, - fontAnchor, - fontAngel // - ); - } - - // - if (drawCBarMid) - { - // - inputs.cBarMidDrawSpecs.Label( - cBarStr + midLineLabel, - clrYellow, - fontName, - fontSize, - fontAnchor, - fontAngel // - ); - } - - // - if (drawPBarMid) - { - // - inputs.pBarMidDrawSpecs.Label( - pBarStr + midLineLabel, - clrYellow, - fontName, - fontSize, - fontAnchor, - fontAngel // - ); - } - } -} - -// -void ApplyPreDefineConfigurations(X121ProviderDescriptor &iDescriptor) -{ - // - bool isX786 = false; - bool isX121 = false; - bool isX110 = false; - - // - if (isX786) - { - } - - // - if (isX121) - { - } - - // - if (isX110) - { - // - iDescriptor.inputs.strInputs.showTrends = isX110; - - // - iDescriptor.inputs.mcInputs.showVerifierMa = isX110; - - // - iDescriptor.inputs.ichInputs.showKumo = true; // isX110; - iDescriptor.inputs.ichInputs.showKijunSen = true; // isX110; - iDescriptor.inputs.ichInputs.showTenkanSen = true; // isX110; - iDescriptor.inputs.ichInputs.showSenkouSpanA = isX110; - iDescriptor.inputs.ichInputs.showSenkouSpanB = isX110; - - // - iDescriptor.inputs.cheInputs.showLongExit1Line = isX110; - iDescriptor.inputs.cheInputs.showShortExit1Line = isX110; - iDescriptor.inputs.cheInputs.showLongExit2Line = isX110; - iDescriptor.inputs.cheInputs.showShortExit2Line = isX110; - - // - iDescriptor.inputs.pvInputs.showPeaksAndVales = isX110; - iDescriptor.inputs.pvInputs.showFibo1Levels = isX110; - iDescriptor.inputs.pvInputs.showFibo2Levels = isX110; - iDescriptor.inputs.pvInputs.showFibo3Levels = isX110; - iDescriptor.inputs.pvInputs.showFibo4Levels = isX110; - iDescriptor.inputs.pvInputs.showFibo5Levels = isX110; - } - - // - iDescriptor.inputs.ichInputs.showKumo = false; // isX110; - iDescriptor.inputs.ichInputs.showKijunSen = false; // isX110; - iDescriptor.inputs.ichInputs.showTenkanSen = false; // isX110; -} - -// \ No newline at end of file diff --git a/Libraries/x-saherelm.xtrade.lib.mq5 b/Libraries/x-saherelm.xtrade.lib.mq5 index d16e9245..1d7e85c2 100644 --- a/Libraries/x-saherelm.xtrade.lib.mq5 +++ b/Libraries/x-saherelm.xtrade.lib.mq5 @@ -24,7 +24,6 @@ #include #include "../Libraries/x-saherelm.draw.lib.mq5" #include "../Libraries/x-saherelm.common.lib.mq5" -#include "../Classes/x-saherelm.xdata-collector.class.mq5" // // Definitions ... @@ -2894,190 +2893,6 @@ typedef void (*TOnTradeStateChanged)(const XOnTradeHandlerState &state); // // Classes ... -// -// Create a Signal Specfic Data Collector ... -class XSCSignalCollector -{ - // - // Public ... -public: - // - // Props ... - - // - // Constructor ... - void XSCSignalCollector() - { - // - XSCDataCollector mBase; - mBase.Clear(); - } - - // - // Deconstructor ... - - // - // Tools ... - - // - // Inheritanced Functions ... - - // - // Cleaning Store ... - void Clear() - { - // - XSCDataCollector mBase; - - // - mBase.Clear(); - } - - // - // Collect All Store ... - int Collect(XSignal &result[]) - { - // - int mResult = 0; - - // - XSCDataCollector mBase; - - // - mResult = mBase.Collect(result); - - // - return mResult; - } - - // - // Add Item To Store ... - bool Add(XSignal &item) - { - // - bool result = false; - - // - XSCDataCollector mBase; - - // - result = mBase.Add(item); - - // - return result; - } - - // - // Add Item(s) To Store ... - int Add(XSignal &items[]) - { - // - int result = 0; - - // - XSCDataCollector mBase; - - // - result = mBase.Add(items); - - // - return result; - } - - // - // Remove an Item from Store ... - bool Remove(XSignal &item) - { - // - bool result = false; - - // - XSCDataCollector mBase; - - // - result = mBase.Remove(item); - - // - return result; - } - - // - // Custom Functions ... - - // - int CollectSignals( - XSignal &result[], // Hold Result - string symbol = NULL, // Trading Symbol - string provider = NULL, // Signal Provider - ENUM_TIMEFRAMES period = NULL, // Trading Timeframe - ENUM_POSITION_TYPE type = NULL, // Long (Buy), Short (Sell) - ENUM_X_ORDER_MODES mode = NULL // Execution Mode - ) - { - // - int mResult = 0; - - // - XSignal signals[]; - int signalsCount = Collect(signals); - if (signalsCount <= 0) - { - return mResult; - } - - // - mResult = ArraySize(result); - - // - // Now we Have to Apply Filters ... - for (int i = 0; i < signalsCount; i++) - { - // - XSignal iSignal = signals[i]; - - // - bool isFiltersPassed = - iSignal.IsFiltersPassed( - symbol, - provider, - period, - type, - mode - // - ); - if (!isFiltersPassed) - { - continue; - } - - // - AddRef( - iSignal, - result - // - ); - } - - // - return mResult; - } - - // - // Protected ... -protected: - // - // Tools ... - - // - // Private ... -private: - // - // Props ... - - // - // Tools ... -}; - // // Tools ...