From 9c9ac86211ca28ade6e1243cc2d25516fbf07797 Mon Sep 17 00:00:00 2001 From: Adrian Kierzkowski Date: Tue, 7 Nov 2023 17:14:31 +0100 Subject: [PATCH 1/3] Refs #11. MQL5 compatible version of SuperSlope oscillator. Unsure if it works correctly. --- .../{SuperSlope.mq5.fixme => SuperSlope.mq5} | 52 ++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) rename Oscillators/{SuperSlope.mq5.fixme => SuperSlope.mq5} (55%) diff --git a/Oscillators/SuperSlope.mq5.fixme b/Oscillators/SuperSlope.mq5 similarity index 55% rename from Oscillators/SuperSlope.mq5.fixme rename to Oscillators/SuperSlope.mq5 index 8d7c8bc..379140c 100644 --- a/Oscillators/SuperSlope.mq5.fixme +++ b/Oscillators/SuperSlope.mq5 @@ -41,7 +41,44 @@ #define extern input #define Bars (ChartStatic::iBars(_Symbol, _Period)) #define Bid (SymbolInfoStatic::GetBid(_Symbol)) -#define TimeDayOfWeek (DateTime::DateOfWeek()) +#define TimeDayOfWeek DateTimeStatic::DayOfWeek + +int WindowFirstVisibleBar(const long chart_ID = 0) { + long result = -1; + + ResetLastError(); + + if (!ChartGetInteger(chart_ID, CHART_FIRST_VISIBLE_BAR, 0, result)) { + Print(__FUNCTION__ + ", Error Code = ", GetLastError()); + } + + return (int)result; +} + +int WindowBarsPerChart() { return ChartGetInteger(0, CHART_VISIBLE_BARS, 0); } + +int ObjectFind(string name) { return ObjectFind(0, name); } + +bool ObjectSetText(string name, string text, int font_size, string font = "", + color text_color = CLR_NONE) { + int tmpObjType = (int)ObjectGetInteger(0, name, OBJPROP_TYPE); + if (tmpObjType != OBJ_LABEL && tmpObjType != OBJ_TEXT) + return (false); + if (StringLen(text) > 0 && font_size > 0) { + if (ObjectSetString(0, name, OBJPROP_TEXT, text) == true && + ObjectSetInteger(0, name, OBJPROP_FONTSIZE, font_size) == true) { + if ((StringLen(font) > 0) && + ObjectSetString(0, name, OBJPROP_FONT, font) == false) + return (false); + if (text_color > -1 && + ObjectSetInteger(0, name, OBJPROP_COLOR, text_color) == false) + return (false); + return (true); + } + return (false); + } + return (false); +} // Define global functions. #undef DoubleToStr @@ -57,6 +94,19 @@ int WindowsTotal(const long _cid = 0) { } return (int)result; } +int WindowOnDropped() { return ChartWindowOnDropped(); } +int WindowFind(string name) { + int window = -1; + if ((ENUM_PROGRAM_TYPE)MQLInfoInteger(MQL_PROGRAM_TYPE) == + PROGRAM_INDICATOR) { + window = ChartWindowFind(); + } else { + window = ChartWindowFind(0, name); + if (window == -1) + Print(__FUNCTION__ + "(): Error = ", GetLastError()); + } + return (window); +} // Includes the main file. #include "SuperSlope.mq4" From 7f6450fc33dd8172084a8bf032c7818293ff5427 Mon Sep 17 00:00:00 2001 From: Adrian Kierzkowski Date: Tue, 7 Nov 2023 19:44:06 +0100 Subject: [PATCH 2/3] Refs #11. Fixed warnings. "Compile" GitHub action will now use EA31337-classes v3.000-dev. --- .github/workflows/compile.yml | 2 +- Oscillators/SuperSlope.mq5 | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index ca47653..ea90a50 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -51,7 +51,7 @@ jobs: - uses: actions/checkout@v3 with: path: Include/EA31337-classes - ref: v3.000.1 + ref: v3.000-dev repository: EA31337/EA31337-classes - name: Compile (build 2361) uses: fx31337/mql-compile-action@master diff --git a/Oscillators/SuperSlope.mq5 b/Oscillators/SuperSlope.mq5 index 379140c..b0e73a8 100644 --- a/Oscillators/SuperSlope.mq5 +++ b/Oscillators/SuperSlope.mq5 @@ -55,7 +55,9 @@ int WindowFirstVisibleBar(const long chart_ID = 0) { return (int)result; } -int WindowBarsPerChart() { return ChartGetInteger(0, CHART_VISIBLE_BARS, 0); } +int WindowBarsPerChart() { + return (int)ChartGetInteger(0, CHART_VISIBLE_BARS, 0); +} int ObjectFind(string name) { return ObjectFind(0, name); } @@ -70,7 +72,7 @@ bool ObjectSetText(string name, string text, int font_size, string font = "", if ((StringLen(font) > 0) && ObjectSetString(0, name, OBJPROP_FONT, font) == false) return (false); - if (text_color > -1 && + if (text_color != CLR_NONE && ObjectSetInteger(0, name, OBJPROP_COLOR, text_color) == false) return (false); return (true); @@ -108,6 +110,20 @@ int WindowFind(string name) { return (window); } +// Following methods are only valid when used in MQL4 code. +string StringTrimLeftMQL4(string text) { + StringTrimLeft(text); + return text; +} + +string StringTrimRightMQL4(string text) { + StringTrimRight(text); + return text; +} + +#define StringTrimLeft StringTrimLeftMQL4 +#define StringTrimRight StringTrimRightMQL4 + // Includes the main file. #include "SuperSlope.mq4" From be542c4538c84b08325e0882983da296b9b70390 Mon Sep 17 00:00:00 2001 From: Adrian Kierzkowski Date: Wed, 22 Nov 2023 19:09:10 +0100 Subject: [PATCH 3/3] Refs #8. ATR_MA_Trend now uses IndicatorLegacy.h file to allow using MQL5 versions of iNAME() indicators like iMA(), iRSI() in MQL4. We use it to run MQL5 indicator in MQL4. --- Misc/ATR_MA_Trend.mq4 | 43 ++++++++++++++++++++++++++++++++++++++ Misc/ATR_MA_Trend.mq4.todo | 7 ------- 2 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 Misc/ATR_MA_Trend.mq4 delete mode 100644 Misc/ATR_MA_Trend.mq4.todo diff --git a/Misc/ATR_MA_Trend.mq4 b/Misc/ATR_MA_Trend.mq4 new file mode 100644 index 0000000..d33267a --- /dev/null +++ b/Misc/ATR_MA_Trend.mq4 @@ -0,0 +1,43 @@ +/** + * @file + * Implements strategy's indicator. + */ + +#include + +#property indicator_chart_window +#property indicator_buffers 4 +#property indicator_plots 4 +//+----------------------------------------------+ +//| Bullish indicator rendering options | +//+----------------------------------------------+ +#property indicator_type1 DRAW_LINE +#property indicator_color1 Blue +#property indicator_style1 STYLE_DASHDOTDOT +#property indicator_width1 2 +#property indicator_label1 "Upper TrendValue" +//+----------------------------------------------+ +//| Bearish indicator rendering options | +//+----------------------------------------------+ +#property indicator_type2 DRAW_LINE +#property indicator_color2 MediumVioletRed +#property indicator_style2 STYLE_DASHDOTDOT +#property indicator_width2 2 +#property indicator_label2 "Lower TrendValue" +//+----------------------------------------------+ +//| Bullish indicator rendering options | +//+----------------------------------------------+ +#property indicator_type3 DRAW_ARROW +#property indicator_color3 DeepSkyBlue +#property indicator_width3 4 +#property indicator_label3 "Buy TrendValue" +//+----------------------------------------------+ +//| Bearish indicator rendering options | +//+----------------------------------------------+ +#property indicator_type4 DRAW_ARROW +#property indicator_color4 Red +#property indicator_width4 4 +#property indicator_label4 "Sell TrendValue" + +// Includes the main file. +#include "ATR_MA_Trend.mq5" diff --git a/Misc/ATR_MA_Trend.mq4.todo b/Misc/ATR_MA_Trend.mq4.todo deleted file mode 100644 index c0f4400..0000000 --- a/Misc/ATR_MA_Trend.mq4.todo +++ /dev/null @@ -1,7 +0,0 @@ -/** - * @file - * Implements strategy's indicator. - */ - -// Includes the main file. -#include "ATR_MA_Trend.mq5"