diff --git a/Classes/x-saherelm.x5.provider.class.mq5 b/Classes/x-saherelm.x5.provider.class.mq5 index 40da8b9d..a4453983 100644 --- a/Classes/x-saherelm.x5.provider.class.mq5 +++ b/Classes/x-saherelm.x5.provider.class.mq5 @@ -2781,8 +2781,12 @@ public: { // string mConditionsStr = mConditions.GenerateSummary(true); + + // + string providerTypeStr = provider + "(" + (hasLong ? "Long" : "Short") + ")" + "\n"; + mConditionsStr = providerTypeStr + "\n" + mConditionsStr; mConditionsCollector.Add(mConditionsStr); - Print("Conditions: " + "\n" + mConditionsStr); + Print(mConditionsStr); } // @@ -94956,6 +94960,59 @@ private: // // Tools ... +// +// Model Provider Descriptor ... +struct X5ProvierDescriptor +{ + // + X5ProviderInputs inputs; + XSCX5Provider *provider; + + // + XSignal signal; + X5MarketConditions conditions; + + // + // Tools ... + + // + // Cleanup ... + void Clean() + { + // + signal.Clean(); + conditions.Clear(); + } + + // + // Check Signal ... + bool HasSignal(int barIndex = 0) + { + // + bool result = false; + + // + result = inputs.IsValid(); + if (!result) + { + return result; + } + + // + // Clear Signal and Conditions ... + Clean(); + + // + result = provider.HasSignal( + barIndex, + signal, + conditions); + + // + return result; + } +}; + // void GetAllX5SignalProviders(ENUM_X5_SIGNAL_PROVIDERS &result[]) { @@ -94975,6 +95032,12 @@ void GetAllX5SignalProviders(ENUM_X5_SIGNAL_PROVIDERS &result[]) Add(XCHMAMX, result); } +// +string ToString(ENUM_X5_SIGNAL_PROVIDERS value) +{ + return EnumToString(value); +} + // ENUM_X5_SIGNAL_PROVIDERS ToX5SignalProvider(string content) { diff --git a/Experts/x-test.x5ea.mq5 b/Experts/x-test.x5ea.mq5 index f8e02cbf..487a0d10 100644 --- a/Experts/x-test.x5ea.mq5 +++ b/Experts/x-test.x5ea.mq5 @@ -24,15 +24,13 @@ // #include "../Libraries/x-saherelm.log.lib.mq5" -#include "../Libraries/x-saherelm.draw.lib.mq5" -#include "../Libraries/x-saherelm.common.lib.mq5" -#include "../Classes/x-saherelm.xtrade.class.mq5" #include "../Classes/x-saherelm.x5.provider.class.mq5" // // Inputs ... long x5EAMagicNumber = 78692110; // Magic Number int x5EASlippage = 10; // Slippgae +string x5EASymbols = "EURUSDb,USDCHFb,USDJPYb,XAUUSDb"; // double x5EAVolume = 0.01; @@ -48,12 +46,13 @@ MqlTick x5EATick; // // X5Provider ... XSignal signal; -X5ProviderInputs x5Inputs; -XSCX5Provider *x5Provider; -X5MarketConditions conditions; + +// +X5ProvierDescriptor mProviderDescriptors[]; // // Event Handlers ... + // // Initialization ... int OnInit() @@ -79,42 +78,14 @@ int OnInit() // logTag = ShortName; - drawPrefix = ShortName; // - // Set Default and Validate X5Provider Inputs ... - x5Inputs.Default(); - if (!x5Inputs.IsValid()) + // Initial Providers ... + if (!InitialProviders()) { return INIT_PARAMETERS_INCORRECT; } - // - // Init X5Provider Class ... - x5Provider = new XSCX5Provider( - x5EASymbol, - x5EAPeriod - // - ); - if (!x5Provider.Init(x5Inputs)) - { - return INIT_PARAMETERS_INCORRECT; - } - - // - // Enable Required Signallers and Types ... - x5Provider.SetSignalTypeState( - POSITION_TYPE_BUY, - true); - x5Provider.SetSignalTypeState( - POSITION_TYPE_SELL, - true); - - // - ENUM_X5_SIGNAL_PROVIDERS providers[]; - GetAllX5SignalProviders(providers); - x5Provider.SetSignalProviderStates(providers, true); - // // Init Succeed ... return INIT_SUCCEEDED; @@ -152,9 +123,7 @@ void OnTick() } // - signal.Clean(); - conditions.Clear(); - x5Provider.HasSignal(1, signal, conditions); + ProcessProvidersTick(); } // @@ -178,3 +147,151 @@ bool X5EAValidateInputs() // return result; } + +// +// Initialize Specific Providers ... +bool InitialProviders() +{ + // + bool result = false; + + // + // Here We Have to Initial 4 instance of X5Provider ... + // - EURUSD/M5; + // - USDCHF/M5; + // - USDJPY/M5; + // - XAUUSD/M5; + + // + result = IsValid(x5EASymbols); + if (!result) + { + return result; + } + + // + string symbols[]; + int symbolsCount = SplitContent( + symbols, + x5EASymbols); + result = symbolsCount > 0; + if (!result) + { + return result; + } + + // + // Define Signallers ... + ENUM_X5_SIGNAL_PROVIDERS signallers[]; + GetAllX5SignalProviders(signallers); + + // + for (int i = 0; i < symbolsCount; i++) + { + // + // Define Structure ... + X5ProvierDescriptor iDescriptor; + + // + // Set Inputs to Default ... + iDescriptor.inputs.Default(); + + // + // Validate Inputs ... + bool isInputsValid = iDescriptor.inputs.IsValid(); + if (!isInputsValid) + { + continue; + } + + // + // Initialize Provider Class ... + iDescriptor.provider = new XSCX5Provider( + symbols[i], + PERIOD_M5 // + ); + + // + // Enable Required Signallers and Types ... + // TODO: add Support for TYPE Specifications ... + iDescriptor.provider + .SetSignalTypeState( + POSITION_TYPE_BUY, + true // + ); + iDescriptor.provider + .SetSignalTypeState( + POSITION_TYPE_SELL, + true // + ); + + // + // Enable Required Signallers ... + iDescriptor.provider + .SetSignalProviderStates(signallers, true); + + // + // Try to Initialize Provider Instance ... + bool isInitialized = iDescriptor.provider + .Init(iDescriptor.inputs); + if (!isInitialized) + { + continue; + } + + // + // Add Prepared Descriptor to Collection ... + AddRef( + iDescriptor, + mProviderDescriptors + // + ); + } + + // + // Validate Result ... + result = ArraySize(mProviderDescriptors) == symbolsCount; + + // + return result; +} + +// +// Check Providers Signals ... +void ProcessProvidersTick() +{ + // + // Here We Have to Check 4 instance of X5Provider for Signals ... + // - EURUSD/M5; + // - USDCHF/M5; + // - USDJPY/M5; + // - XAUUSD/M5; + + // + int descriptorsCount = ArraySize(mProviderDescriptors); + if (descriptorsCount <= 0) + { + return; + } + + // + int signalsCount = 0; + for (int i = 0; i < descriptorsCount; i++) + { + // + X5ProvierDescriptor iDescriptor = mProviderDescriptors[i]; + + // + bool iHasSignal = iDescriptor.HasSignal(0); + + // + if (iHasSignal) + { + // + signalsCount++; + Print("Signal: " + iDescriptor.provider.GetSymbol() + ", " + ToString(iDescriptor.provider.GetPeriod())); + } + } +} + +// \ No newline at end of file diff --git a/Helpers/x-saherelm.xcc.helper.mq5 b/Helpers/x-saherelm.xcc.helper.mq5 index c16b4bdf..98bec867 100644 --- a/Helpers/x-saherelm.xcc.helper.mq5 +++ b/Helpers/x-saherelm.xcc.helper.mq5 @@ -36,12 +36,13 @@ struct XCCInputs // // Chart Style ... - color upColor; // Up Color - color downColor; // Down Color - color lineColor; // Line mode and Doji candlestick Color - color bearishColor; // Bullish Color - color bullishColor; // Bearish Color - color volumesColor; // Volumes Color + ENUM_CHART_MODE mode; // Mode + color upColor; // Up Color + color downColor; // Down Color + color lineColor; // Line mode and Doji candlestick Color + color bearishColor; // Bullish Color + color bullishColor; // Bearish Color + color volumesColor; // Volumes Color // // Presentation ... @@ -62,6 +63,9 @@ struct XCCInputs // Clean ... void Clean() { + // + mode = CHART_CANDLES; + // upColor = CLR_NONE; downColor = CLR_NONE; @@ -78,6 +82,9 @@ struct XCCInputs // Default ... void Default() { + // + mode = CHART_CANDLES; + // upColor = clrLime; downColor = clrRed; @@ -147,7 +154,7 @@ public: bool Init( string symbol, // Trading Symbol ENUM_TIMEFRAMES period, // Trading Period - XCCInputs &inputs // Inputs + XCCInputs &inputs // Inputs ) { // @@ -177,6 +184,7 @@ public: // // Chart Style ... "", + mInputs.mode, // Mode mInputs.upColor, // Up Color mInputs.downColor, // Down Color mInputs.lineColor, // Line mode and Doji candlestick Color diff --git a/Indicators/x-saherelm.xcc.mq5 b/Indicators/x-saherelm.xcc.mq5 index f0445ebe..2e11f1c3 100644 --- a/Indicators/x-saherelm.xcc.mq5 +++ b/Indicators/x-saherelm.xcc.mq5 @@ -106,12 +106,13 @@ struct XChartStyle // input group "Chart Style"; -input color upColor = clrLime; // Up Color -input color downColor = clrRed; // Down Color -input color lineColor = clrLime; // Line mode and Doji candlestick Color -input color bearishColor = clrRed; // Bullish Color -input color bullishColor = clrLime; // Bearish Color -input color volumesColor = clrGreen; // Volumes Color +input ENUM_CHART_MODE mode = CHART_CANDLES; // Mode +input color upColor = clrLime; // Up Color +input color downColor = clrRed; // Down Color +input color lineColor = clrLime; // Line mode and Doji candlestick Color +input color bearishColor = clrRed; // Bullish Color +input color bullishColor = clrLime; // Bearish Color +input color volumesColor = clrGreen; // Volumes Color // input group "Presentation"; @@ -412,6 +413,7 @@ void ReadChartStyle() chartStyle.volumesColor = (color)ChartGetInteger(chartId, CHART_COLOR_VOLUME); // + chartStyle.mode = mode; chartStyle.upColor = upColor; chartStyle.downColor = downColor; chartStyle.lineColor = lineColor; diff --git a/Libraries/x-saherelm.common.lib.mq5 b/Libraries/x-saherelm.common.lib.mq5 index 049965af..9a1dcd9b 100644 --- a/Libraries/x-saherelm.common.lib.mq5 +++ b/Libraries/x-saherelm.common.lib.mq5 @@ -1022,7 +1022,7 @@ struct XOHCL } // - ENUM_SERIESMODE mode = swing == X_SWING_HIGH + ENUM_SERIESMODE mMode = swing == X_SWING_HIGH ? MODE_HIGH : MODE_LOW; @@ -1031,13 +1031,13 @@ struct XOHCL ? iHighest( symbol, period, - mode, + mMode, mLength, from) : iLowest( symbol, period, - mode, + mMode, mLength, from); @@ -1049,7 +1049,7 @@ struct XOHCL // Find Lowest Bar Index ... int FindHighestIndex( int mLength, // Loopback ... - ENUM_SERIESMODE mode // Calculation mode + ENUM_SERIESMODE mMode // Calculation mode ) { // @@ -1071,7 +1071,7 @@ struct XOHCL result = iHighest( symbol, period, - mode, + mMode, mLength, Index()); @@ -1083,7 +1083,7 @@ struct XOHCL // Find Lowest ... double FindHighest( int mLength, // Loopback ... - ENUM_SERIESMODE mode // Calculation mode + ENUM_SERIESMODE mMode // Calculation mode ) { // @@ -1098,7 +1098,7 @@ struct XOHCL // int idx = FindHighestIndex( mLength, - mode); + mMode); if (idx <= -1) { return result; @@ -1118,7 +1118,7 @@ struct XOHCL } // - result = iH.GetPrice(mode); + result = iH.GetPrice(mMode); // return result; @@ -1128,7 +1128,7 @@ struct XOHCL // Find Lowest Bar Index ... int FindLowestIndex( int mLength, // Loopback ... - ENUM_SERIESMODE mode // Calculation mode + ENUM_SERIESMODE mMode // Calculation mode ) { // @@ -1150,7 +1150,7 @@ struct XOHCL result = iLowest( symbol, period, - mode, + mMode, mLength, Index()); @@ -1162,7 +1162,7 @@ struct XOHCL // Find Lowest ... double FindLowest( int mLength, // Loopback ... - ENUM_SERIESMODE mode // Calculation mode + ENUM_SERIESMODE mMode // Calculation mode ) { // @@ -1177,7 +1177,7 @@ struct XOHCL // int idx = FindLowestIndex( mLength, - mode); + mMode); if (idx <= -1) { return result; @@ -1197,7 +1197,7 @@ struct XOHCL } // - result = iL.GetPrice(mode); + result = iL.GetPrice(mMode); // return result; @@ -3069,14 +3069,14 @@ double PointToPrice( // // Converts Series Mode to XPRICE ... ENUM_X_PRICE ToPrice( - ENUM_SERIESMODE mode // Specified Series Mode ... + ENUM_SERIESMODE mMode // Specified Series Mode ... ) { // ENUM_X_PRICE result = X_PRICE_CLOSE; // - switch (mode) + switch (mMode) { // // High ...