From e9e313fa58dec4afb60085187148be50df28e7f8 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Thu, 20 Jun 2024 13:38:54 +0330 Subject: [PATCH] last ... --- Classes/x-saherelm.x121.setup.class.mq5 | 5 + Classes/x-saherelm.x121.setup.xea.mq5 | 24 +- Classes/x-saherelm.xscsupres.class.mq5 | 330 ++++++++++++++++++++++++ 3 files changed, 352 insertions(+), 7 deletions(-) create mode 100644 Classes/x-saherelm.xscsupres.class.mq5 diff --git a/Classes/x-saherelm.x121.setup.class.mq5 b/Classes/x-saherelm.x121.setup.class.mq5 index 9914cca4..524fc362 100644 --- a/Classes/x-saherelm.x121.setup.class.mq5 +++ b/Classes/x-saherelm.x121.setup.class.mq5 @@ -3608,7 +3608,12 @@ struct X121SignalGenerator // if (canUseZones) { + // signal.zones.Draw(); + + // + // Find Hot Zones ... + } // diff --git a/Classes/x-saherelm.x121.setup.xea.mq5 b/Classes/x-saherelm.x121.setup.xea.mq5 index 3a6e87e3..d456503d 100644 --- a/Classes/x-saherelm.x121.setup.xea.mq5 +++ b/Classes/x-saherelm.x121.setup.xea.mq5 @@ -35,13 +35,13 @@ struct XTradeInfo { // - int pushers; // Signal Pushers - datetime time; // Issue Time (Open Position) - string symbol; // Trading Symbol - double entry; // Entry Price - double volume; // Volume - string provider; // Signaller - ENUM_TIMEFRAMES period; // Trading Timeframe + int pushers; // Signal Pushers + datetime time; // Issue Time (Open Position) + string symbol; // Trading Symbol + double entry; // Entry Price + double volume; // Volume + string provider; // Signaller + ENUM_TIMEFRAMES period; // Trading Timeframe ENUM_X_POSITION_TYPES type; // Position Type // @@ -3885,6 +3885,16 @@ public: } } + // + // TODO: Remove this ... + // isSignalValid = !AllowSupport() + // ? true + // : IsValidSize(ArraySize(iSignal.supports)); + // if (!isSignalValid) + // { + // continue; + // } + // // Filter Signals Based On Max Allowed ... if (maxAllowed > 0) diff --git a/Classes/x-saherelm.xscsupres.class.mq5 b/Classes/x-saherelm.xscsupres.class.mq5 new file mode 100644 index 00000000..e5dda43f --- /dev/null +++ b/Classes/x-saherelm.xscsupres.class.mq5 @@ -0,0 +1,330 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 Class Library +// ---------------------------------------------- +// Name: XSCSupRes +// Description: provides all Support and Resistances requirements ... +// +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// +// +// Global Properties ... +#property library +#property copyright "Copyright 2023, SaherElm IT Center" +#property link "https://www.saherelm.ir" +#property version "1.00" +#property strict + +// +// Imports ... +#include "../Classes/x-saherelm.base.class.mq5" +#include "../Helpers/x-saherelm.xpv.helper.mq5" +#include "../Libraries/x-saherelm.draw.lib.mq5" + +// +// Definitions ... +struct XSCSupResInput +{ + // + // Props ... + + // + int numberOfSupports; // Number of Required Supports + int numberOfResistances; // Number of Required Resistances + + // + int pivotsVerifications; // Pivots Verifications + + // + double distance; // Distance between Pivots + + // + double price; // Price for Support and Resistance Finding + + // + color clrSupport; + color clrResistance; + + // + // Constructor ... + void XSCSupResInput() + { + Clean(); + } + + // + // Tools ... + + // + // Cleanup ... + void Clean() + { + // + numberOfSupports = 0; + numberOfResistances = 0; + + // + price = 0; + distance = 0; + pivotsVerifications = 0; + + // + clrSupport = CLR_NONE; + clrResistance = CLR_NONE; + } + + // + // Defualt Configs ... + void Default() + { + // + numberOfSupports = 5; + numberOfResistances = 5; + + // + price = 0; + distance = 10; + pivotsVerifications = 35; + + // + clrSupport = clrAqua; + clrResistance = clrMagenta; + } + + // + // Validate ... + bool IsValid() + { + // + bool result = false; + + // + result = + // + price > 0 && + distance >= 0 && + numberOfSupports > 0 && + numberOfResistances > 0 && + pivotsVerifications > 2 + // + ; + + // + return result; + } +}; + +// +// Class ... + +// +class XSCSupRes : public XSCBase +{ + // + // Public ... +public: + // + // Props ... + + // + // Constructor ... + void XSCSupRes( + string symbol, + ENUM_TIMEFRAMES period // + ) : XSCBase() + { + // + mSymbol = symbol; + mPeriod = period; + } + + // + // Deconstructor ... + void ~XSCSupRes() {} + + // + // Initializer ... + bool Init(XSCSupResInput &inputs) + { + // + bool result = false; + + // + result = inputs.IsValid(); + if (!result) + { + return result; + } + + // + mInputs = inputs; + + // + // Find Pivots ... + result = FindPivots(); + if (!result) + { + return result; + } + + // + return result; + } + + // + // Getter(s) / Setter(s) ... + + // + string GetSymbol() + { + return mSymbol; + } + + // + ENUM_TIMEFRAMES GetPeriod() + { + return mPeriod; + } + + // + XSCSupResInput GetInputs() + { + return mInputs; + } + + // + bool SetInputs(XSCSupResInput &inputs) + { + return Init(inputs); + } + + // + // Overrides ... + + // + string GetTag() override + { + return "XSupRes"; + } + + // + // Tools ... + + // + // Validate ... + bool IsValid() + { + // + bool result = false; + + // + result = + // + false + // + ; + + // + return result; + } + + // + // Retrieve Title Prefix ... + string GetIdentifier() + { + // + string result = NULL; + + // + if (!IsValid()) + { + return result; + } + + // + result = GetTag() + "_" + + mSymbol + "_" + + ToString(mPeriod) + "_"; + + // + return result; + } + + // + // Protected ... +protected: + // + // Tools ... + + // + // Private ... +private: + // + // Props ... + + // + string mSymbol; // Trading Symbol ... + ENUM_TIMEFRAMES mPeriod; // Trading Period ... + + // + XSCSupResInput mInputs; // Configs ... + + // + double mSupports[]; + double mResistances[]; + + // + // Tools ... + + // + bool FindPivots(int barIndex = 0) + { + // + bool result = false; + + // + int totalBars = iBars( + mSymbol, + mPeriod // + ); + + // + result = barIndex >= 0 && barIndex < totalBars - mInputs.pivotsVerifications; + if (!result) { + return result; + } + + // + int next = barIndex + 1; + bool canNext = next >= 0 && next < totalBars - mInputs.pivotsVerifications; + + // + XSCXPVHelper helper = new XSCXPVHelper(); + XPVInputs pvInputs; + pvInputs.Default(); + result = helper.Init( + mSymbol, + mPeriod, + pvInputs // + ); + if (!result) + { + return result; + } + + // + // TODO: Complete this ... + + // + // Check States ... + + // + return result; + } +}; + +// \ No newline at end of file