diff --git a/BKP/Main/Providers/x-saherelm.xuspy5.provider.indicators.lib.mq5 b/BKP/Main/Providers/x-saherelm.xuspy5.provider.indicators.lib.mq5 index 7a1f9b6b..a09daa41 100644 --- a/BKP/Main/Providers/x-saherelm.xuspy5.provider.indicators.lib.mq5 +++ b/BKP/Main/Providers/x-saherelm.xuspy5.provider.indicators.lib.mq5 @@ -1959,6 +1959,23 @@ bool XUSPY5XTDHasLongSignal() // ) // + || + // + // Check LC Fast Over Slow ... + ((mConditions.isXCHMALCTrendsDown || + mConditions.isXCHMALCFastOverSlow) && + ( + // + (mConditions.isXCHMALCPeak && + mConditions.isXTSCurrentMax && + mConditions.isXCHMASCOverMax && + mConditions.isXFICrossedOverZero && + mConditions.isXTDSignalCrossedOverBear) + // + ) + // + ) + // ) // ) diff --git a/Documents/Templates/Brokers List.txt b/Documents/Templates/Brokers List.txt index a758252c..10eb3c55 100644 --- a/Documents/Templates/Brokers List.txt +++ b/Documents/Templates/Brokers List.txt @@ -12,7 +12,7 @@ All Markets XTD ---- -Resolve XUSPY5 XTD All Longs Stopouts in AMarkets-Real, GrowthNext ... +Resolve XUSPY5 XTD All Longs Stopouts in OANDA ... Resolve XUSPY5 XTD All Critical Guard Attacks in All Markets ... Resolve XUSPY5 XTD All Guard Attacks in All Markets ... diff --git a/Projects/XUSCHF5/Classes/x-saherelm.provider.lib.mq5 b/Projects/XUSCHF5/Classes/x-saherelm.provider.lib.mq5 index 765544c7..63279162 100644 --- a/Projects/XUSCHF5/Classes/x-saherelm.provider.lib.mq5 +++ b/Projects/XUSCHF5/Classes/x-saherelm.provider.lib.mq5 @@ -254,14 +254,14 @@ struct XMarketConditions // // -class XCPriver : public XCBase +class XCProvider : public XCBase { // // Public ... public: // // Constructor ... - XCPriver( + XCProvider( // // Common Requirements ... string xSymbol, // Which Symbol is Used @@ -362,7 +362,7 @@ public: // // Deconstructor ... - ~XCPriver() {} + ~XCProvider() {} // // START Common Functions ... diff --git a/Projects/XUSCHF5/Experts/x-saherelm.xuspy5.ea.mq5 b/Projects/XUSCHF5/Experts/x-saherelm.xuspy5.ea.mq5 new file mode 100644 index 00000000..56b7b4c9 --- /dev/null +++ b/Projects/XUSCHF5/Experts/x-saherelm.xuspy5.ea.mq5 @@ -0,0 +1,399 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 Expert Advisor +// ---------------------------------------- +// Name: XUSPY5 +// Description: this is an expert controller +// advisors which provides a mechanism for use them ... +// +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// +// +// Global Properties ... +#property copyright "Copyright 2023, SaherElm IT Center" +#property link "https://saherelm.ir" +#property version "1.00" +#property description "SaherElm XUSPY5 EA" +#property strict + +// +// START Inputs ... +// + +input group "Commons"; + +// +// XCTIMER inputs ... +input bool xUSPY5ShowCandleTimer = true; // Show Condle Remaining Time +input color xUSPY5CandleTimerColot = clrYellow; // Candle Timer Color +input ENUM_BASE_CORNER xUSPY5CandleTimerCorner = CORNER_RIGHT_LOWER; // Where to Show Candle Timer + +// +// END Inputs ... +// + +// +// START Including Providers ... +// + +// +// Logger Library ... +#include "../Libraries/x-saherelm.log.lib.mq5" + +// +// Common Library ... +#include "../Libraries/x-saherelm.common.lib.mq5" + +// +// Alert Library ... +#include "../Libraries/x-saherelm.alert.lib.mq5" + +// +// Draw Library ... +#include "../Libraries/x-saherelm.draw.lib.mq5" + +// +// XUSPY5 Signal Provider ... +#include "../Providers/x-saherelm.xuspy5.provider.lib.mq5" + +// +// END Including Providers ... +// + +// +// START Global Definitions: Variables, Properties and etc ... +// +bool isXUSPY5NewHour; +bool isXUSPY5NewDay; +bool isXUSPY5NewWeek; +bool isXUSPY5NewMonth; + +// +int xUSPY5CTimerHandler = INVALID_HANDLE; +// +// END Global Definitions: Variables, Properties and etc ... +// + +// +// START Event Handlers ... +// + +// +// Initialization ... +int OnInit() +{ + // + logTag = "XUSPY5EA"; + drawPrefix = logTag; + alertPrefix = logTag; + + // + // Apply default Chart Style for EA ... + ApplyChartStyle(); + + // + // Reset Timings ... + ResetTiming(); + + // + // Validate Inputs ... + if (!ValidateInputs()) + { + return INIT_PARAMETERS_INCORRECT; + } + + // + // Initialize XUSPY5 Provider ... + if (!XUSPY5InitSignalProviderLibrary()) + { + return INIT_PARAMETERS_INCORRECT; + } + + // + // Init XCTimer ... + if (xUSPY5ShowCandleTimer) + { + if (!XUSPY5CTimerInit()) + { + return INIT_FAILED; + } + } + + // + // 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 + + // + // Here we can handle De Initialization Reasons ... + + // + // De Initialize XUSPY5 Provider ... + XUSPY5DeinitSignalProviderLibrary(reason); + + // + // De Init XDraw Library ... + // OnDeinitDrawLibrary(); + + // + IndicatorRelease(xUSPY5CTimerHandler); +} + +// +// On Tick Handler ... +void OnTick() +{ + // + // Handle Monthly Alert ... + bool isFirstMonth = xMonth == -1; + isXUSPY5NewMonth = IsNewMonth(); + bool canMonthlyAlert = + isXUSPY5NewMonth && + xUSPY5EnableAlerts && + xUSPY5EnableMonthlyAlerts; + bool canMonthlyReport = + !isFirstMonth && + canMonthlyAlert && + xUSPY5EnableMonthlyReports; + if (canMonthlyAlert) + { + // + string message = "New Month ..."; + + // + // Prepare Monthly Report ... + if (canMonthlyReport) + { + // + string report = xUSPY5Reporter.GenerateReportString(XREPORT_MONTHLY); + + // + message = "Last Month Report:\n" + report; + } + + // + // Reset Report ... + xUSPY5Reporter.Reset(XREPORT_MONTHLY); + + // + SendAlert(message); + } + + // + // Handle Weekly Alert ... + bool isFirstWeek = xDayOfWeek == -1; + isXUSPY5NewWeek = IsNewWeek(); + bool canWeeklyAlert = + isXUSPY5NewWeek && + xUSPY5EnableAlerts && + xUSPY5EnableWeeklyAlerts; + bool canWeeklyReport = + !isFirstWeek && + canWeeklyAlert && + xUSPY5EnableWeeklyReports; + if (canWeeklyAlert) + { + // + string message = "New Week ..."; + + // + // Prepare Weekly Report ... + if (canWeeklyReport) + { + // + string report = xUSPY5Reporter.GenerateReportString(XREPORT_WEEKLY); + + // + message = "Last Week Report:\n" + report; + } + + // + // Reset Report ... + xUSPY5Reporter.Reset(XREPORT_WEEKLY); + + // + SendAlert(message); + } + + // + // Handle Daily Alert ... + bool isFirstDay = xDay == -1; + isXUSPY5NewDay = IsNewDay(); + bool canDailyAlert = + isXUSPY5NewDay && + xUSPY5EnableAlerts && + xUSPY5EnableDailyAlerts; + bool canDailyReport = + !isFirstDay && + canDailyAlert && + xUSPY5EnableDailyReports; + if (canDailyAlert) + { + // + string message = "New Day ..."; + + // + // Prepare Daily Report ... + if (canDailyReport) + { + // + string report = xUSPY5Reporter.GenerateReportString(XREPORT_DAILY); + + // + message = "Last Week Report:\n" + report; + } + + // + // Reset Report ... + xUSPY5Reporter.Reset(XREPORT_DAILY); + + // + SendAlert(message); + } + + // + // Handle Hourly Alert ... + bool isFirstHour = xHour == -1; + isXUSPY5NewHour = IsNewHour(); + bool canHourlyAlert = + isXUSPY5NewHour && + xUSPY5EnableAlerts && + xUSPY5EnableHourlyAlerts; + if (canHourlyAlert) + { + // + string message = "New Hour ..."; + + // + SendAlert(message); + } + + // + // Prevent Going Forward if user Disable it ... + if (xUSPY5EnableProvider) + { + // + // Handle Processing on XUSPY5 Signal Provider ... + XUSPY5SignalProviderDoControlState(); + } + + // + // Check Can Ignore Tick or not .. + bool canIgnoreTick = xUSPY5IsTestMode + ? !IsNewCandle() + : !IsNewCandle() && xUSPY5WaitUntilNextCandle; + if (canIgnoreTick) + { + return; + } + + // + xUSPY5WaitUntilNextCandle = false; + + // + // Prevent Going Forward if user Disable it ... + if (xUSPY5EnableProvider) + { + // + // Handle Processing on XUSPY5 Signal Provider ... + XUSPY5SignalProviderHandleTick(); + } +} + +// +// Handle Trade Events ... +void OnTrade() +{ + + // + // Prevent Going Forward if user Disable it ... + if (xUSPY5EnableProvider) + { + // + // Handle Processing Trades on XUSPY5 Signal Provider ... + XUSPY5SignalProviderHandleTrade(); + } +} + +// +// END Event Handlers ... +// + +// +// START Functions ... +// + +// +// Validate Input Args for Initialization ... +bool ValidateInputs() +{ + // + bool result = false; + + // + // Validate Args ... + + // + // Validate XUSPY5 Provider Inputs ... + result = XUSPY5ValidateInputs(); + if (!result) + { + return false; + } + + // + // Logging State ... + string message = "Validation of (" + logTag + ") Inputs " + (result ? "Succeeded" : "Failed") + " ..."; + LogMessage(message); + + // + return result; +} + +bool XUSPY5CTimerInit() +{ + // + bool result = true; + + // + xUSPY5CTimerHandler = iCustom( + _Symbol, + _Period, + "x-saherelm.xctimer.indicator", + // + // Inputs ... + xUSPY5CandleTimerColot, + xUSPY5CandleTimerCorner); + + // + if (xUSPY5CTimerHandler == INVALID_HANDLE) + { + result = false; + } + + // + return result; +} +// +// END Functions ... +// diff --git a/Projects/XUSCHF5/Providers/x-saherelm.xuspy5.provider.indicators.lib.mq5 b/Projects/XUSCHF5/Providers/x-saherelm.xuspy5.provider.indicators.lib.mq5 new file mode 100644 index 00000000..a09daa41 --- /dev/null +++ b/Projects/XUSCHF5/Providers/x-saherelm.xuspy5.provider.indicators.lib.mq5 @@ -0,0 +1,6787 @@ +/////////////////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 XUSPY5 Signal Provider Indicators Library +// ---------------------------------------------------------------- +// +// 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 + +// +// Include Provider Inputs ... +#include "x-saherelm.xuspy5.provider.inputs.lib.mq5" + +// +// Include Provider Class ... +#include "../Classes/x-saherelm.provider.lib.mq5" + +// +// Signallers ... +input group "XUSPY5 Signallers"; + +// +// XTD ... +input group "XUSPY5 XTD Signaller"; +input bool xUSPY5XTDEnableSignaller = true; // Enable Signaller +input bool xUSPY5XTDAllowLongSignals = true; // Enable Long Signals +input bool xUSPY5XTDAllowShortSignals = true; // Enable Short Signals + +// +// XTAM ... +input group "XUSPY5 XTAM Signaller"; +input bool xUSPY5XTAMEnableSignaller = true; // Enable Signaller +input bool xUSPY5XTAMAllowLongSignals = true; // Enable Long Signals +input bool xUSPY5XTAMAllowShortSignals = true; // Enable Short Signals + +// +// XSI ... +input group "XUSPY5 XSI Signaller"; +input bool xUSPY5XSIEnableSignaller = true; // Enable Signaller +input bool xUSPY5XSIAllowLongSignals = true; // Enable Long Signals +input bool xUSPY5XSIAllowShortSignals = true; // Enable Short Signals + +// +// XTSFI ... +input group "XUSPY5 XTSFI Signaller"; +input bool xUSPY5XTSFIEnableSignaller = true; // Enable Signaller +input bool xUSPY5XTSFIAllowLongSignals = true; // Enable Long Signals +input bool xUSPY5XTSFIAllowShortSignals = true; // Enable Short Signals + +// +// XOBDLH ... +// input group "XUSPY5 XOBDLH Signaller"; +// input bool xUSPY5XOBDLHEnableSignaller = true; // Enable Signaller +// input bool xUSPY5XOBDLHAllowLongSignals = true; // Enable Long Signals +// input bool xUSPY5XOBDLHAllowShortSignals = true; // Enable Short Signals + +// +// XCHMACC ... +input group "XUSPY5 XCHMACC Signaller"; +input bool xUSPY5XCHMACCEnableSignaller = true; // Enable Signaller +input bool xUSPY5XCHMACCAllowLongSignals = true; // Enable Long Signals +input bool xUSPY5XCHMACCAllowShortSignals = true; // Enable Short Signals + +// +// XCHMAMX ... +// input group "XUSPY5 XCHMAMX Signaller"; +// input bool xUSPY5XCHMAMXEnableSignaller = true; // Enable Signaller +// input bool xUSPY5XCHMAMXAllowLongSignals = true; // Enable Long Signals +// input bool xUSPY5XCHMAMXAllowShortSignals = true; // Enable Short Signals + +// +// XCHMAMN ... +// input group "XUSPY5 XCHMAMN Signaller"; +// input bool xUSPY5XCHMAMNEnableSignaller = true; // Enable Signaller +// input bool xUSPY5XCHMAMNAllowLongSignals = true; // Enable Long Signals +// input bool xUSPY5XCHMAMNAllowShortSignals = true; // Enable Short Signals + +// +// Check in Test Mode or not ... +bool xUSPY5IsTestMode = false; + +// +// Detect max Input Length of Indicators ... +int xUSPY5MaxLengthOfInputs = 0; + +// +// Detect Calculated Bars ... +int xUSPY5CalculatedBars = 0; + +// +// Check prevent Double Signalling on Same Candle ... +bool xUSPY5WaitUntilNextCandle = false; + +// +// Signaller Variables ... +// +// XTD ... +bool xUSPY5MXTDEnableSignaller = xUSPY5XTDEnableSignaller; +bool xUSPY5MXTDAllowLongSignals = xUSPY5XTDAllowLongSignals; +bool xUSPY5MXTDAllowShortSignals = xUSPY5XTDAllowShortSignals; + +// +// XTAM ... +bool xUSPY5MXTAMEnableSignaller = xUSPY5XTAMEnableSignaller; +bool xUSPY5MXTAMAllowLongSignals = xUSPY5XTAMAllowLongSignals; +bool xUSPY5MXTAMAllowShortSignals = xUSPY5XTAMAllowShortSignals; + +// +// XSI ... +bool xUSPY5MXSIEnableSignaller = xUSPY5XSIEnableSignaller; +bool xUSPY5MXSIAllowLongSignals = xUSPY5XSIAllowLongSignals; +bool xUSPY5MXSIAllowShortSignals = xUSPY5XSIAllowShortSignals; + +// +// XTSFI ... +bool xUSPY5MXTSFIEnableSignaller = xUSPY5XTSFIEnableSignaller; +bool xUSPY5MXTSFIAllowLongSignals = xUSPY5XTSFIAllowLongSignals; +bool xUSPY5MXTSFIAllowShortSignals = xUSPY5XTSFIAllowShortSignals; + +// +// XOBDLH ... +bool xUSPY5MXOBDLHEnableSignaller = false; // xUSPY5XOBDLHEnableSignaller; +bool xUSPY5MXOBDLHAllowLongSignals = false; // xUSPY5XOBDLHAllowLongSignals; +bool xUSPY5MXOBDLHAllowShortSignals = false; // xUSPY5XOBDLHAllowShortSignals; + +// +// XCHMACC ... +bool xUSPY5MXCHMACCEnableSignaller = xUSPY5XCHMACCEnableSignaller; +bool xUSPY5MXCHMACCAllowLongSignals = xUSPY5XCHMACCAllowLongSignals; +bool xUSPY5MXCHMACCAllowShortSignals = xUSPY5XCHMACCAllowShortSignals; + +// +// XCHMAMX ... +bool xUSPY5MXCHMAMXEnableSignaller = false; // xUSPY5XCHMAMXEnableSignaller; +bool xUSPY5MXCHMAMXAllowLongSignals = false; // xUSPY5XCHMAMXAllowLongSignals; +bool xUSPY5MXCHMAMXAllowShortSignals = false; // xUSPY5XCHMAMXAllowShortSignals; + +// +// XCHMAMN ... +bool xUSPY5MXCHMAMNEnableSignaller = false; // xUSPY5XCHMAMNEnableSignaller; +bool xUSPY5MXCHMAMNAllowLongSignals = false; // xUSPY5XCHMAMNAllowLongSignals; +bool xUSPY5MXCHMAMNAllowShortSignals = false; // xUSPY5XCHMAMNAllowShortSignals; + +// +XCProvider *xUSPY5Provider; + +// +// Validate Indicators Inputs ... +bool XUSPY5ValidateIndicatorsInputs() +{ + // + bool result = false; + + // + // XTM ... + result = XTMValidateInputs(); + if (!result) + { + return result; + } + + // + // XAMA ... + result = XAMAValidateInputs(); + if (!result) + { + return result; + } + + // + // XTD ... + result = XTDValidateInputs(); + if (!result) + { + return result; + } + + // + // XFI ... + result = XFIValidateInputs(); + if (!result) + { + return result; + } + + // + // XTS ... + result = XTSValidateInputs(); + if (!result) + { + return result; + } + + // + // XOBD ... + result = XOBDValidateInputs(); + if (!result) + { + return result; + } + + // + // XLH ... + result = XLHValidateInputs(); + if (!result) + { + return result; + } + + // + // XRSI ... + result = XRSIValidateInputs(); + if (!result) + { + return result; + } + + // + // XCHLH ... + result = XCHLHValidateInputs(); + if (!result) + { + return result; + } + + // + // XCHMA ... + result = XCHMAValidateInputs(); + if (!result) + { + return result; + } + + // + // Make an Instance Of XCProvider Class for Use ... + xUSPY5Provider = new XCProvider( + // + // Commons ... + _Symbol, + _Period, + // + // Signallers ... + // + // XTD ... + xUSPY5MXTDEnableSignaller, + xUSPY5MXTDAllowLongSignals, + xUSPY5MXTDAllowShortSignals, + // + // XTAM ... + xUSPY5MXTAMEnableSignaller, + xUSPY5MXTAMAllowLongSignals, + xUSPY5MXTAMAllowShortSignals, + // + // XSI ... + xUSPY5MXSIEnableSignaller, + xUSPY5MXSIAllowLongSignals, + xUSPY5MXSIAllowShortSignals, + // + // XTSFI ... + xUSPY5MXTSFIEnableSignaller, + xUSPY5MXTSFIAllowLongSignals, + xUSPY5MXTSFIAllowShortSignals, + // + // XOBDLH ... + xUSPY5MXOBDLHEnableSignaller, + xUSPY5MXOBDLHAllowLongSignals, + xUSPY5MXOBDLHAllowShortSignals, + // + // XCHMACC ... + xUSPY5MXCHMACCEnableSignaller, + xUSPY5MXCHMACCAllowLongSignals, + xUSPY5MXCHMACCAllowShortSignals, + // + // XCHMAMX ... + xUSPY5MXCHMAMXEnableSignaller, + xUSPY5MXCHMAMXAllowLongSignals, + xUSPY5MXCHMAMXAllowShortSignals, + // + // XCHMAMN ... + xUSPY5MXCHMAMNEnableSignaller, + xUSPY5MXCHMAMNAllowLongSignals, + xUSPY5MXCHMAMNAllowShortSignals + // + ); + + // + result = true; + + // + return result; +} + +// +// Init Indicators ... +bool XUSPY5InitIndicators() +{ + // + bool result = false; + + // + // Make it Enable when we need to Log Market Conditions ... + xUSPY5IsTestMode = IsRunningOnTestMode(); + + // + // Check and Calculate Max Length in Inputs ... + // + + // + // XTM ... + xUSPY5MaxLengthOfInputs = MathMax( + xTMMaPeriod, + xUSPY5NumberOfItemsPerTick); + + // + // XAMA ... + xUSPY5MaxLengthOfInputs = MathMax( + xAMALength, + xUSPY5NumberOfItemsPerTick); + xUSPY5MaxLengthOfInputs = MathMax( + xAMAFastEMA, + xUSPY5NumberOfItemsPerTick); + xUSPY5MaxLengthOfInputs = MathMax( + xAMASlowEMA, + xUSPY5NumberOfItemsPerTick); + + // + // XLH ... + xUSPY5MaxLengthOfInputs = MathMax( + xLHLength, + xUSPY5NumberOfItemsPerTick); + + // + // XTD ... + xUSPY5MaxLengthOfInputs = MathMax( + xTDLength, + xUSPY5MaxLengthOfInputs); + + // + // XFI ... + xUSPY5MaxLengthOfInputs = MathMax( + xFILength, + xUSPY5MaxLengthOfInputs); + + // + // XRSI ... + xUSPY5MaxLengthOfInputs = MathMax( + xRSILength, + xUSPY5MaxLengthOfInputs); + + // + // XOBD ... + xUSPY5MaxLengthOfInputs = MathMax( + xOBDLength, + xUSPY5MaxLengthOfInputs); + + // + // XCHLH ... + xUSPY5MaxLengthOfInputs = MathMax( + xCHLHLcLength, + xUSPY5MaxLengthOfInputs); + xUSPY5MaxLengthOfInputs = MathMax( + xCHLHMcLength, + xUSPY5MaxLengthOfInputs); + xUSPY5MaxLengthOfInputs = MathMax( + xCHLHScLength, + xUSPY5MaxLengthOfInputs); + + // + // XCHMA ... + xUSPY5MaxLengthOfInputs = MathMax( + xCHMAScFastLength, + xUSPY5MaxLengthOfInputs); + xUSPY5MaxLengthOfInputs = MathMax( + xCHMAScSlowLength, + xUSPY5MaxLengthOfInputs); + xUSPY5MaxLengthOfInputs = MathMax( + xCHMAMcFastLength, + xUSPY5MaxLengthOfInputs); + xUSPY5MaxLengthOfInputs = MathMax( + xCHMAMcSlowLength, + xUSPY5MaxLengthOfInputs); + xUSPY5MaxLengthOfInputs = MathMax( + xCHMALcFastLength, + xUSPY5MaxLengthOfInputs); + xUSPY5MaxLengthOfInputs = MathMax( + xCHMALcSlowLength, + xUSPY5MaxLengthOfInputs); + + // + // Validate Indicators Inputs before Initialization ... + result = XUSPY5ValidateIndicatorsInputs(); + if (!result) + { + return result; + } + + // + // Validate Signallers ... + + // + // XTD ... + bool isXTDEnable = + xUSPY5XTDEnableSignaller && + (xUSPY5XTDAllowLongSignals || + xUSPY5XTDAllowShortSignals); + + // + // XTAM ... + bool isXTAMEnable = + xUSPY5XTAMEnableSignaller && + (xUSPY5XTAMAllowLongSignals || + xUSPY5XTAMAllowShortSignals); + + // + // XSI ... + bool isXSIEnable = + xUSPY5XSIEnableSignaller && + (xUSPY5XSIAllowLongSignals || + xUSPY5XSIAllowShortSignals); + + // + // XTSFI ... + bool isXTSFIEnable = + xUSPY5XTSFIEnableSignaller && + (xUSPY5XTSFIAllowLongSignals || + xUSPY5XTSFIAllowShortSignals); + + // + // XOBDLH ... + bool isXOBDLHEnable = false; + // xUSPY5XOBDLHEnableSignaller && + // (xUSPY5XOBDLHAllowLongSignals || + // xUSPY5XOBDLHAllowShortSignals); + + // + // XCHMACC ... + bool isXCHMACCEnable = + xUSPY5XCHMACCEnableSignaller && + (xUSPY5XCHMACCAllowLongSignals || + xUSPY5XCHMACCAllowShortSignals); + + // + // XCHMAMX ... + bool isXCHMAMXEnable = false; + // xUSPY5XCHMAMXEnableSignaller && + // (xUSPY5XCHMAMXAllowLongSignals || + // xUSPY5XCHMAMXAllowShortSignals); + + // + // XCHMAMN ... + bool isXCHMAMNEnable = false; + // xUSPY5XCHMAMNEnableSignaller && + // (xUSPY5XCHMAMNAllowLongSignals || + // xUSPY5XCHMAMNAllowShortSignals); + + // + bool hasSignaller = + // + isXTDEnable || + isXTAMEnable || + isXSIEnable || + isXTSFIEnable || + isXOBDLHEnable || + isXCHMACCEnable || + isXCHMAMXEnable || + isXCHMAMNEnable + // + ; + result = hasSignaller; + if (!result) + { + // + LogMessage("XUSPY5 doesn't enable any Signaller ..."); + + // + return result; + } + + // + // Initialize Indicator/Oscillator Handlers ... + ResetLastError(); + + // + // XTM Init ... + result = XTMInitHandlers(); + if (!result) + { + return result; + } + + // + // XAMA Init ... + result = XAMAInitHandlers(); + if (!result) + { + return result; + } + + // + // XLH Init ... + result = XLHInitHandlers(); + if (!result) + { + return result; + } + + // + // XTD Init ... + result = XTDInitHandlers(); + if (!result) + { + return result; + } + + // + // XFI Init ... + result = XFIInitHandlers(); + if (!result) + { + return result; + } + + // + // XTS Init ... + result = XTSInitHandlers(); + if (!result) + { + return result; + } + + // + // XRSI Init ... + result = XRSIInitHandlers(); + if (!result) + { + return result; + } + + // + // XOBD Init ... + result = XOBDInitHandlers(); + if (!result) + { + return result; + } + + // + // XCLH Init ... + result = XCHLHInitHandlers(); + if (!result) + { + return result; + } + + // + // XCHMA Init ... + result = XCHMAInitHandlers(); + if (!result) + { + return result; + } + + // + result = true; + + // + return result; +} + +// +// Release Indicators ... +void XUSPY5ReleaseIndicators() +{ + // + // Release Handlers ... + XTMReleaseHandlers(); + XAMAReleaseHandlers(); + XLHReleaseHandlers(); + XTDReleaseHandlers(); + XFIReleaseHandlers(); + XTSReleaseHandlers(); + XRSIReleaseHandlers(); + XOBDReleaseHandlers(); + XCHMAReleaseHandlers(); + XCHLHReleaseHandlers(); +} + +// +// Handle Reading Buffers ... +void XUSPY5HandleReadingBuffers() +{ + // + // Reading Calculated Bars for a Simple Handler ... + xUSPY5CalculatedBars = BarsCalculated(xTMHandler); + + // + // Read Indicators Buffers ... + XTMReadBuffers(xUSPY5NumberOfItemsPerTick); + XAMAReadBuffers(xUSPY5NumberOfItemsPerTick); + XLHReadBuffers(xUSPY5NumberOfItemsPerTick); + XTDReadBuffers(xUSPY5NumberOfItemsPerTick); + XFIReadBuffers(xUSPY5NumberOfItemsPerTick); + XTSReadBuffers(xUSPY5NumberOfItemsPerTick); + XRSIReadBuffers(xUSPY5NumberOfItemsPerTick); + XOBDReadBuffers(xUSPY5NumberOfItemsPerTick); + XCHMAReadBuffers(xUSPY5NumberOfItemsPerTick); + XCHLHReadBuffers(xUSPY5NumberOfItemsPerTick); + + // + xUSPY5Provider.ReadConditions(); +} + +// +// +// START Combination Functions ... +// +// + +// +// Can Open Long Trade ... +// this is a Function will Check all market Conditions and get all +// Strategy requirement Verifications for Long Signals ... +bool XUSPY5CanOpenLongTrade( + XProvidedSignal &info // Retrieve Signal Additional Info on this Object +) +{ + // + bool result = false; + + // + info.tp = 0; + info.sl = 0; + ArrayResize( + info.signallers, + 0); + + // + bool hasSignal = XUSPY5HasLongSignal(info); + + // + result = + // + hasSignal + // + ; + + // + if (result) + { + xUSPY5Provider.ClearConditions(); + } + + // + return result; +} + +// +// Can Close Long Trade ... +// this is a Function will Check all market Conditions and get all +// Strategy requirement Verifications for Long Signals ... +bool XUSPY5CanCloseLongTrade() +{ + // + bool result = false; + + // + return result; +} + +// +// Can Open Short Trade ... +// this is a Function will Check all market Conditions and get all +// Strategy requirement Verifications for Short Signals ... +bool XUSPY5CanOpenShortTrade( + XProvidedSignal &info // Retrieve Signal Additional Info on this Object +) +{ + // + bool result = false; + + // + info.tp = 0; + info.sl = 0; + ArrayResize( + info.signallers, + 0); + + // + bool hasSignal = XUSPY5HasShortSignal(info); + + // + result = + // + hasSignal + // + ; + + // + if (result) + { + xUSPY5Provider.ClearConditions(); + } + + // + return result; +} + +// +// Can Close Short Trade ... +// this is a Function will Check all market Conditions and get all +// Strategy requirement Verifications for Short Signals ... +bool XUSPY5CanCloseShortTrade() +{ + // + bool result = false; + + // + return result; +} + +// +// +// END Combination Functions ... +// +// + +// +// +// START Combination Signaling ... +// +// + +// +// Check Market Conditions by Combination of Power of All tools for LONGs ... +bool XUSPY5HasLongSignal( + XProvidedSignal &info // Retrieve Signal Additional Info on this Object +) +{ + // + bool result = false; + + // + // XTD ... + bool isXTDHasSignal = XUSPY5XTDHasLongSignal(); + if (isXTDHasSignal) + { + // + Add( + EnumToString(XTD), + info.signallers); + } + + // + // XTAM ... + bool isXTAMHasSignal = XUSPY5XTAMHasLongSignal(); + if (isXTAMHasSignal) + { + // + Add( + EnumToString(XTAM), + info.signallers); + } + + // + // XSI ... + bool isXSIHasSignal = XUSPY5XSIHasLongSignal(); + if (isXSIHasSignal) + { + // + Add( + EnumToString(XSI), + info.signallers); + } + + // + // XTSFI ... + bool isXTSFIHasSignal = XUSPY5XTSFIHasLongSignal(); + if (isXTSFIHasSignal) + { + // + Add( + EnumToString(XTSFI), + info.signallers); + } + + // + // XOBD XLH ... + bool isXOBDLHHasSignal = XUSPY5XOBDLHHasLongSignal(); + if (isXOBDLHHasSignal) + { + // + Add( + EnumToString(XOBDLH), + info.signallers); + } + + // + // XCHMA Cycles Cross ... + bool isXCHMACCHasSignal = XUSPY5XCHMACCHasLongSignal(); + if (isXCHMACCHasSignal) + { + // + Add( + EnumToString(XCHMACC), + info.signallers); + } + + // + // XCHMA Cycles Min ... + bool isXCHMAMNHasSignal = XUSPY5XCHMAMNHasLongSignal(); + if (isXCHMAMNHasSignal) + { + // + Add( + EnumToString(XCHMAMN), + info.signallers); + } + + // + // XCHMA Cycles Max + bool isXCHMAMXHasSignal = XUSPY5XCHMAMXHasLongSignal(); + if (isXCHMAMXHasSignal) + { + // + Add( + EnumToString(XCHMAMX), + info.signallers); + } + + // + result = + // + isXTDHasSignal + // + || + // + isXTAMHasSignal + // + || + // + isXSIHasSignal + // + || + // + isXTSFIHasSignal + // + || + // + isXOBDLHHasSignal + // + || + // + isXCHMACCHasSignal + // + || + // + isXCHMAMNHasSignal + // + || + // + isXCHMAMXHasSignal + // + ; + + // + if (result) + { + // + // Only Log Signals Time Market Conditions if is in Testing Mode ... + if (xUSPY5IsTestMode || xUSPY5EnableSignalAlerts) + { + // + XMarketConditions mConditions = xUSPY5Provider.GetLastMarketCondition(); + string message = xUSPY5Provider.GenerateConditionsString(mConditions); + + // + LogMessage( + "Long Signal Provided by: \n" + + info.signallers[ArraySize(info.signallers) - 1] + "\n" + + "Pusher: " + (string)ArraySize(info.signallers) + "\n" + + "Market Conditions: " + message); + } + } + + // + return result; +} + +// +// Check Market Conditions by Combination of Power of All tools for SHORTs ... +bool XUSPY5HasShortSignal( + XProvidedSignal &info // Retrieve Signal Additional Info on this Object +) +{ + // + bool result = false; + + // + // XTD ... + bool isXTDHasSignal = XUSPY5XTDHasShortSignal(); + if (isXTDHasSignal) + { + // + Add( + EnumToString(XTD), + info.signallers); + } + + // + // XTAM ... + bool isXTAMHasSignal = XUSPY5XTAMHasShortSignal(); + if (isXTAMHasSignal) + { + // + Add( + EnumToString(XTAM), + info.signallers); + } + + // + // XSI ... + bool isXSIHasSignal = XUSPY5XSIHasShortSignal(); + if (isXSIHasSignal) + { + // + Add( + EnumToString(XSI), + info.signallers); + } + + // + // XTSFI ... + bool isXTSFIHasSignal = XUSPY5XTSFIHasShortSignal(); + if (isXTSFIHasSignal) + { + // + Add( + EnumToString(XTSFI), + info.signallers); + } + + // + // XOBD XLH ... + bool isXOBDLHHasSignal = XUSPY5XOBDLHHasShortSignal(); + if (isXOBDLHHasSignal) + { + // + Add( + EnumToString(XOBDLH), + info.signallers); + } + + // + // XCHMA Cycles Cross ... + bool isXCHMACCHasSignal = XUSPY5XCHMACCHasShortSignal(); + if (isXCHMACCHasSignal) + { + // + Add( + EnumToString(XCHMACC), + info.signallers); + } + + // + // XCHMA Cycles Min ... + bool isXCHMAMNHasSignal = XUSPY5XCHMAMNHasShortSignal(); + if (isXCHMAMNHasSignal) + { + // + Add( + EnumToString(XCHMAMN), + info.signallers); + } + + // + // XCHMA Cycles Max + bool isXCHMAMXHasSignal = XUSPY5XCHMAMXHasShortSignal(); + if (isXCHMAMXHasSignal) + { + // + Add( + EnumToString(XCHMAMX), + info.signallers); + } + + // + result = + // + isXTDHasSignal + // + || + // + isXTAMHasSignal + // + || + // + isXSIHasSignal + // + || + // + isXTSFIHasSignal + // + || + // + isXOBDLHHasSignal + // + || + // + isXCHMACCHasSignal + // + || + // + isXCHMAMNHasSignal + // + || + // + isXCHMAMXHasSignal + // + ; + + // + if (result) + { + // + // Only Log Signals Time Market Conditions if is in Testing Mode ... + if (xUSPY5IsTestMode || xUSPY5EnableSignalAlerts) + { + // + XMarketConditions mConditions = xUSPY5Provider.GetLastMarketCondition(); + string message = xUSPY5Provider.GenerateConditionsString(mConditions); + + // + LogMessage( + "Short Signal Provided by: \n" + + info.signallers[ArraySize(info.signallers) - 1] + "\n" + + "Pusher: " + (string)ArraySize(info.signallers) + "\n" + + "Market Conditions: " + message); + } + } + + // + return result; +} + +// +// +// END Combination Signaling ... +// +// + +// +// START Signal Providers ... +// + +// +// Disbale All Signallers Longs ... +void XUSPY5DisableLongSignallers() +{ + // + // XTD ... + if (xUSPY5MXTDEnableSignaller) + { + // + xUSPY5Provider.DisbaleXTDLongs(); + xUSPY5MXTDAllowLongSignals = false; + } + + // + // XTAM ... + if (xUSPY5MXTAMEnableSignaller) + { + // + xUSPY5Provider.DisbaleXTAMLongs(); + xUSPY5MXTAMAllowLongSignals = false; + } + + // + // XSI ... + if (xUSPY5MXSIEnableSignaller) + { + // + xUSPY5Provider.DisbaleXSILongs(); + xUSPY5MXSIAllowLongSignals = false; + } + + // + // XTSFI ... + if (xUSPY5MXTSFIEnableSignaller) + { + // + xUSPY5Provider.DisbaleXTSFILongs(); + xUSPY5MXTSFIAllowLongSignals = false; + } + + // + // XOBDLH ... + // if (xUSPY5MXOBDLHEnableSignaller) + // { + // // + // xUSPY5Provider.DisbaleXOBDLHLongs(); + // xUSPY5MXOBDLHAllowLongSignals = false; + // } + + // + // XCHMACC ... + if (xUSPY5MXCHMACCEnableSignaller) + { + // + xUSPY5Provider.DisbaleXCHMACCLongs(); + xUSPY5MXCHMACCAllowLongSignals = false; + } + + // + // XCHMAMX ... + // if (xUSPY5MXCHMAMXEnableSignaller) + // { + // // + // xUSPY5Provider.DisbaleXCHMAMXLongs(); + // xUSPY5MXCHMAMXAllowLongSignals = false; + // } + + // + // XCHMAMN ... + // if (xUSPY5MXCHMAMNEnableSignaller) + // { + // // + // xUSPY5Provider.DisbaleXCHMAMNLongs(); + // xUSPY5MXCHMAMNAllowLongSignals = false; + // } +} + +// +// Enable All Signallers Longs ... +// Only if they are Configured as Enable at Settings ... +void XUSPY5EnableLongSignallers() +{ + // + // XTD ... + if (xUSPY5MXTDEnableSignaller) + { + // + xUSPY5MXTDAllowLongSignals = + xUSPY5XTDAllowLongSignals + ? true + : xUSPY5MXTDAllowLongSignals; + + // + if (xUSPY5MXTDAllowLongSignals) + { + xUSPY5Provider.EnableXTDLongs(); + } + } + + // + // XTAM ... + if (xUSPY5MXTAMEnableSignaller) + { + // + xUSPY5MXTAMAllowLongSignals = + xUSPY5XTAMAllowLongSignals + ? true + : xUSPY5MXTAMAllowLongSignals; + + // + if (xUSPY5MXTAMAllowLongSignals) + { + xUSPY5Provider.EnableXTAMLongs(); + } + } + + // + // XSI ... + if (xUSPY5MXSIEnableSignaller) + { + // + xUSPY5MXSIAllowLongSignals = + xUSPY5XSIAllowLongSignals + ? true + : xUSPY5MXSIAllowLongSignals; + + // + if (xUSPY5MXSIAllowLongSignals) + { + xUSPY5Provider.EnableXSILongs(); + } + } + + // + // XTSFI ... + if (xUSPY5MXTSFIEnableSignaller) + { + // + xUSPY5MXTSFIAllowLongSignals = + xUSPY5XTSFIAllowLongSignals + ? true + : xUSPY5MXTSFIAllowLongSignals; + + // + if (xUSPY5MXTSFIAllowLongSignals) + { + xUSPY5Provider.EnableXTSFILongs(); + } + } + + // + // XOBDLH ... + // if (xUSPY5MXOBDLHEnableSignaller) + // { + // // + // xUSPY5MXOBDLHAllowLongSignals = + // xUSPY5XOBDLHAllowLongSignals + // ? true + // : xUSPY5MXOBDLHAllowLongSignals; + + // // + // if (xUSPY5MXOBDLHAllowLongSignals) + // { + // xUSPY5Provider.EnableXOBDLHLongs(); + // } + // } + + // + // XCHMACC ... + if (xUSPY5MXCHMACCEnableSignaller) + { + // + xUSPY5MXCHMACCAllowLongSignals = + xUSPY5XCHMACCAllowLongSignals + ? true + : xUSPY5MXCHMACCAllowLongSignals; + + // + if (xUSPY5MXCHMACCAllowLongSignals) + { + xUSPY5Provider.EnableXCHMACCLongs(); + } + } + + // + // XCHMAMX ... + // if (xUSPY5MXCHMAMXEnableSignaller) + // { + // // + // xUSPY5MXCHMAMXAllowLongSignals = + // xUSPY5XCHMAMXAllowLongSignals + // ? true + // : xUSPY5MXCHMAMXAllowLongSignals; + + // // + // if (xUSPY5MXCHMAMXAllowLongSignals) + // { + // xUSPY5Provider.EnableXCHMAMXLongs(); + // } + // } + + // + // XCHMAMN ... + // if (xUSPY5MXCHMAMNEnableSignaller) + // { + // // + // xUSPY5MXCHMAMNAllowLongSignals = + // xUSPY5XCHMAMNAllowLongSignals + // ? true + // : xUSPY5MXCHMAMNAllowLongSignals; + + // // + // if (xUSPY5MXCHMAMNAllowLongSignals) + // { + // xUSPY5Provider.EnableXCHMAMNLongs(); + // } + // } +} + +// +// Disable All Signallers Shorts ... +void XUSPY5DisableShortSignallers() +{ + // + // XTD ... + if (xUSPY5MXTDEnableSignaller) + { + // + xUSPY5Provider.DisableXTDShorts(); + xUSPY5MXTDAllowShortSignals = false; + } + + // + // XTAM ... + if (xUSPY5MXTAMEnableSignaller) + { + // + xUSPY5Provider.DisableXTAMShorts(); + xUSPY5MXTAMAllowShortSignals = false; + } + + // + // XSI ... + if (xUSPY5MXSIEnableSignaller) + { + // + xUSPY5Provider.DisableXSIShorts(); + xUSPY5MXSIAllowShortSignals = false; + } + + // + // XTSFI ... + if (xUSPY5MXTSFIEnableSignaller) + { + // + xUSPY5Provider.DisableXTSFIShorts(); + xUSPY5MXTSFIAllowShortSignals = false; + } + + // + // XOBDLH ... + // if (xUSPY5MXOBDLHEnableSignaller) + // { + // // + // xUSPY5Provider.DisableXOBDLHShorts(); + // xUSPY5MXOBDLHAllowShortSignals = false; + // } + + // + // XCHMACC ... + if (xUSPY5MXCHMACCEnableSignaller) + { + // + xUSPY5Provider.DisableXCHMACCShorts(); + xUSPY5MXCHMACCAllowShortSignals = false; + } + + // + // XCHMAMX ... + // if (xUSPY5MXCHMAMXEnableSignaller) + // { + // // + // xUSPY5Provider.DisableXCHMAMXShorts(); + // xUSPY5MXCHMAMXAllowShortSignals = false; + // } + + // + // XCHMAMN ... + // if (xUSPY5MXCHMAMNEnableSignaller) + // { + // // + // xUSPY5Provider.DisableXCHMAMNShorts(); + // xUSPY5MXCHMAMNAllowShortSignals = false; + // } +} + +// +// Enable All Signallers Shorts ... +// Only if they are Configured as Enable at Settings ... +void XUSPY5EnableShortSignallers() +{ + // + // XTD ... + if (xUSPY5MXTDEnableSignaller) + { + // + xUSPY5MXTDAllowShortSignals = + xUSPY5XTDAllowShortSignals + ? true + : xUSPY5MXTDAllowShortSignals; + + // + if (xUSPY5MXTDAllowShortSignals) + { + xUSPY5Provider.EnableXTDShorts(); + } + } + + // + // XTAM ... + if (xUSPY5MXTAMEnableSignaller) + { + // + xUSPY5MXTAMAllowShortSignals = + xUSPY5XTAMAllowShortSignals + ? true + : xUSPY5MXTAMAllowShortSignals; + + // + if (xUSPY5MXTAMAllowShortSignals) + { + xUSPY5Provider.EnableXTAMShorts(); + } + } + + // + // XSI ... + if (xUSPY5MXSIEnableSignaller) + { + // + xUSPY5MXSIAllowShortSignals = + xUSPY5XSIAllowShortSignals + ? true + : xUSPY5MXSIAllowShortSignals; + + // + if (xUSPY5MXSIAllowShortSignals) + { + xUSPY5Provider.EnableXSIShorts(); + } + } + + // + // XTSFI ... + if (xUSPY5MXTSFIEnableSignaller) + { + // + xUSPY5MXTSFIAllowShortSignals = + xUSPY5XTSFIAllowShortSignals + ? true + : xUSPY5MXTSFIAllowShortSignals; + + // + if (xUSPY5MXTSFIAllowShortSignals) + { + xUSPY5Provider.EnableXTSFIShorts(); + } + } + + // + // XOBDLH ... + // if (xUSPY5MXOBDLHEnableSignaller) + // { + // // + // xUSPY5MXOBDLHAllowShortSignals = + // xUSPY5XOBDLHAllowShortSignals + // ? true + // : xUSPY5MXOBDLHAllowShortSignals; + + // // + // if (xUSPY5MXOBDLHAllowShortSignals) + // { + // xUSPY5Provider.EnableXOBDLHShorts(); + // } + // } + + // + // XCHMACC ... + if (xUSPY5MXCHMACCEnableSignaller) + { + // + xUSPY5MXCHMACCAllowShortSignals = + xUSPY5XCHMACCAllowShortSignals + ? true + : xUSPY5MXCHMACCAllowShortSignals; + + // + if (xUSPY5MXCHMACCAllowShortSignals) + { + xUSPY5Provider.EnableXCHMACCShorts(); + } + } + + // + // XCHMAMX ... + // if (xUSPY5MXCHMAMXEnableSignaller) + // { + // // + // xUSPY5MXCHMAMXAllowShortSignals = + // xUSPY5XCHMAMXAllowShortSignals + // ? true + // : xUSPY5MXCHMAMXAllowShortSignals; + + // // + // if (xUSPY5MXCHMAMXAllowShortSignals) + // { + // xUSPY5Provider.EnableXCHMAMXShorts(); + // } + // } + + // + // XCHMAMN ... + // if (xUSPY5MXCHMAMNEnableSignaller) + // { + // // + // xUSPY5MXCHMAMNAllowShortSignals = + // xUSPY5XCHMAMNAllowShortSignals + // ? true + // : xUSPY5MXCHMAMNAllowShortSignals; + + // // + // if (xUSPY5MXCHMAMNAllowShortSignals) + // { + // xUSPY5Provider.EnableXCHMAMNShorts(); + // } + // } +} + +// +// +// + +// +// XTD Long Signal Checking ... +bool XUSPY5XTDHasLongSignal() +{ + // + bool result = false; + + // + // Validate Args ... + if (!xUSPY5MXTDEnableSignaller || + !xUSPY5MXTDAllowLongSignals) + { + return result; + } + + // + // Retrieve Market Condition ... + XMarketConditions mConditions = xUSPY5Provider.GetLastMarketCondition(); + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + xUSPY5Provider.XTDHasLongConditions() + // + && + // + // Exceptions: + // there some commonly Exceptions which makes our choice incorrect, + // here we are combined knownly Exceptions ... + !( + // + // for Exception we used XLH Conditions as follow ... + // + // Check Conditions if Price In Signal Range ... + (mConditions.isXLHPriceInSignalRange && + // + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XTD Long ... + // PriceInSignalRange ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + // + (mConditions.isXTSCurrentUnderFarest && + ( + // + ((mConditions.isXCHMAMCTrendsDown && + mConditions.isXCHMAMCFastOverSlow) && + ( + // + (mConditions.isXCHMALCPeak && + mConditions.isXCHLHMCLCHHSame) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check if MC Fast Under Slow ... + ((mConditions.isXCHMAMCFastUnderSlow || + mConditions.isXCHMAMCFastCrossedUnderSlow) && + ( + // + (mConditions.isXTDSignalCrossedOverBear && + ( + // + (mConditions.isXTSCurrentCrossedUnderNearest && + ( + // + (mConditions.isXCHMALCPeak && + mConditions.isXCHLHMCLCHHSame && + mConditions.isXTSCurrentUnderNearest) + // + ) + // + ) + // + ) + // + ) + // + || + // + (mConditions.isXCHMAMCTrendsUp && + ( + // + (mConditions.isXTSAllSame && + mConditions.isXCHMAMCVale && + mConditions.isXTDSignalCrossedOverBear) + // + ) + // + ) + // + ) + // + ) + // + ) + // + ) + // + || + // + // XTD Long ... + // PriceInSignalRange ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + // + // Check if MC Fast Under Slow ... + ((mConditions.isXCHMAMCFastUnderSlow || + mConditions.isXCHMAMCFastCrossedUnderSlow) && + ( + // + (mConditions.isXAMAStartBullish && + ( + // + (mConditions.isXCHMALCPeak && + mConditions.isXTSCurrentMax && + mConditions.isXTDBullOverBear && + mConditions.isXTDSignalCrossedOverBear) + // + ) + // + ) + // + ) + // + ) + // + ) + // + ) + // + || + // + // XTD Long ... + // PriceInSignalRange ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTD Long ... + // PriceInSignalRange ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Under Signal ... + ( + // + ((mConditions.isXLHPriceUnderSignal || + mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XTD Long ... + // PriceUnderSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + // + (mConditions.isXTSCurrentUnderNearest && + ( + // + ((mConditions.isXCHMAMCVale && + mConditions.isXCHMALCVale) && + ( + // + (mConditions.isXTDBearishVale && + mConditions.isXTMStartBullish && + mConditions.isXCHLHMCLCLLSame && + mConditions.isXCHMASCUnderMin) + // + ) + // + ) + // + ) + // + ) + // + || + // + (mConditions.isXTSCurrentUnderFarest && + ( + // + ( + (mConditions.isXTDBearishVale && + mConditions.isXTDSignalCrossedOverBear) && + ( + // + (mConditions.isXCHMALCPeak && + mConditions.isXTSCurrentMin && + mConditions.isXCHLHMCLCHHSame) + // + || + // + (mConditions.isXCHMAMCVale && + mConditions.isXCHMALCVale && + mConditions.isXCHLHMCLCLLSame && + mConditions.isXCHMASCUnderMin && + mConditions.isXAMAStartBullish && + mConditions.isXCHMASCFastCrossedOverSlow) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check if MC Fast Under Slow ... + ((mConditions.isXCHMAMCFastUnderSlow || + mConditions.isXCHMAMCFastCrossedUnderSlow) && + ( + // + (mConditions.isXTSCurrentUnderNearest && + ( + // + (mConditions.isXTSCurrentCrossedUnderNearest && + ( + // + (mConditions.isXCHMAMCVale && + mConditions.isXCHMALCPeak && + mConditions.isXTDSignalCrossedOverBear) + // + ) + // + ) + // + ) + // + ) + // + || + // + (mConditions.isXTSCurrentUnderFarest && + ( + // + (mConditions.isXCHMAMCVale && + mConditions.isXCHMALCVale && + mConditions.isXTDBearishVale && + mConditions.isXTMStartBullish && + mConditions.isXCHMASCUnderMin) + // + ) + // + ) + // + ) + // + ) + // + ) + // + ) + // + || + // + // XTD Long ... + // PriceUnderSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTD Long ... + // PriceUnderSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTD Long ... + // PriceUnderSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Over Signal ... + ( + // + ((mConditions.isXLHPriceOverSignal || + mConditions.isXLHPriceCrossedOverSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XTD Long ... + // PriceOverSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + // + (mConditions.isXTSCurrentUnderNearest && + ( + // + (mConditions.isXTSCurrentUnderMediest && + ( + // + (mConditions.isXCHMASCOverMax && + mConditions.isXTSCurrentCrossedUnderNearest && + mConditions.isXTSCurrentCrossedUnderMediest) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check if MC Fast Under Slow ... + ((mConditions.isXCHMAMCFastUnderSlow || + mConditions.isXCHMAMCFastCrossedUnderSlow) && + ( + // + (mConditions.isXTSCurrentUnderFarest && + ( + // + (mConditions.isXCHMAMCVale && + mConditions.isXCHMALCPeak && + mConditions.isXTDBearishVale && + mConditions.isXTDSignalCrossedOverBear && + mConditions.isXLHPriceCrossedOverSignal) + // + ) + // + ) + // + || + // + ((mConditions.isXCHMALCTrendsDown && + mConditions.isXCHMALCFastOverSlow) && + ( + // + ((mConditions.isXCHMALCPeak && + mConditions.isXTSCurrentMax && + mConditions.isXTDSignalCrossedOverBear && + mConditions.isXLHPriceCrossedOverSignal) && + ( + // + (mConditions.isXCHMAMCVale && + mConditions.isXTDBearishVale) + // + || + // + (mConditions.isXLHHHDecreased && + mConditions.isXAMAStartBullish) + // + ) + // + ) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check LC Fast Under Slow ... + ((mConditions.isXCHMALCFastUnderSlow || + mConditions.isXCHMALCFastCrossedUnderSlow) && + ( + // + ((mConditions.isXTMNeutural || + mConditions.isXTMEndBullish) && + ( + // + (mConditions.isXTDSignalCrossedOverBear && + mConditions.isXCHMAMCPeak && + mConditions.isXTSCurrentMax && + mConditions.isXLHLLIncreased && + mConditions.isXCHMASCOverMin) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check LC Fast Over Slow ... + ((mConditions.isXCHMALCTrendsDown || + mConditions.isXCHMALCFastOverSlow) && + ( + // + (mConditions.isXCHMALCPeak && + mConditions.isXTSCurrentMax && + mConditions.isXCHMASCOverMax && + mConditions.isXFICrossedOverZero && + mConditions.isXTDSignalCrossedOverBear) + // + ) + // + ) + // + ) + // + ) + // + || + // + // XTD Long ... + // PriceOverSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + // + (mConditions.isXTSCurrentUnderNearest && + ( + // + (mConditions.isXTSCurrentCrossedUnderNearest && + ( + // + ((mConditions.isXCHLHSCMCHHSame && + mConditions.isXTDSignalCrossedOverBear) && + ( + // + (mConditions.isXCHMAMCPeak && + mConditions.isXCHMALCVale) + // + || + // + (mConditions.isXCHMALCPeak && + mConditions.isXCHMASCOverMax) + // + ) + // + ) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check LC Fast Under Slow ... + ((mConditions.isXCHMALCFastUnderSlow || + mConditions.isXCHMALCFastCrossedUnderSlow) && + ( + // + ((mConditions.isXCHMAMCPeak && + mConditions.isXCHLHSameHHs && + mConditions.isXTSCurrentMax && + mConditions.isXTDSignalCrossedOverBear) && + ( + // + mConditions.isXLHHighAttachedHH + // + || + // + (mConditions.isXLHLLSameInLength && + mConditions.isXRSICrossedOverLongExit) + // + ) + // + ) + // + ) + // + ) + // + ) + // + ) + // + || + // + // XTD Long ... + // PriceOverSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTD Long ... + // PriceOverSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is not has clear state ... + ( + // + ((!mConditions.isXLHPriceOverSignal && + !mConditions.isXLHPriceUnderSignal && + !mConditions.isXLHPriceInSignalRange && + !mConditions.isXLHPriceCrossedOverSignal && + !mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XTD Long ... + // PriceFree ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTD Long ... + // PriceFree ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTD Long ... + // PriceFree ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTD Long ... + // PriceFree ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + ) + // + ; + + // + return result; +} + +// +// XTD Short Signal Checking ... +bool XUSPY5XTDHasShortSignal() +{ + // + bool result = false; + + // + // Validate Args ... + if (!xUSPY5MXTDEnableSignaller || + !xUSPY5MXTDAllowShortSignals) + { + return result; + } + + // + // Retrieve Market Condition ... + XMarketConditions mConditions = xUSPY5Provider.GetLastMarketCondition(); + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + xUSPY5Provider.XTDHasShortConditions() + // + && + // + // Exceptions: + // there some commonly Exceptions which makes our choice incorrect, + // here we are combined knownly Exceptions ... + !( + // + // for Exception we used XLH Conditions as follow ... + // + // Check Conditions if Price In Signal Range ... + (mConditions.isXLHPriceInSignalRange && + // + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XTD Short ... + // PriceInSignalRange ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTD Short ... + // PriceInSignalRange ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTD Short ... + // PriceInSignalRange ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTD Short ... + // PriceInSignalRange ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Under Signal ... + ( + // + ((mConditions.isXLHPriceUnderSignal || + mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XTD Short ... + // PriceUnderSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTD Short ... + // PriceUnderSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTD Short ... + // PriceUnderSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTD Short ... + // PriceUnderSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Over Signal ... + ( + // + ((mConditions.isXLHPriceOverSignal || + mConditions.isXLHPriceCrossedOverSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XTD Short ... + // PriceOverSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTD Short ... + // PriceOverSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTD Short ... + // PriceOverSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTD Short ... + // PriceOverSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is not has clear state ... + ( + // + ((!mConditions.isXLHPriceOverSignal && + !mConditions.isXLHPriceUnderSignal && + !mConditions.isXLHPriceInSignalRange && + !mConditions.isXLHPriceCrossedOverSignal && + !mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XTD Short ... + // PriceFree ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTD Short ... + // PriceFree ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTD Short ... + // PriceFree ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTD Short ... + // PriceFree ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + ) + // + ; + + // + return result; +} + +// +// XTAM Long Signal Checking ... +bool XUSPY5XTAMHasLongSignal() +{ + // + bool result = false; + + // + // Validate Args ... + if (!xUSPY5MXTAMEnableSignaller || + !xUSPY5MXTAMAllowLongSignals) + { + return result; + } + + // + // Retrieve Market Condition ... + XMarketConditions mConditions = xUSPY5Provider.GetLastMarketCondition(); + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + xUSPY5Provider.XTAMHasLongConditions() + // + && + // + // Exceptions: + // there some commonly Exceptions which makes our choice incorrect, + // here we are combined knownly Exceptions ... + !( + // + // for Exception we used XLH Conditions as follow ... + // + // Check Conditions if Price In Signal Range ... + (mConditions.isXLHPriceInSignalRange && + // + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XTAM Long ... + // PriceInSignalRange ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTAM Long ... + // PriceInSignalRange ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTAM Long ... + // PriceInSignalRange ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTAM Long ... + // PriceInSignalRange ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Under Signal ... + ( + // + ((mConditions.isXLHPriceUnderSignal || + mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XTAM Long ... + // PriceUnderSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTAM Long ... + // PriceUnderSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTAM Long ... + // PriceUnderSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTAM Long ... + // PriceUnderSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Over Signal ... + ( + // + ((mConditions.isXLHPriceOverSignal || + mConditions.isXLHPriceCrossedOverSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XTAM Long ... + // PriceOverSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTAM Long ... + // PriceOverSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTAM Long ... + // PriceOverSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTAM Long ... + // PriceOverSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is not has clear state ... + ( + // + ((!mConditions.isXLHPriceOverSignal && + !mConditions.isXLHPriceUnderSignal && + !mConditions.isXLHPriceInSignalRange && + !mConditions.isXLHPriceCrossedOverSignal && + !mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XTAM Long ... + // PriceFree ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTAM Long ... + // PriceFree ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTAM Long ... + // PriceFree ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTAM Long ... + // PriceFree ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + ) + // + ; + + // + return result; +} + +// +// XTAM Short Signal Checking ... +bool XUSPY5XTAMHasShortSignal() +{ + // + bool result = false; + + // + // Validate Args ... + if (!xUSPY5MXTAMEnableSignaller || + !xUSPY5MXTAMAllowShortSignals) + { + return result; + } + + // + // Retrieve Market Condition ... + XMarketConditions mConditions = xUSPY5Provider.GetLastMarketCondition(); + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + xUSPY5Provider.XTAMHasShortConditions() + // + && + // + // Exceptions: + // there some commonly Exceptions which makes our choice incorrect, + // here we are combined knownly Exceptions ... + !( + // + // for Exception we used XLH Conditions as follow ... + // + // Check Conditions if Price In Signal Range ... + (mConditions.isXLHPriceInSignalRange && + // + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XTAM Short ... + // PriceInSignalRange ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTAM Short ... + // PriceInSignalRange ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTAM Short ... + // PriceInSignalRange ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTAM Short ... + // PriceInSignalRange ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Under Signal ... + ( + // + ((mConditions.isXLHPriceUnderSignal || + mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XTAM Short ... + // PriceUnderSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTAM Short ... + // PriceUnderSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTAM Short ... + // PriceUnderSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTAM Short ... + // PriceUnderSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Over Signal ... + ( + // + ((mConditions.isXLHPriceOverSignal || + mConditions.isXLHPriceCrossedOverSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XTAM Short ... + // PriceOverSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTAM Short ... + // PriceOverSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTAM Short ... + // PriceOverSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTAM Short ... + // PriceOverSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is not has clear state ... + ( + // + ((!mConditions.isXLHPriceOverSignal && + !mConditions.isXLHPriceUnderSignal && + !mConditions.isXLHPriceInSignalRange && + !mConditions.isXLHPriceCrossedOverSignal && + !mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XTAM Short ... + // PriceFree ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTAM Short ... + // PriceFree ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTAM Short ... + // PriceFree ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTAM Short ... + // PriceFree ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + ) + // + ; + + // + return result; +} + +// +// XSI Long Signal Checking ... +bool XUSPY5XSIHasLongSignal() +{ + // + bool result = false; + + // + // Validate Args ... + if (!xUSPY5MXSIEnableSignaller || + !xUSPY5MXSIAllowLongSignals) + { + return result; + } + + // + // Retrieve Market Condition ... + XMarketConditions mConditions = xUSPY5Provider.GetLastMarketCondition(); + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + xUSPY5Provider.XSIHasLongConditions() + // + && + // + // Exceptions: + // there some commonly Exceptions which makes our choice incorrect, + // here we are combined knownly Exceptions ... + !( + // + // for Exception we used XLH Conditions as follow ... + // + // Check Conditions if Price In Signal Range ... + (mConditions.isXLHPriceInSignalRange && + // + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XSI Long ... + // PriceInSignalRange ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XSI Long ... + // PriceInSignalRange ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XSI Long ... + // PriceInSignalRange ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XSI Long ... + // PriceInSignalRange ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Under Signal ... + ( + // + ((mConditions.isXLHPriceUnderSignal || + mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XSI Long ... + // PriceUnderSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XSI Long ... + // PriceUnderSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XSI Long ... + // PriceUnderSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XSI Long ... + // PriceUnderSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Over Signal ... + ( + // + ((mConditions.isXLHPriceOverSignal || + mConditions.isXLHPriceCrossedOverSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XSI Long ... + // PriceOverSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XSI Long ... + // PriceOverSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XSI Long ... + // PriceOverSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XSI Long ... + // PriceOverSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is not has clear state ... + ( + // + ((!mConditions.isXLHPriceOverSignal && + !mConditions.isXLHPriceUnderSignal && + !mConditions.isXLHPriceInSignalRange && + !mConditions.isXLHPriceCrossedOverSignal && + !mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XSI Long ... + // PriceFree ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XSI Long ... + // PriceFree ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XSI Long ... + // PriceFree ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XSI Long ... + // PriceFree ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + ) + // + ; + + // + return result; +} + +// +// XSI Short Signal Checking ... +bool XUSPY5XSIHasShortSignal() +{ + // + bool result = false; + + // + // Validate Args ... + if (!xUSPY5MXSIEnableSignaller || + !xUSPY5MXSIAllowShortSignals) + { + return result; + } + + // + // Retrieve Market Condition ... + XMarketConditions mConditions = xUSPY5Provider.GetLastMarketCondition(); + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + xUSPY5Provider.XSIHasShortConditions() + // + && + // + // Exceptions: + // there some commonly Exceptions which makes our choice incorrect, + // here we are combined knownly Exceptions ... + !( + // + // for Exception we used XLH Conditions as follow ... + // + // Check Conditions if Price In Signal Range ... + (mConditions.isXLHPriceInSignalRange && + // + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XSI Short ... + // PriceInSignalRange ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XSI Short ... + // PriceInSignalRange ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XSI Short ... + // PriceInSignalRange ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XSI Short ... + // PriceInSignalRange ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Under Signal ... + ( + // + ((mConditions.isXLHPriceUnderSignal || + mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XSI Short ... + // PriceUnderSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XSI Short ... + // PriceUnderSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XSI Short ... + // PriceUnderSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XSI Short ... + // PriceUnderSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Over Signal ... + ( + // + ((mConditions.isXLHPriceOverSignal || + mConditions.isXLHPriceCrossedOverSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XSI Short ... + // PriceOverSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XSI Short ... + // PriceOverSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XSI Short ... + // PriceOverSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XSI Short ... + // PriceOverSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is not has clear state ... + ( + // + ((!mConditions.isXLHPriceOverSignal && + !mConditions.isXLHPriceUnderSignal && + !mConditions.isXLHPriceInSignalRange && + !mConditions.isXLHPriceCrossedOverSignal && + !mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XSI Short ... + // PriceFree ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XSI Short ... + // PriceFree ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XSI Short ... + // PriceFree ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XSI Short ... + // PriceFree ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + ) + // + ; + + // + return result; +} + +// +// XTSFI Long Signal Checking ... +bool XUSPY5XTSFIHasLongSignal() +{ + // + bool result = false; + + // + // Validate Args ... + if (!xUSPY5MXTSFIEnableSignaller || + !xUSPY5MXTSFIAllowLongSignals) + { + return result; + } + + // + // Retrieve Market Condition ... + XMarketConditions mConditions = xUSPY5Provider.GetLastMarketCondition(); + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + xUSPY5Provider.XTSFIHasLongConditions() + // + && + // + // Exceptions: + // there some commonly Exceptions which makes our choice incorrect, + // here we are combined knownly Exceptions ... + !( + // + // for Exception we used XLH Conditions as follow ... + // + // Check Conditions if Price In Signal Range ... + (mConditions.isXLHPriceInSignalRange && + // + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XTSFI Long ... + // PriceInSignalRange ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTSFI Long ... + // PriceInSignalRange ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTSFI Long ... + // PriceInSignalRange ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTSFI Long ... + // PriceInSignalRange ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Under Signal ... + ( + // + ((mConditions.isXLHPriceUnderSignal || + mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XTSFI Long ... + // PriceUnderSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTSFI Long ... + // PriceUnderSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTSFI Long ... + // PriceUnderSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTSFI Long ... + // PriceUnderSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Over Signal ... + ( + // + ((mConditions.isXLHPriceOverSignal || + mConditions.isXLHPriceCrossedOverSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XTSFI Long ... + // PriceOverSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTSFI Long ... + // PriceOverSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTSFI Long ... + // PriceOverSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTSFI Long ... + // PriceOverSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is not has clear state ... + ( + // + ((!mConditions.isXLHPriceOverSignal && + !mConditions.isXLHPriceUnderSignal && + !mConditions.isXLHPriceInSignalRange && + !mConditions.isXLHPriceCrossedOverSignal && + !mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XTSFI Long ... + // PriceFree ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTSFI Long ... + // PriceFree ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTSFI Long ... + // PriceFree ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTSFI Long ... + // PriceFree ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + ) + // + ; + + // + return result; +} + +// +// XTSFI Short Signal Checking ... +bool XUSPY5XTSFIHasShortSignal() +{ + // + bool result = false; + + // + // Validate Args ... + if (!xUSPY5MXTSFIEnableSignaller || + !xUSPY5MXTSFIAllowShortSignals) + { + return result; + } + + // + // Retrieve Market Condition ... + XMarketConditions mConditions = xUSPY5Provider.GetLastMarketCondition(); + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + xUSPY5Provider.XTSFIHasShortConditions() + // + && + // + // Exceptions: + // there some commonly Exceptions which makes our choice incorrect, + // here we are combined knownly Exceptions ... + !( + // + // for Exception we used XLH Conditions as follow ... + // + // Check Conditions if Price In Signal Range ... + (mConditions.isXLHPriceInSignalRange && + // + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XTSFI Short ... + // PriceInSignalRange ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTSFI Short ... + // PriceInSignalRange ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTSFI Short ... + // PriceInSignalRange ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTSFI Short ... + // PriceInSignalRange ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Under Signal ... + ( + // + ((mConditions.isXLHPriceUnderSignal || + mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XTSFI Short ... + // PriceUnderSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTSFI Short ... + // PriceUnderSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTSFI Short ... + // PriceUnderSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTSFI Short ... + // PriceUnderSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Over Signal ... + ( + // + ((mConditions.isXLHPriceOverSignal || + mConditions.isXLHPriceCrossedOverSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XTSFI Short ... + // PriceOverSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTSFI Short ... + // PriceOverSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTSFI Short ... + // PriceOverSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTSFI Short ... + // PriceOverSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is not has clear state ... + ( + // + ((!mConditions.isXLHPriceOverSignal && + !mConditions.isXLHPriceUnderSignal && + !mConditions.isXLHPriceInSignalRange && + !mConditions.isXLHPriceCrossedOverSignal && + !mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XTSFI Short ... + // PriceFree ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTSFI Short ... + // PriceFree ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTSFI Short ... + // PriceFree ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XTSFI Short ... + // PriceFree ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + ) + // + ; + + // + return result; +} + +// +// XOBDLH Long Signal Checking ... +bool XUSPY5XOBDLHHasLongSignal() +{ + // + bool result = false; + + // + // Validate Args ... + if (!xUSPY5MXOBDLHEnableSignaller || + !xUSPY5MXOBDLHAllowLongSignals) + { + return result; + } + + // + // Retrieve Market Condition ... + XMarketConditions mConditions = xUSPY5Provider.GetLastMarketCondition(); + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + xUSPY5Provider.XOBDLHHasLongConditions() + // + && + // + // Exceptions: + // there some commonly Exceptions which makes our choice incorrect, + // here we are combined knownly Exceptions ... + !( + // + // for Exception we used XLH Conditions as follow ... + // + // Check Conditions if Price In Signal Range ... + (mConditions.isXLHPriceInSignalRange && + // + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XOBDLH Long ... + // PriceInSignalRange ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XOBDLH Long ... + // PriceInSignalRange ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XOBDLH Long ... + // PriceInSignalRange ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XOBDLH Long ... + // PriceInSignalRange ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Under Signal ... + ( + // + ((mConditions.isXLHPriceUnderSignal || + mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XOBDLH Long ... + // PriceUnderSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XOBDLH Long ... + // PriceUnderSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XOBDLH Long ... + // PriceUnderSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XOBDLH Long ... + // PriceUnderSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Over Signal ... + ( + // + ((mConditions.isXLHPriceOverSignal || + mConditions.isXLHPriceCrossedOverSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XOBDLH Long ... + // PriceOverSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XOBDLH Long ... + // PriceOverSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XOBDLH Long ... + // PriceOverSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XOBDLH Long ... + // PriceOverSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is not has clear state ... + ( + // + ((!mConditions.isXLHPriceOverSignal && + !mConditions.isXLHPriceUnderSignal && + !mConditions.isXLHPriceInSignalRange && + !mConditions.isXLHPriceCrossedOverSignal && + !mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XOBDLH Long ... + // PriceFree ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XOBDLH Long ... + // PriceFree ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XOBDLH Long ... + // PriceFree ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XOBDLH Long ... + // PriceFree ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + ) + // + ; + + // + return result; +} + +// +// XOBDLH Short Signal Checking ... +bool XUSPY5XOBDLHHasShortSignal() +{ + // + bool result = false; + + // + // Validate Args ... + if (!xUSPY5MXOBDLHEnableSignaller || + !xUSPY5MXOBDLHAllowShortSignals) + { + return result; + } + + // + // Retrieve Market Condition ... + XMarketConditions mConditions = xUSPY5Provider.GetLastMarketCondition(); + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + xUSPY5Provider.XOBDLHHasShortConditions() + // + && + // + // Exceptions: + // there some commonly Exceptions which makes our choice incorrect, + // here we are combined knownly Exceptions ... + !( + // + // for Exception we used XLH Conditions as follow ... + // + // Check Conditions if Price In Signal Range ... + (mConditions.isXLHPriceInSignalRange && + // + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XOBDLH Short ... + // PriceInSignalRange ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XOBDLH Short ... + // PriceInSignalRange ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XOBDLH Short ... + // PriceInSignalRange ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XOBDLH Short ... + // PriceInSignalRange ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Under Signal ... + ( + // + ((mConditions.isXLHPriceUnderSignal || + mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XOBDLH Short ... + // PriceUnderSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XOBDLH Short ... + // PriceUnderSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XOBDLH Short ... + // PriceUnderSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XOBDLH Short ... + // PriceUnderSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Over Signal ... + ( + // + ((mConditions.isXLHPriceOverSignal || + mConditions.isXLHPriceCrossedOverSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XOBDLH Short ... + // PriceOverSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XOBDLH Short ... + // PriceOverSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XOBDLH Short ... + // PriceOverSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XOBDLH Short ... + // PriceOverSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is not has clear state ... + ( + // + ((!mConditions.isXLHPriceOverSignal && + !mConditions.isXLHPriceUnderSignal && + !mConditions.isXLHPriceInSignalRange && + !mConditions.isXLHPriceCrossedOverSignal && + !mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XOBDLH Short ... + // PriceFree ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XOBDLH Short ... + // PriceFree ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XOBDLH Short ... + // PriceFree ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XOBDLH Short ... + // PriceFree ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + ) + // + ; + + // + return result; +} + +// +// XCHMACC Long Signal Checking ... +bool XUSPY5XCHMACCHasLongSignal() +{ + // + bool result = false; + + // + // Validate Args ... + if (!xUSPY5MXCHMACCEnableSignaller || + !xUSPY5MXCHMACCAllowLongSignals) + { + return result; + } + + // + // Retrieve Market Condition ... + XMarketConditions mConditions = xUSPY5Provider.GetLastMarketCondition(); + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + xUSPY5Provider.XCHMACCHasLongConditions() + // + && + // + // Exceptions: + // there some commonly Exceptions which makes our choice incorrect, + // here we are combined knownly Exceptions ... + !( + // + // for Exception we used XLH Conditions as follow ... + // + // Check Conditions if Price In Signal Range ... + (mConditions.isXLHPriceInSignalRange && + // + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XCHMACC Long ... + // PriceInSignalRange ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMACC Long ... + // PriceInSignalRange ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMACC Long ... + // PriceInSignalRange ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMACC Long ... + // PriceInSignalRange ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Under Signal ... + ( + // + ((mConditions.isXLHPriceUnderSignal || + mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XCHMACC Long ... + // PriceUnderSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMACC Long ... + // PriceUnderSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMACC Long ... + // PriceUnderSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMACC Long ... + // PriceUnderSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Over Signal ... + ( + // + ((mConditions.isXLHPriceOverSignal || + mConditions.isXLHPriceCrossedOverSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XCHMACC Long ... + // PriceOverSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMACC Long ... + // PriceOverSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMACC Long ... + // PriceOverSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMACC Long ... + // PriceOverSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is not has clear state ... + ( + // + ((!mConditions.isXLHPriceOverSignal && + !mConditions.isXLHPriceUnderSignal && + !mConditions.isXLHPriceInSignalRange && + !mConditions.isXLHPriceCrossedOverSignal && + !mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XCHMACC Long ... + // PriceFree ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMACC Long ... + // PriceFree ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMACC Long ... + // PriceFree ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMACC Long ... + // PriceFree ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + ) + // + ; + + // + return result; +} + +// +// XCHMACC Short Signal Checking ... +bool XUSPY5XCHMACCHasShortSignal() +{ + // + bool result = false; + + // + // Validate Args ... + if (!xUSPY5MXCHMACCEnableSignaller || + !xUSPY5MXCHMACCAllowShortSignals) + { + return result; + } + + // + // Retrieve Market Condition ... + XMarketConditions mConditions = xUSPY5Provider.GetLastMarketCondition(); + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + xUSPY5Provider.XCHMACCHasShortConditions() + // + && + // + // Exceptions: + // there some commonly Exceptions which makes our choice incorrect, + // here we are combined knownly Exceptions ... + !( + // + // for Exception we used XLH Conditions as follow ... + // + // Check Conditions if Price In Signal Range ... + (mConditions.isXLHPriceInSignalRange && + // + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XCHMACC Short ... + // PriceInSignalRange ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMACC Short ... + // PriceInSignalRange ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMACC Short ... + // PriceInSignalRange ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMACC Short ... + // PriceInSignalRange ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Under Signal ... + ( + // + ((mConditions.isXLHPriceUnderSignal || + mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XCHMACC Short ... + // PriceUnderSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMACC Short ... + // PriceUnderSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMACC Short ... + // PriceUnderSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMACC Short ... + // PriceUnderSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Over Signal ... + ( + // + ((mConditions.isXLHPriceOverSignal || + mConditions.isXLHPriceCrossedOverSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XCHMACC Short ... + // PriceOverSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMACC Short ... + // PriceOverSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMACC Short ... + // PriceOverSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMACC Short ... + // PriceOverSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is not has clear state ... + ( + // + ((!mConditions.isXLHPriceOverSignal && + !mConditions.isXLHPriceUnderSignal && + !mConditions.isXLHPriceInSignalRange && + !mConditions.isXLHPriceCrossedOverSignal && + !mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XCHMACC Short ... + // PriceFree ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMACC Short ... + // PriceFree ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMACC Short ... + // PriceFree ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMACC Short ... + // PriceFree ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + ) + // + ; + + // + return result; +} + +// +// XCHMAMN Long Signal Checking ... +bool XUSPY5XCHMAMNHasLongSignal() +{ + // + bool result = false; + + // + // Validate Args ... + if (!xUSPY5MXCHMAMNEnableSignaller || + !xUSPY5MXCHMAMNAllowLongSignals) + { + return result; + } + + // + // Retrieve Market Condition ... + XMarketConditions mConditions = xUSPY5Provider.GetLastMarketCondition(); + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + xUSPY5Provider.XCHMAMNHasLongConditions() + // + && + // + // Exceptions: + // there some commonly Exceptions which makes our choice incorrect, + // here we are combined knownly Exceptions ... + !( + // + // for Exception we used XLH Conditions as follow ... + // + // Check Conditions if Price In Signal Range ... + (mConditions.isXLHPriceInSignalRange && + // + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XCHMAMN Long ... + // PriceInSignalRange ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMN Long ... + // PriceInSignalRange ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMN Long ... + // PriceInSignalRange ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMN Long ... + // PriceInSignalRange ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Under Signal ... + ( + // + ((mConditions.isXLHPriceUnderSignal || + mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XCHMAMN Long ... + // PriceUnderSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMN Long ... + // PriceUnderSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMN Long ... + // PriceUnderSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMN Long ... + // PriceUnderSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Over Signal ... + ( + // + ((mConditions.isXLHPriceOverSignal || + mConditions.isXLHPriceCrossedOverSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XCHMAMN Long ... + // PriceOverSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMN Long ... + // PriceOverSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMN Long ... + // PriceOverSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMN Long ... + // PriceOverSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is not has clear state ... + ( + // + ((!mConditions.isXLHPriceOverSignal && + !mConditions.isXLHPriceUnderSignal && + !mConditions.isXLHPriceInSignalRange && + !mConditions.isXLHPriceCrossedOverSignal && + !mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XCHMAMN Long ... + // PriceFree ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMN Long ... + // PriceFree ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMN Long ... + // PriceFree ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMN Long ... + // PriceFree ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + ) + // + ; + + // + return result; +} + +// +// XCHMAMN Short Signal Checking ... +bool XUSPY5XCHMAMNHasShortSignal() +{ + // + bool result = false; + + // + // Validate Args ... + if (!xUSPY5MXCHMAMNEnableSignaller || + !xUSPY5MXCHMAMNAllowShortSignals) + { + return result; + } + + // + // Retrieve Market Condition ... + XMarketConditions mConditions = xUSPY5Provider.GetLastMarketCondition(); + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + xUSPY5Provider.XCHMAMNHasShortConditions() + // + && + // + // Exceptions: + // there some commonly Exceptions which makes our choice incorrect, + // here we are combined knownly Exceptions ... + !( + // + // for Exception we used XLH Conditions as follow ... + // + // Check Conditions if Price In Signal Range ... + (mConditions.isXLHPriceInSignalRange && + // + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XCHMAMN Short ... + // PriceInSignalRange ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMN Short ... + // PriceInSignalRange ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMN Short ... + // PriceInSignalRange ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMN Short ... + // PriceInSignalRange ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Under Signal ... + ( + // + ((mConditions.isXLHPriceUnderSignal || + mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XCHMAMN Short ... + // PriceUnderSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMN Short ... + // PriceUnderSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMN Short ... + // PriceUnderSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMN Short ... + // PriceUnderSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Over Signal ... + ( + // + ((mConditions.isXLHPriceOverSignal || + mConditions.isXLHPriceCrossedOverSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XCHMAMN Short ... + // PriceOverSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMN Short ... + // PriceOverSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMN Short ... + // PriceOverSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMN Short ... + // PriceOverSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is not has clear state ... + ( + // + ((!mConditions.isXLHPriceOverSignal && + !mConditions.isXLHPriceUnderSignal && + !mConditions.isXLHPriceInSignalRange && + !mConditions.isXLHPriceCrossedOverSignal && + !mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XCHMAMN Short ... + // PriceFree ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMN Short ... + // PriceFree ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMN Short ... + // PriceFree ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMN Short ... + // PriceFree ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + ) + // + ; + + // + return result; +} + +// +// XCHMAMX Long Signal Checking ... +bool XUSPY5XCHMAMXHasLongSignal() +{ + // + bool result = false; + + // + // Validate Args ... + if (!xUSPY5MXCHMAMXEnableSignaller || + !xUSPY5MXCHMAMXAllowLongSignals) + { + return result; + } + + // + // Retrieve Market Condition ... + XMarketConditions mConditions = xUSPY5Provider.GetLastMarketCondition(); + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + xUSPY5Provider.XCHMAMXHasLongConditions() + // + && + // + // Exceptions: + // there some commonly Exceptions which makes our choice incorrect, + // here we are combined knownly Exceptions ... + !( + // + // for Exception we used XLH Conditions as follow ... + // + // Check Conditions if Price In Signal Range ... + (mConditions.isXLHPriceInSignalRange && + // + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XCHMAMX Long ... + // PriceInSignalRange ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMX Long ... + // PriceInSignalRange ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMX Long ... + // PriceInSignalRange ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMX Long ... + // PriceInSignalRange ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Under Signal ... + ( + // + ((mConditions.isXLHPriceUnderSignal || + mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XCHMAMX Long ... + // PriceUnderSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMX Long ... + // PriceUnderSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMX Long ... + // PriceUnderSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMX Long ... + // PriceUnderSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Over Signal ... + ( + // + ((mConditions.isXLHPriceOverSignal || + mConditions.isXLHPriceCrossedOverSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XCHMAMX Long ... + // PriceOverSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMX Long ... + // PriceOverSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMX Long ... + // PriceOverSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMX Long ... + // PriceOverSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is not has clear state ... + ( + // + ((!mConditions.isXLHPriceOverSignal && + !mConditions.isXLHPriceUnderSignal && + !mConditions.isXLHPriceInSignalRange && + !mConditions.isXLHPriceCrossedOverSignal && + !mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XCHMAMX Long ... + // PriceFree ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMX Long ... + // PriceFree ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMX Long ... + // PriceFree ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMX Long ... + // PriceFree ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + ) + // + ; + + // + return result; +} + +// +// XCHMAMX Short Signal Checking ... +bool XUSPY5XCHMAMXHasShortSignal() +{ + // + bool result = false; + + // + // Validate Args ... + if (!xUSPY5MXCHMAMXEnableSignaller || + !xUSPY5MXCHMAMXAllowShortSignals) + { + return result; + } + + // + // Retrieve Market Condition ... + XMarketConditions mConditions = xUSPY5Provider.GetLastMarketCondition(); + + // + // Start Analysing Market based On Conditions ... + result = + // + // Base Condition: + xUSPY5Provider.XCHMAMXHasShortConditions() + // + && + // + // Exceptions: + // there some commonly Exceptions which makes our choice incorrect, + // here we are combined knownly Exceptions ... + !( + // + // for Exception we used XLH Conditions as follow ... + // + // Check Conditions if Price In Signal Range ... + (mConditions.isXLHPriceInSignalRange && + // + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XCHMAMX Short ... + // PriceInSignalRange ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMX Short ... + // PriceInSignalRange ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMX Short ... + // PriceInSignalRange ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMX Short ... + // PriceInSignalRange ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Under Signal ... + ( + // + ((mConditions.isXLHPriceUnderSignal || + mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XCHMAMX Short ... + // PriceUnderSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMX Short ... + // PriceUnderSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMX Short ... + // PriceUnderSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMX Short ... + // PriceUnderSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is Over Signal ... + ( + // + ((mConditions.isXLHPriceOverSignal || + mConditions.isXLHPriceCrossedOverSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XCHMAMX Short ... + // PriceOverSignal ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMX Short ... + // PriceOverSignal ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMX Short ... + // PriceOverSignal ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMX Short ... + // PriceOverSignal ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + || + // + // Check Conditions if Price is not has clear state ... + ( + // + ((!mConditions.isXLHPriceOverSignal && + !mConditions.isXLHPriceUnderSignal && + !mConditions.isXLHPriceInSignalRange && + !mConditions.isXLHPriceCrossedOverSignal && + !mConditions.isXLHPriceCrossedUnderSignal) && + ( + // + // Next Step is to Check LL and HH Same Style ... + // + // XCHMAMX Short ... + // PriceFree ... + // Check if Both LL and HH Same In Length ... + ((mConditions.isXLHLLSameInLength && + mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMX Short ... + // PriceFree ... + // Check If LL Same In Length ... + ((mConditions.isXLHLLSameInLength && + !mConditions.isXLHHHSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMX Short ... + // PriceFree ... + // Check If HH is Same In Length ... + ((mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + || + // + // XCHMAMX Short ... + // PriceFree ... + // Not Same LL or HH in Lenght ... + ((!mConditions.isXLHHHSameInLength && + !mConditions.isXLHLLSameInLength) && + // + ( + false) + // + ) + // + ) + // + ) + // + ) + // + ) + // + ; + + // + return result; +} + +// +// END Signal Providers ... +// diff --git a/Projects/XUSCHF5/Providers/x-saherelm.xuspy5.provider.inputs.lib.mq5 b/Projects/XUSCHF5/Providers/x-saherelm.xuspy5.provider.inputs.lib.mq5 new file mode 100644 index 00000000..3093b8d3 --- /dev/null +++ b/Projects/XUSCHF5/Providers/x-saherelm.xuspy5.provider.inputs.lib.mq5 @@ -0,0 +1,283 @@ +/////////////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 XUSPY5 Signal Provider Library Inputs +// ----------------------------------------------------------- +// +// 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 + +// +// Include Logger ... +#include "../Libraries/x-saherelm.log.lib.mq5" + +// +// Include Classes ... +#include "../Classes/x-saherelm.class.lib.mq5" + +// +input group "XUSPY5 Provider"; + +// +// Commonly Used Configurations ... +input group "XUSPY5 Common"; +// +// Provider ... +input bool xUSPY5EnableProvider = true; // Enable Provider +input int xUSPY5NumberOfItemsPerTick = 30; // Number Of items Readed In Each Tick +// +// Alerts ... +input bool xUSPY5EnableAlerts = true; // Enable Events Alert +input bool xUSPY5EnableHourlyAlerts = false; // Send Alert on each new Hour +input bool xUSPY5EnableDailyAlerts = false; // Send Alert on each new Day +input bool xUSPY5EnableWeeklyAlerts = false; // Send Alert on each new Week +input bool xUSPY5EnableMonthlyAlerts = false; // Send Alert on each new Month +// +// Reports ... +input bool xUSPY5EnableDailyReports = false; // Send Report on each new Day +input bool xUSPY5EnableWeeklyReports = false; // Send Report on each new Week +input bool xUSPY5EnableMonthlyReports = false; // Send Report on each new Month + +// +// Trader and Expert Specific Configurations ... +input group "XUSPY5 Trader"; +input int xUSPY5MagicNumber = 16940563; // Trader MagicNumber +input int xUSPY5Slippage = 10; // Trader Slippage + +// +// Trades Management Configurations ... +input group "XUSPY5 Trade Management"; +input bool xUSPY5AllowLongTrades = true; // Allow Long Trades +input bool xUSPY5AllowShortTrades = true; // Allow Short Trades + +// +// Risk Management Configurations ... +input group "XUSPY5 Risk Management"; +// +// Trade Count ... +input int xUSPY5MaxAllowedTrades = 10; // Max Allowed Trades at Same Time +input ENUM_X_CROSS_SIGNAL_METHOD xUSPY5CrossSignalsMethod = X_CROSS_SIGNAL_REGULAR; // Handle Cross Signals Method +// +// Max Allowed Trade Age ... +input int xUSPY5MaxAllowedTradeAge = 1500; // Detect Long Time Trades +input ENUM_X_GUARD_ACTIONS xUSPY5OldTradesAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_1; // What to do with Old Trades +// +// Trade Volume Specific Configurations ... +input double xUSPY5StaticVolumeFactor = 0.0001; // Static Volume baesd on Balance +input ENUM_STATIC_VOLUME_METHODS xUSPY5StaticVolumeMethod = X_STATIC_VOLUME_BASED_ON_BALANCE; // How to Calculate Static Volume +input double xUSPY5VolumeMultiplier = 0; // Volume Increase Multiplier +input double xUSPY5ApplyVolumeMultiplierFactor = 0; // Apply Volume Multiplier Rate based on Balance +input double xUSPY5MaxSupportedVolumePerTradeFactor = 0; // Max Supported Volume Per Trade Factor based on Balance +input double xUSPY5IncreasedMaxSupportedVolumeRate = 0; // Increase Max Supported Volume based on Balance +// +// Trade Profits ... +input double xUSPY5MinRewardInPips = 3; // Minimum Reward Per Trade in Pips +input double xUSPY5RiskFreeStepInPips = 0; // Make Trades Risk Free Steps in Pips +input double xUSPY5RiskFreeRate = 0; // Volume Multiplier for Risk Free Trades +// +// Guard Riskable Money and Profits ... +input double xUSPY5CriticalDrawDownFactor = 0.30; // Critical Allowed Drawdown Factor based on Balance +input ENUM_X_GUARD_ACTIONS xUSPY5CriticalGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_1; // Specify Guard Action on Critical Drawdown +input double xUSPY5MaxAllowedDrawDownFactor = 0.40; // Max Allowed Drawdown Factor based on Balance +input ENUM_X_GUARD_ACTIONS xUSPY5MaxAllowedGuardAction = X_GUARD_PARTIAL_CLOSE_MAX_IN_DD_5; // Specify Guard Action on Max Allowed Drawdown +input int xUSPY5GuardStopoutFiredAfterTouches = 5; // Guard Stopout all Trades if Max Allowed Drawdown touched + +// +// Account Conditions for Trading ... +input double xUSPY5BalanceFactorForOpenTrades = 0.5; // Minimum Balance for Open Trades +input double xUSPY5FreeMarginFactorForOpenTrades = 0.8; // Minimum Free Margin for Open Trades + +// +// May be Used Later as Input Params ... +bool xUSPY5UseVirtualTPSl = false; // Use Virtual TP SL +bool xUSPY5EnableSignalAlerts = false; // Send Signal Alert + +// +// Validate Inputs before Initialization ... +bool XUSPY5ValidateInputs() +{ + // + bool result = false; + + // + // Implement Other Verifications ... + + // + // Check Trading Availability ... + bool isTradeAvailable = xUSPY5AllowLongTrades || xUSPY5AllowShortTrades; + if (!isTradeAvailable) + { + LogMessage("XUSPY5 => Warning: Trading disabled ..."); + } + + // + // Chekc Number of reading items per tick ... + result = xUSPY5NumberOfItemsPerTick >= 5; + if (!result) + { + // + LogMessage("XUSPY5 invalid Number of items Reading Per Tick ..."); + + // + return result; + } + + // + // Check Max Allowed Trades Count ... + result = isTradeAvailable && xUSPY5MaxAllowedTrades >= 1; + if (!result) + { + // + LogMessage("XUSPY5 Number of Trades not valid ..."); + + // + return result; + } + + // + // Check Free Margin ... + result = + isTradeAvailable && + xUSPY5FreeMarginFactorForOpenTrades > 0 && + xUSPY5FreeMarginFactorForOpenTrades < 1; + if (!result) + { + // + LogMessage("XUSPY5 Invalid Free Margin ..."); + + // + return result; + } + + // + // Check min Balance for Open Trades ... + result = + isTradeAvailable && + xUSPY5BalanceFactorForOpenTrades > 0 && + xUSPY5BalanceFactorForOpenTrades < 1; + if (!result) + { + // + LogMessage("XUSPY5 Invalid Min Balance for Open Trades ..."); + + // + return result; + } + + // + // Check Min Reward Per Trade ... + result = xUSPY5MinRewardInPips > 0; + if (!result) + { + // + LogMessage("XUSPY5 Invalid Min Reward Per Trade ..."); + + // + return result; + } + + // + // Check Trades Volume ... + result = xUSPY5StaticVolumeFactor > 0; + if (!result) + { + // + LogMessage("XUSPY5 Invalid Static Volume ..."); + + // + return result; + } + + // + // Check Volume Multiplier ... + result = xUSPY5VolumeMultiplier >= 0; + if (!result) + { + // + LogMessage("XUSPY5 Invalid Volume Multiplier ..."); + + // + return result; + } + + // + result = + xUSPY5CriticalDrawDownFactor == 0 || (xUSPY5CriticalDrawDownFactor > 0 && + xUSPY5CriticalDrawDownFactor < 1); + if (!result) + { + // + LogMessage("XUSPY5 Invalid Critical DrawDown Factor ..."); + + // + return result; + } + + // + result = + xUSPY5MaxAllowedDrawDownFactor == 0 || (xUSPY5MaxAllowedDrawDownFactor > 0 && + xUSPY5MaxAllowedDrawDownFactor < 1); + if (!result) + { + // + LogMessage("XUSPY5 Invalid Max Allowed DrawDown Factor ..."); + + // + return result; + } + + // + // Check Guard Actions ... + // + result = + xUSPY5CriticalDrawDownFactor > 0 && + xUSPY5CriticalDrawDownFactor < 1 && + xUSPY5MaxAllowedDrawDownFactor > 0 && + xUSPY5MaxAllowedDrawDownFactor < 1; + if (!result) + { + // + LogMessage("XUSPY5 For Critical Drawdown, you have to Specify Max Drawdown also ..."); + + // + return result; + } + + // + result = xUSPY5CriticalDrawDownFactor > 0 && xUSPY5CriticalDrawDownFactor < xUSPY5MaxAllowedDrawDownFactor; + if (!result) + { + // + LogMessage("XUSPY5 Critical Drawdown must Smaller than Max Drawdown ..."); + + // + return result; + } + + // + if (xUSPY5CriticalDrawDownFactor > 0 && xUSPY5CriticalGuardAction == X_GUARD_DO_NOTHING) + { + LogMessage("XUSPY5 IMPORTANT you Specified Critical Drawdown, but there is no any Guard Action ..."); + } + + // + if (xUSPY5MaxAllowedDrawDownFactor > 0 && xUSPY5MaxAllowedGuardAction == X_GUARD_DO_NOTHING) + { + LogMessage("XUSPY5 IMPORTANT you Specified Max Allowed Drawdown, but there is no any Guard Action ..."); + } + + // + result = true; + + // + return result; +} \ No newline at end of file diff --git a/Projects/XUSCHF5/Providers/x-saherelm.xuspy5.provider.lib.mq5 b/Projects/XUSCHF5/Providers/x-saherelm.xuspy5.provider.lib.mq5 new file mode 100644 index 00000000..797bf5d2 --- /dev/null +++ b/Projects/XUSCHF5/Providers/x-saherelm.xuspy5.provider.lib.mq5 @@ -0,0 +1,1373 @@ +//////////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 XUSPY5 Signal Provider Library +// -------------------------------------------------------- +// Name: XUSPY5SignalProvider +// Description: XUSPY5 based signal 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 + +#define XUSPY5ProviderName "XUSPY5" + +// +// START Inputs ... +// + +#include "x-saherelm.xuspy5.provider.inputs.lib.mq5"; + +// +// END Inputs ... +// + +// +// Include Common Library ... +#include "../Libraries/x-saherelm.common.lib.mq5" + +// +// Include Logger Library ... +#include "../Libraries/x-saherelm.log.lib.mq5" + +// +// Include Alert Library ... +#include "../Libraries/x-saherelm.alert.lib.mq5" + +// +// Include Draw Library ... +#include "../Libraries/x-saherelm.draw.lib.mq5" + +// +// Include Class Libraries ... +#include "../Classes/x-saherelm.class.lib.mq5" + +// +// START Global Definitions: Variables, Properties and etc ... +// + +// +XCGuard *xUSPY5Guard; +XCTrade *xUSPY5Trader; +XCReporter *xUSPY5Reporter; +XCCollector *xUSPY5Collector; +XCAccountInfo *xUSPY5AccountInfo; +XCVolumeManager *xUSPY5VolumeManager; + +// +#include "x-saherelm.xuspy5.provider.indicators.lib.mq5" + +// +// Controlling Variables ... +bool xUSPY5MEnableProvider = false; +bool xUSPY5MAllowLongTrades = false; +bool xUSPY5MAllowShortTrades = false; + +// +double xUSPY5Deposit = 0; +double xUSPY5Balance = 0; +double xUSPY5MinReward = 0; +double xUSPY5FreeMargin = 0; +double xUSPY5BalanceForOpenTrades = 0; +double xUSPY5FreeMarginForOpenTrades = 0; + +// +// Guard ... +double xUSPY5CriticalDrawDown = 0; +double xUSPY5MaxAllowedDrawDown = 0; + +// +double xUSPY5MaxDrawUp = 0; +double xUSPY5MaxDrawDown = 0; + +// +int NOT_ENOUGH_MONEY_ERROR = 4756; +const string XUSPY5_SUPPORT_ID = "SP"; + +// +// END Global Definitions: Variables, Properties and etc ... +// + +// +// START Provided Functions ... +// + +// +// Initial Library if required ... +bool XUSPY5InitSignalProviderLibrary() +{ + // + bool result = false; + + // + if (!xUSPY5EnableProvider) + { + return result; + } + + // + // Controlling Variables ... + xUSPY5MEnableProvider = xUSPY5EnableProvider; + xUSPY5MAllowLongTrades = xUSPY5AllowLongTrades; + xUSPY5MAllowShortTrades = xUSPY5AllowShortTrades; + + // + // Validate Inputs ... + result = XUSPY5ValidateInputs(); + if (!result) + { + return result; + } + + // + // Init Indicators ... + result = XUSPY5InitIndicators(); + if (!result) + { + return result; + } + + // + xUSPY5Reporter = new XCReporter(); + xUSPY5Collector = new XCCollector(); + xUSPY5AccountInfo = new XCAccountInfo(); + + // + // Calculate Account Deposit ... + xUSPY5Deposit = xUSPY5AccountInfo.GetInitialBalance(); + + // + // Prepare Min Reward ... + if (xUSPY5MinRewardInPips > 0) + { + xUSPY5MinReward = PipsToPrice(xUSPY5MinRewardInPips); + } + + // + // Calculate Min Balance for Trades ... + if (xUSPY5BalanceFactorForOpenTrades > 0) + { + xUSPY5BalanceForOpenTrades = xUSPY5BalanceFactorForOpenTrades * xUSPY5Deposit; + } + + // + // Claculate Min Free Marging for Trades ... + if (xUSPY5FreeMarginFactorForOpenTrades > 0) + { + xUSPY5FreeMarginForOpenTrades = xUSPY5FreeMarginFactorForOpenTrades * xUSPY5Deposit; + } + + // + // Calculate Init Time Critical DrawDown Value ... + if (xUSPY5CriticalDrawDownFactor > 0) + { + xUSPY5CriticalDrawDown = xUSPY5CriticalDrawDownFactor * xUSPY5Deposit; + } + + // + // Calculate Init Time Max Allowed DrawDown Value ... + if (xUSPY5MaxAllowedDrawDownFactor > 0) + { + xUSPY5MaxAllowedDrawDown = xUSPY5MaxAllowedDrawDownFactor * xUSPY5Deposit; + } + + // + // Instant Volume Manager ... + xUSPY5VolumeManager = new XCVolumeManager( + xUSPY5StaticVolumeFactor, + xUSPY5StaticVolumeMethod, + xUSPY5VolumeMultiplier, + xUSPY5ApplyVolumeMultiplierFactor, + xUSPY5MaxSupportedVolumePerTradeFactor, + xUSPY5IncreasedMaxSupportedVolumeRate); + + // + // Make XCTrader instance ... + xUSPY5Trader = new XCTrade( + XUSPY5ProviderName, + _Symbol, + xUSPY5Slippage, + xUSPY5MagicNumber, + xUSPY5UseVirtualTPSl, + xUSPY5MaxAllowedTrades, + xUSPY5FreeMarginForOpenTrades, + xUSPY5BalanceForOpenTrades); + + // + // Instantiate Account Guard ... + xUSPY5Guard = new XCGuard( + // + // Old Trades ... + xUSPY5MaxAllowedTradeAge, + xUSPY5OldTradesAction, + // + // Critical DrawDown ... + xUSPY5CriticalDrawDownFactor, + xUSPY5CriticalGuardAction, + // + // Max Allowed DrawDown ... + xUSPY5MaxAllowedDrawDownFactor, + xUSPY5MaxAllowedGuardAction, + xUSPY5GuardStopoutFiredAfterTouches, + // + // xUSPY5GuardSupportMethod + X_SUPPORT_DO_NOTHING + // + ); + + // + // Reset Calculations Buffers and Variables ... + XUSPY5ResetCollectors(); + + // + XUSPY5UpdateReports(); + + // + result = true; + + // + // Logging State ... + XUSPY5IssueInitializationSucceedAlert(); + + // + return result; +} + +// +// DeInitial Library if required ... +void XUSPY5DeinitSignalProviderLibrary(const int reason) +{ + // + // Release Handlers ... + XUSPY5ReleaseIndicators(); + + // + // Logging State ... + XUSPY5IssueDeinitializationSucceedAlert(); +} + +// +// this is a Globally Function which do all of +// checkings and positions handling ... +void XUSPY5SignalProviderHandleTick() +{ + // + // Check Provider is Enable or Not ... + if (!xUSPY5MEnableProvider) + { + return; + } + + // + XUSPY5SignalProviderDoControlState(); + + // + // Reading Indicator Buffers ... + XUSPY5HandleReadingBuffers(); + if (xUSPY5CalculatedBars < xUSPY5MaxLengthOfInputs) + { + return; + } + + // + // Handle Open Trades ... + XUSPY5HandleOpenTrades(); + + // + // Handle Close Trades ... + XUSPY5HandleCloseTrades(); + + // + // DrawDown and DrawUp ... + XUSPY5HandleCalculateDrawDownUp(); +} + +// +// Do Control Checks here ... +void XUSPY5SignalProviderDoControlState() +{ + // + // Update account Balance ... + xUSPY5Balance = xUSPY5AccountInfo.GetBalance(); + xUSPY5FreeMargin = xUSPY5AccountInfo.GetFreeMargin(); + + // + // Check Provider is Enable or Not ... + if (!xUSPY5MEnableProvider) + { + return; + } + + // + // Protect Account by Guarding Maximum Drawdown ... + // TODO: add Guard Result here ... + string guardMessage = ""; + XGuardHandlerResult guardHandlerResult; + bool isGuarded = xUSPY5Guard.Guard( + guardHandlerResult, + guardMessage, + xUSPY5Trader, + _Period); + if (isGuarded) + { + // + // Criticals ... + int criticalsCount = ArraySize(guardHandlerResult.criticals); + if (criticalsCount > 0) + { + // + for (int i = 0; i < criticalsCount; i++) + { + // + XSignal iSignal = guardHandlerResult.criticals[i]; + + // + XUSPY5OnGuard( + iSignal, + X_GUARDED_CRITICAL, + guardMessage); + } + } + + // + // Maxes ... + int maxesCount = ArraySize(guardHandlerResult.maxes); + if (maxesCount > 0) + { + // + for (int i = 0; i < maxesCount; i++) + { + // + XSignal iSignal = guardHandlerResult.maxes[i]; + + // + XUSPY5OnGuard( + iSignal, + X_GUARDED_MAX, + guardMessage, + guardHandlerResult.isStopOut); + } + } + + // + // Olds ... + int oldsCount = ArraySize(guardHandlerResult.olds); + if (oldsCount > 0) + { + // + for (int i = 0; i < oldsCount; i++) + { + // + XSignal iSignal = guardHandlerResult.olds[i]; + + // + XUSPY5OnGuard( + iSignal, + X_GUARDED_OLD, + guardMessage); + } + } + } + + // + // Signal Protection ... + XSignal protectSupports[]; + bool isSupported = xUSPY5Guard.ProtectSignals( + protectSupports, + xUSPY5Trader); + if (isSupported) + { + // + LogMessage("Guard do Support Trdae ..."); + } + + // + // Handling Signals ... + XTraderHandlerResult signalHandlerResult; + xUSPY5Trader.HandleSignals( + signalHandlerResult, + false // Ignore Risk Free Trdaes + ); + + // + // Handle Sl Reports ... + int handledSLsCount = ArraySize(signalHandlerResult.sl); + if (handledSLsCount > 0) + { + // + for (int i = 0; i < handledSLsCount; i++) + { + // + XSignal iSignal = signalHandlerResult.sl[i]; + XUSPY5OnSL(iSignal); + } + } + + // + // Handle TP Reports ... + int handledTPsCount = ArraySize(signalHandlerResult.tp); + if (handledTPsCount > 0) + { + // + for (int i = 0; i < handledTPsCount; i++) + { + // + XSignal iSignal = signalHandlerResult.tp[i]; + XUSPY5OnTP(iSignal); + } + } + + // + // Handle RFs as TP Reports ... + int handledRFsCount = ArraySize(signalHandlerResult.rf); + if (handledRFsCount > 0) + { + // + for (int i = 0; i < handledRFsCount; i++) + { + // + XSignal iSignal = signalHandlerResult.rf[i]; + XUSPY5OnRF(iSignal); + } + } +} + +// +// Handle Trades when OnTrade Event Hnadler Calls ... +void XUSPY5SignalProviderHandleTrade() +{ + // + // Check Provider Enabled ... + if (!xUSPY5MEnableProvider) + { + return; + } + + // + // Handle OnTrade Event ... + XOnTradeHandlerResult result = {}; + xUSPY5Trader.HandleOnTradeEvent( + result); + + // + // Detected TP or SL ... + if (result.hasNewDeal) + { + // + XDeal last = xUSPY5Trader.GetLastDeal(); + + // + if (last.reason == DEAL_REASON_SL) + { + xUSPY5Reporter.AddTradeSLInReports(); + } + else if (last.reason == DEAL_REASON_TP) + { + xUSPY5Reporter.AddTradeTPInReports(); + } + } +} + +// +// Handle Open Trades ... +void XUSPY5HandleOpenTrades() +{ + // + // Check Can Trade ... + bool canTrade = xUSPY5MAllowLongTrades || xUSPY5MAllowShortTrades; + if (!canTrade) + { + return; + } + + // + // Check Max Open Trades ... + int openSignals = xUSPY5Trader.Count(); + bool canOpenPositions = openSignals < xUSPY5MaxAllowedTrades; + if (!canOpenPositions) + { + return; + } + + // + // Check Signals Exists ... + XProvidedSignal longSignalInfo; + XProvidedSignal shortSignalInfo; + bool hasLongSignal = XUSPY5CanOpenLongTrade(longSignalInfo); + bool hasShortSignal = XUSPY5CanOpenShortTrade(shortSignalInfo); + if (!hasLongSignal && !hasShortSignal) + { + return; + } + + // + // Update Reports ... + XUSPY5UpdateReports(); + + // + xUSPY5WaitUntilNextCandle = true; + + // + // Open Long Trades ... + if ( + // + hasLongSignal && + xUSPY5MAllowLongTrades) + { + // + bool isOpened = XUSPY5OpenLongPosition(longSignalInfo); + } + + // + // Open Short Trades ... + if ( + // + hasShortSignal && + xUSPY5MAllowShortTrades) + { + // + bool isOpened = XUSPY5OpenShortPosition(shortSignalInfo); + } +} + +// +// Handle Close Trades ... +void XUSPY5HandleCloseTrades() +{ + // + // Force Close Long Trades ... + bool isClosedLongTrades = false; + bool canCloseLongTrades = XUSPY5CanCloseLongTrade(); + if (xUSPY5MAllowLongTrades && canCloseLongTrades) + { + // + ENUM_X_SIGNAL_TYPE type = X_SIGNAL_LONG; + + // + XSignal closed[]; + xUSPY5Trader.CloseSignals( + closed, + type); + + // + int closedTradesCount = ArraySize(closed); + isClosedLongTrades = closedTradesCount > 0; + if (isClosedLongTrades) + { + // + for (int i = 0; i < closedTradesCount; i++) + { + // + XSignal iSignal = closed[i]; + XUSPY5OnFC(iSignal); + } + } + } + + // + // Force Close Short Trades ... + bool isClosedShortTrades = false; + bool canCloseShortTrades = XUSPY5CanCloseShortTrade(); + if (xUSPY5MAllowShortTrades && canCloseShortTrades) + { + // + ENUM_X_SIGNAL_TYPE type = X_SIGNAL_SHORT; + + // + XSignal closed[]; + xUSPY5Trader.CloseSignals( + closed, + type); + + // + int closedTradesCount = ArraySize(closed); + isClosedShortTrades = closedTradesCount > 0; + if (isClosedShortTrades) + { + // + for (int i = 0; i < closedTradesCount; i++) + { + // + XSignal iSignal = closed[i]; + XUSPY5OnFC(iSignal); + } + } + } +} + +// +// Open Long Position ... +bool XUSPY5OpenLongPosition( + XProvidedSignal &info // Retrieve Signal Additional Info on this Object +) +{ + // + bool result = false; + + // + // Calculate Required Data for Position ... + double entry = GetEntry(_Symbol, X_SIGNAL_LONG); + double sl = info.sl > 0 ? info.sl : 0; + // entry - (200 * _Point); + // info.sl > 0 ? info.sl : 0; + double tp = info.tp > 0 ? info.tp : entry + xUSPY5MinReward; + double riskFreeRate = xUSPY5RiskFreeRate; + double riskFreeStep = xUSPY5RiskFreeStepInPips; + double volume = XUSPY5CalculateVolume(ArraySize(info.signallers)); + + // + XSignal signal = {}; + signal = xUSPY5Trader.GenerateSignal( + X_SIGNAL_LONG, + tp, + sl, + volume, + riskFreeStep, + riskFreeRate); + bool isValidSignal = IsValid( + signal, + xUSPY5MagicNumber); + if (!isValidSignal) + { + return result; + } + + // + int signalsCount = xUSPY5Trader.Count(); + bool isCross = signalsCount >= 1; + if (isCross) + { + // + // Handle Cross Signals ... + XUSPY5HnadleCrossSignal(signal); + } + + // + // Retrieve Can Execute Signal or not ... + bool canExecuteSignal = + !isCross + // + || + // + ( + // + isCross && + xUSPY5CrossSignalsMethod != X_CROSS_SIGNAL_DO_NOTHING + // + ); + if (!canExecuteSignal) + { + return result; + } + + // + // Execute Signal ... + ENUM_EXECUTION_SIGNAL_RESULT executionResult = xUSPY5Trader.ExecuteSignal( + signal, + false, // Ignore Number of Trades ... + true // Check Account Conditions ... + ); + result = executionResult == X_TRADER_SUCCEED_EXECUTION; + if (result) + { + // + // Update Reports ... + string providers[]; + ArrayCopy( + providers, + info.signallers + ); + + // + XSignal tSignal = xUSPY5Trader.GetSignal(signal.ticket); + + // + XUSPY5OnSignal( + tSignal, + providers); + } + else + { + XUSPY5IssueSignalExecutionError(executionResult); + } + + // + return result; +} + +// +// Open Short Position ... +bool XUSPY5OpenShortPosition( + XProvidedSignal &info // Retrieve Signal Additional Info on this Object +) +{ + // + bool result = false; + + // + // Calculate Required Data for Position ... + double entry = GetEntry(_Symbol, X_SIGNAL_SHORT); + double sl = info.sl > 0 ? info.sl : 0; + // entry + (200 * _Point); + // info.sl > 0 ? info.sl : 0; + double tp = info.tp > 0 ? info.tp : entry - xUSPY5MinReward; + double riskFreeRate = xUSPY5RiskFreeRate; + double riskFreeStep = xUSPY5RiskFreeStepInPips; + double volume = XUSPY5CalculateVolume(ArraySize(info.signallers)); + + // + XSignal signal = {}; + signal = xUSPY5Trader.GenerateSignal( + X_SIGNAL_SHORT, + tp, + sl, + volume, + riskFreeStep, + riskFreeRate); + bool isValidSignal = IsValid( + signal, + xUSPY5MagicNumber); + if (!isValidSignal) + { + return result; + } + + // + int signalsCount = xUSPY5Trader.Count(); + bool isCross = signalsCount >= 1; + if (isCross) + { + // + // Handle Cross Signals ... + XUSPY5HnadleCrossSignal(signal); + } + + // + // Retrieve Can Execute Signal or not ... + bool canExecuteSignal = + !isCross + // + || + // + ( + // + isCross && + xUSPY5CrossSignalsMethod != X_CROSS_SIGNAL_DO_NOTHING + // + ); + if (!canExecuteSignal) + { + return result; + } + + // + // Execute Signal ... + ENUM_EXECUTION_SIGNAL_RESULT executionResult = xUSPY5Trader.ExecuteSignal( + signal, + false, // Ignore Number of Trades ... + true // Check Account Conditions ... + ); + result = executionResult == X_TRADER_SUCCEED_EXECUTION; + if (result) + { + string providers[]; + ArrayCopy( + providers, + info.signallers + ); + + // + XSignal tSignal = xUSPY5Trader.GetSignal(signal.ticket); + + // + XUSPY5OnSignal( + tSignal, + providers); + } + else + { + XUSPY5IssueSignalExecutionError(executionResult); + } + + // + return result; +} + +// +// Apply Cross Signal Actions ... +void XUSPY5HnadleCrossSignal( + XSignal &signal // Specified Signal ... +) +{ + // + // Check Cross Signal Handling Enabled ... + if (xUSPY5CrossSignalsMethod == X_CROSS_SIGNAL_DO_NOTHING) + { + return; + } + + // + // First We have to Change Cross Signals Comment ... + string comment = xUSPY5Trader.GenerateSignalComment( + signal, + true); + + // + signal.comment = comment; + + // + // If Every thing is Regular, prevent any changes here ... + if (xUSPY5CrossSignalsMethod == X_CROSS_SIGNAL_REGULAR) + { + return; + } + + // + // Retrieve Max in Drawdown Signal ... + XSignal maxInDDSignal = xUSPY5Trader.GetMaxInDrawdownSignal(); + + // + // Validate Signal ... + bool isValidSignal = + maxInDDSignal.ticket > 0 && + maxInDDSignal.symbol == signal.symbol && + IsValid(maxInDDSignal, xUSPY5MagicNumber); + if (!isValidSignal) + { + return; + } + + // + double volume = signal.volume; + bool isDirectional = maxInDDSignal.type == signal.type; + + // + // Prevent any changes on Regular Conditions ... + bool isRegular = + isDirectional + ? ( + // + xUSPY5CrossSignalsMethod == X_CROSS_SIGNAL_DIRECTION_REGULAR || + xUSPY5CrossSignalsMethod == X_CROSS_SIGNAL_DIRECTION_REGULAR_INDIRECTION_IMPORTANT + // + ) + : ( + // + xUSPY5CrossSignalsMethod == X_CROSS_SIGNAL_INDIRECTION_REGULAR || + xUSPY5CrossSignalsMethod == X_CROSS_SIGNAL_DIRECTION_IMPORTANT_INDIRECTION_REGULAR + // + ); + if (isRegular) + { + return; + } + + // + // Important Act needs to Multiply volume by 2 ... + volume *= 2; + + // + // Set Volume of signal ... + signal.volume = volume; +} + +// +// Calculate Usefull data ... +void XUSPY5HandleCalculateDrawDownUp() +{ + // + XSignal signals[]; + xUSPY5Trader.GetSignals(signals); + int signalsCount = ArraySize(signals); + if (signalsCount <= 0) + { + return; + } + + // + double profit = 0; + double volume = 0; + XCollector collector = {}; + double maxAllowedVolume = xUSPY5VolumeManager.GetMaxAllowedVolume(); + for (int i = 0; i < signalsCount; i++) + { + // + XSignal iSignal = signals[i]; + + // + profit += iSignal.profit; + + // + volume = + volume == 0 || + volume < iSignal.volume + ? iSignal.volume + : volume; + } + + // + if (profit < 0) + { + // + xUSPY5MaxDrawDown = + xUSPY5MaxDrawDown == 0 || + xUSPY5MaxDrawDown > MathAbs(profit) + ? MathAbs(profit) + : xUSPY5MaxDrawDown; + + // + // Update Buffers ... + datetime time = iTime(_Symbol, _Period, 0); + + // + // Calculate Max Allowed Drawdown ... + // + collector.time = time; + collector.volume = volume; + collector.maxDrawDown = xUSPY5MaxDrawDown; + collector.maxAllowedVolume = maxAllowedVolume; + collector.minBalanceForOpenTrade = xUSPY5Trader.GetMinBalanceForOpenTrades(); + } + else + { + // + xUSPY5MaxDrawUp = + xUSPY5MaxDrawUp == 0 || + xUSPY5MaxDrawUp < profit + ? profit + : xUSPY5MaxDrawUp; + } + + // + // Update Collector ... + xUSPY5Collector.Add(collector); + + // + // Update Reports ... + xUSPY5Reporter.UpdateMaxDrawUpInReports(xUSPY5MaxDrawUp); + xUSPY5Reporter.UpdateMaxDrawDownInReports(xUSPY5MaxDrawDown); + xUSPY5Reporter.UpdateMaxSameTimeTradesInReports(signalsCount); +} + +// +// START Event Handlers ... +// + +// +// Runs When a Signal Successfully Executed ... +void XUSPY5OnSignal( + XSignal &signal, // Specified Signal + string &providers[] // Signal Providers +) +{ + // + // Issue Propper Alert ... + XUSPY5IssueSignalExecutionAlert( + signal, + providers); + + // + // Add Signal To Supports on Guard ... + xUSPY5Guard.AddSupport(signal); + + // + // Update Reports ... + xUSPY5Reporter.AddSignalToReports( + signal, + providers); +} + +// +// Runs when a Position Got Take Profit ... +void XUSPY5OnTP( + XSignal &signal // Specified Signal +) +{ + // + // Issue Propper Alert ... + XUSPY5IssueTPAlert(signal); + + // + // Remove Signal From Guard Protector ... + xUSPY5Guard.Remove(signal.ticket); + xUSPY5Guard.RemoveSupport(signal.ticket); + + // + // Update Reports ... + xUSPY5Reporter.AddTradeTPInReports(); + XUSPY5UpdateReports(); +} + +// +// Runs when a Position Got Stop Loss ... +void XUSPY5OnSL( + XSignal &signal // Specified Signal +) +{ + // + // Issue Propper Alert ... + XUSPY5IssueSLAlert(signal); + + // + // Remove Signal From Guard Protector ... + xUSPY5Guard.Remove(signal.ticket); + xUSPY5Guard.RemoveSupport(signal.ticket); + + // + // Update Reports ... + xUSPY5Reporter.AddTradeSLInReports(); + XUSPY5UpdateReports(); +} + +// +// Runs when a Position Risk Free ... +void XUSPY5OnRF( + XSignal &signal // Specified Signal +) +{ + // + // Issue Propper Alert ... + XUSPY5IssueRFAlert(signal); + + // + // Remove Signal From Guard Protector ... + // since RiskFree Signals has SL ... + xUSPY5Guard.Remove(signal.ticket); + xUSPY5Guard.RemoveSupport(signal.ticket); + + // + // Update Reports ... + xUSPY5Reporter.AddTradeSLInReports(); + XUSPY5UpdateReports(); +} + +// +// Runs when a Position Force Closed ... +void XUSPY5OnFC( + XSignal &signal // Specified Signal +) +{ + // + // Issue Propper Alert ... + XUSPY5IssueFCAlert(signal); + + // + // Remove Signal From Guard Protector ... + xUSPY5Guard.Remove(signal.ticket); + xUSPY5Guard.RemoveSupport(signal.ticket); + + // + // Update Reports ... + xUSPY5Reporter.AddTradeSLInReports(); + XUSPY5UpdateReports(); +} + +// +// Runs when a Position Guarded ... +void XUSPY5OnGuard( + XSignal &signal, // Specified Signal + ENUM_X_GUARD_REASONS reason, // Reason of Guard Applied + string message, // Guard Returned Message + bool isStopOut = false // Specified StopOut Fired or not +) +{ + // + // Chekc StopOut ... + if (isStopOut) + { + // + LogMessage(message); + + // + xUSPY5MEnableProvider = false; + } + + // + // Issue Propper Alert ... + XUSPY5IssueGuardAlert(signal, reason, isStopOut); + + // + // Update Reports ... + xUSPY5Reporter.AddTradeSLInReports(); + XUSPY5UpdateReports(); +} + +// +// END Event Handlers ... +// + +// +// END Provided Functions ... +// + +// +// START Private Functions ... +// + +// +// START Volume Baseed Functions ... +// + +// +// Calculating Volume for Tradings ... +double XUSPY5CalculateVolume( + double forceMultiplier = 0 // some times we get more than one signal at the same time, here we increase volume using this ... +) +{ + // + // Check Open Trades ... + int openSignals = xUSPY5Trader.Count(); + + // + double result = xUSPY5VolumeManager.CalculateVolume( + openSignals, + _Symbol); + + // + result *= forceMultiplier; + + // + // Normalize Volume ... + result = NormalizeVolume(result, _Symbol, 2); + + // + return result; +} + +// +// END Volume Baseed Functions ... +// + +// +// START Report/Collect and Guard Functions ... +// + +// +// Update Report Info ... +void XUSPY5UpdateReports() +{ + // + double staticVolume = xUSPY5VolumeManager.GetStaticVolume(); + string staticVolumeCalculationMethod = EnumToString(xUSPY5StaticVolumeMethod); + double maxAllowedVolume = xUSPY5VolumeManager.GetMaxAllowedVolume(); + double volumeIncreaseMultiplier = xUSPY5VolumeManager.GetVolumeMultiplier(); + double balanceGowingToApplyMultiplier = xUSPY5VolumeManager.GetIncreaseMultiplierBalance(); + + double balanceGrowingToIncreaseMaxAllowedVolume = xUSPY5VolumeManager.GetIncreaseMaxAllowedVolumeBalance(); + + // + // Update Reports Volume Info ... + xUSPY5Reporter.UpdateReportsVolumeInfo( + staticVolume, + staticVolumeCalculationMethod, + maxAllowedVolume, + volumeIncreaseMultiplier, + balanceGowingToApplyMultiplier, + balanceGrowingToIncreaseMaxAllowedVolume); + + // + // Calculate Max Allowed Drawdown ... + double minBalanceForTradeBasedOnBalance = xUSPY5Trader.GetMinBalanceForOpenTrades(); + xUSPY5Reporter.UpdateMinBalanceForOpenTradesInReports(minBalanceForTradeBasedOnBalance); +} + +// +// Reset XUSPY5 Info Buffers ... +void XUSPY5ResetCollectors() +{ + // + // Reset Calculations Buffers and Variables ... + xUSPY5MaxDrawUp = 0; + xUSPY5MaxDrawDown = 0; + + // + xUSPY5Trader.Reset(); + xUSPY5Reporter.Reset(); + xUSPY5Collector.Reset(); + xUSPY5VolumeManager.ResetForceVolumeMultiplier(); +} + +// +// END Report/Collect and Guard Functions ... +// + +// +// START Alert Functions ... +// + +// +// Send Alert ... +void XUSPY5IssueAlert(string message) +{ + // + // Validate Args ... + if (StringLen(message) <= 0) + { + return; + } + + // + if (xUSPY5EnableAlerts) + { + SendAlert(message); + } + else + { + LogMessage(message); + } +} + +// +// Send Take Profit Alert on Specific Signal ... +void XUSPY5IssueTPAlert( + XSignal &signal // Specified Signal +) +{ + // + string message = ""; + + // + message = xUSPY5Trader.GenerateSignalTPComment(signal); + + // + XUSPY5IssueAlert(message); +} + +// +// Send Stop Loss Alert on Specific Signal ... +void XUSPY5IssueSLAlert( + XSignal &signal // Specified Signal +) +{ + // + string message = ""; + + // + message = xUSPY5Trader.GenerateSignalSLComment(signal); + + // + XUSPY5IssueAlert(message); +} + +// +// Send Force Close Alert on Specific Signal ... +void XUSPY5IssueFCAlert( + XSignal &signal // Specified Signal +) +{ + // + string message = ""; + + // + message = xUSPY5Trader.GenerateSignalForceCloseComment(signal); + + // + XUSPY5IssueAlert(message); +} + +// +// Send Risk Free Alert on Specific Signal ... +void XUSPY5IssueRFAlert( + XSignal &signal // Specified Signal +) +{ + // + string message = ""; + + // + message = xUSPY5Trader.GenerateSignalRFComment(signal, 0); + + // + XUSPY5IssueAlert(message); +} + +// +// Send Guard Alert on Specific Signal ... +void XUSPY5IssueGuardAlert( + XSignal &signal, // Specified Signal + ENUM_X_GUARD_REASONS reason, // Specified Guard Reason + bool isStopOut = false // Specified StopOut Fired or not +) +{ + // + string message = ""; + + // + message = xUSPY5Guard.GenerateGuardedSignalComment( + signal, + reason); + + // + XUSPY5IssueAlert(message); +} + +// +// Send Initialization Succeed Alert ... +void XUSPY5IssueInitializationSucceedAlert() +{ + // + string message = "Initializion of (" + XUSPY5ProviderName + " Provider" + " _ " + _Symbol + " _ " + EnumToString(_Period) + ") Succeeded ..."; + XUSPY5IssueAlert(message); +} + +// +// Send De Initialization Succeed Alert ... +void XUSPY5IssueDeinitializationSucceedAlert() +{ + // + string message = "De Initializion of (" + XUSPY5ProviderName + " Provider" + ") Succeeded ..."; + XUSPY5IssueAlert(message); +} + +// +// Send Signal Successfully Execution Alert ... +void XUSPY5IssueSignalExecutionAlert( + XSignal &signal, // Specified Signal + string &providers[] // Signal Providers +) +{ + // + string message = xUSPY5Trader.ToString(signal); + + // + string providersMsg = ToString(providers); + if (StringLen(providersMsg) > 0) + { + message += ", Providers: " + providersMsg; + } + + // + XUSPY5IssueAlert(message); +} + +// +// Send Signal Execution Alert ... +void XUSPY5IssueSignalExecutionError(int error) +{ + // + string message = GetSignalExecutionError(error); + if (StringLen(message) == 0) + { + return; + } + + // + XUSPY5IssueAlert(message); +} + +// +// END Alert Functions ... +// + +// +// END Private Functions ... +// diff --git a/Projects/XUSPY5/Settings/XTD.set b/Projects/XUSPY5/Settings/XTD.set index f9e3fe91..693478f2 100644 Binary files a/Projects/XUSPY5/Settings/XTD.set and b/Projects/XUSPY5/Settings/XTD.set differ diff --git a/Providers/x-saherelm.xuspy5.provider.indicators.lib.mq5 b/Providers/x-saherelm.xuspy5.provider.indicators.lib.mq5 index 7a1f9b6b..a09daa41 100644 --- a/Providers/x-saherelm.xuspy5.provider.indicators.lib.mq5 +++ b/Providers/x-saherelm.xuspy5.provider.indicators.lib.mq5 @@ -1959,6 +1959,23 @@ bool XUSPY5XTDHasLongSignal() // ) // + || + // + // Check LC Fast Over Slow ... + ((mConditions.isXCHMALCTrendsDown || + mConditions.isXCHMALCFastOverSlow) && + ( + // + (mConditions.isXCHMALCPeak && + mConditions.isXTSCurrentMax && + mConditions.isXCHMASCOverMax && + mConditions.isXFICrossedOverZero && + mConditions.isXTDSignalCrossedOverBear) + // + ) + // + ) + // ) // )