From 45473cd42365a34cd3bae32441f006f38f73d06d Mon Sep 17 00:00:00 2001 From: Aster Seker Date: Thu, 2 Jul 2026 20:18:57 +0300 Subject: [PATCH 1/8] refactor(mql): use TimeShield for MT4 legacy timing Update the time-shield-cpp submodule to the MQL4 facade commit and replace the local MT4 legacy timing helper logic with calls through TimeShield.mqh. --- external/time-shield-cpp | 2 +- .../OptionX/v1/lib/legacy-time-utils.mqh | 56 ++++--------------- mql/legacy_trading_connector/README.md | 6 +- 3 files changed, 15 insertions(+), 49 deletions(-) diff --git a/external/time-shield-cpp b/external/time-shield-cpp index d3c251b..214e3af 160000 --- a/external/time-shield-cpp +++ b/external/time-shield-cpp @@ -1 +1 @@ -Subproject commit d3c251bf173ee6222f6e79186a34c4a0592d5767 +Subproject commit 214e3af84b33dafccfb13172d3966f6341be5ef7 diff --git a/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/lib/legacy-time-utils.mqh b/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/lib/legacy-time-utils.mqh index 861862d..724a544 100644 --- a/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/lib/legacy-time-utils.mqh +++ b/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/lib/legacy-time-utils.mqh @@ -7,72 +7,38 @@ #property strict -const int LEGACY_TRADING_SEC_PER_MIN = 60; -const int LEGACY_TRADING_SEC_PER_DAY = 86400; +#include + +const long LEGACY_TRADING_SEC_PER_MIN = time_shield::SEC_PER_MIN; +const long LEGACY_TRADING_SEC_PER_DAY = time_shield::SEC_PER_DAY; uint legacy_trading_sec_of_day(const datetime timestamp) { - return (uint)((ulong)timestamp % LEGACY_TRADING_SEC_PER_DAY); + return (uint)time_shield::sec_of_day((long)timestamp); } uint legacy_trading_sec_of_day(const int hour, const int minute, const int second) { - return (uint)(hour * LEGACY_TRADING_SEC_PER_MIN * 60 + minute * LEGACY_TRADING_SEC_PER_MIN + second); + return (uint)time_shield::sec_of_day(hour, minute, second); } uint legacy_trading_sec_of_day(const string value) { - uint hour = 0; - uint minute = 0; - uint second = 0; - - string parts[]; - const ushort separator = StringGetCharacter(":", 0); - const int count = StringSplit(value, separator, parts); - if (count == 0 || count > 3) { - ArrayFree(parts); - return LEGACY_TRADING_SEC_PER_DAY; - } - - if (count >= 1) hour = (uint)StringToInteger(parts[0]); - if (count >= 2) minute = (uint)StringToInteger(parts[1]); - if (count >= 3) second = (uint)StringToInteger(parts[2]); - - ArrayFree(parts); - - if (hour >= 24 || minute >= 60 || second >= 60) { - return LEGACY_TRADING_SEC_PER_DAY; - } - - return legacy_trading_sec_of_day((int)hour, (int)minute, (int)second); + return (uint)time_shield::sec_of_day(value); } class LegacyTradingTimer { private: - ulong m_start_time; - uint m_prev_tick_count; - ulong m_tick_count_offset; - - ulong tick_count64() { - const ulong max_tick_count = 4294967295; - const uint current = GetTickCount(); - if (current < m_prev_tick_count) { - m_tick_count_offset += max_tick_count; - } - m_prev_tick_count = current; - return m_tick_count_offset + current; - } + long m_start_time_ms; public: LegacyTradingTimer() { - m_tick_count_offset = 0; - m_prev_tick_count = 0; reset(); } void reset() { - m_start_time = tick_count64(); + m_start_time_ms = time_shield::monotonic_ms(); } ulong get_elapsed_ms() { - return tick_count64() - m_start_time; + return (ulong)(time_shield::monotonic_ms() - m_start_time_ms); } double get_elapsed() { @@ -80,4 +46,4 @@ public: } }; -#endif // OPTIONX_LEGACY_TRADING_TIME_UTILS_MQH \ No newline at end of file +#endif // OPTIONX_LEGACY_TRADING_TIME_UTILS_MQH diff --git a/mql/legacy_trading_connector/README.md b/mql/legacy_trading_connector/README.md index 17b96dc..a2f15f4 100644 --- a/mql/legacy_trading_connector/README.md +++ b/mql/legacy_trading_connector/README.md @@ -34,9 +34,9 @@ instead of extending this one. Copy the contents of either `MQL4` or `MQL5` into the corresponding terminal data folder, preserving the `Include` and `Indicators` directory structure. -The MT5 package includes ``. Install the MQL5 headers from the -`time-shield-cpp` package into the terminal `MQL5/Include` directory before -compiling the MT5 connector. +The MT4 and MT5 packages include ``. Install the matching MQL +headers from the `time-shield-cpp` package into the terminal `MQL4/Include` or +`MQL5/Include` directory before compiling the connector. Compile `LegacyTradingConnector.mq4` or `LegacyTradingConnector.mq5` in MetaEditor. The C++ CI does not compile MQL files. From efb7479fb642a165fd745ced7983eb9aaf47eb5e Mon Sep 17 00:00:00 2001 From: Aster Seker Date: Thu, 2 Jul 2026 20:33:35 +0300 Subject: [PATCH 2/8] fix(mql): use direct TimeShield constants Update the TimeShield submodule to the MQL4 class facade and replace legacy connector constant aliases with direct TimeShield constants in the MQL4 and MQL5 connector helpers. --- external/time-shield-cpp | 2 +- .../Include/OptionX/v1/lib/legacy-time-utils.mqh | 15 ++++++--------- .../Include/OptionX/v1/utils/signal-capture.mqh | 2 +- .../MQL4/Include/OptionX/v1/utils/tools.mqh | 8 ++++---- .../Include/OptionX/v1/lib/legacy-time-utils.mqh | 5 +---- .../Include/OptionX/v1/utils/signal-capture.mqh | 4 ++-- .../MQL5/Include/OptionX/v1/utils/tools.mqh | 8 ++++---- 7 files changed, 19 insertions(+), 25 deletions(-) diff --git a/external/time-shield-cpp b/external/time-shield-cpp index 214e3af..458e897 160000 --- a/external/time-shield-cpp +++ b/external/time-shield-cpp @@ -1 +1 @@ -Subproject commit 214e3af84b33dafccfb13172d3966f6341be5ef7 +Subproject commit 458e897df58eff29e064360013bdd169a79808ad diff --git a/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/lib/legacy-time-utils.mqh b/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/lib/legacy-time-utils.mqh index 724a544..8b1cc2b 100644 --- a/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/lib/legacy-time-utils.mqh +++ b/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/lib/legacy-time-utils.mqh @@ -9,24 +9,21 @@ #include -const long LEGACY_TRADING_SEC_PER_MIN = time_shield::SEC_PER_MIN; -const long LEGACY_TRADING_SEC_PER_DAY = time_shield::SEC_PER_DAY; - uint legacy_trading_sec_of_day(const datetime timestamp) { - return (uint)time_shield::sec_of_day((long)timestamp); + return (uint)TimeShield::sec_of_day((long)timestamp); } uint legacy_trading_sec_of_day(const int hour, const int minute, const int second) { - return (uint)time_shield::sec_of_day(hour, minute, second); + return (uint)TimeShield::sec_of_day(hour, minute, second); } uint legacy_trading_sec_of_day(const string value) { - return (uint)time_shield::sec_of_day(value); + return (uint)TimeShield::sec_of_day(value); } class LegacyTradingTimer { private: - long m_start_time_ms; + ulong m_start_time_ms; public: LegacyTradingTimer() { @@ -34,11 +31,11 @@ public: } void reset() { - m_start_time_ms = time_shield::monotonic_ms(); + m_start_time_ms = TimeShield::monotonic_ms(); } ulong get_elapsed_ms() { - return (ulong)(time_shield::monotonic_ms() - m_start_time_ms); + return TimeShield::monotonic_ms() - m_start_time_ms; } double get_elapsed() { diff --git a/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/signal-capture.mqh b/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/signal-capture.mqh index c21fd7f..60e504e 100644 --- a/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/signal-capture.mqh +++ b/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/signal-capture.mqh @@ -378,7 +378,7 @@ private: datetime signal_bar_time = 0; const datetime current_time = TimeCurrent(); - const long period_duration = config.period * LEGACY_TRADING_SEC_PER_MIN; + const long period_duration = config.period * TimeShield::SEC_PER_MIN; const datetime close_bar_time = open_bar_time + (datetime)period_duration; // обрабатываем событие, когда бар еще не закрылся diff --git a/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/tools.mqh b/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/tools.mqh index fbf1fb1..0bd965e 100644 --- a/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/tools.mqh +++ b/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/tools.mqh @@ -164,12 +164,12 @@ public: bool set(const string &arg_str_start_time, const string &arg_str_stop_time) { time_start = legacy_trading_sec_of_day(arg_str_start_time); - if (time_start == LEGACY_TRADING_SEC_PER_DAY) { + if (time_start == TimeShield::SEC_PER_DAY) { error_code = 1; return false; } time_stop = legacy_trading_sec_of_day(arg_str_stop_time); - if (time_stop == LEGACY_TRADING_SEC_PER_DAY) { + if (time_stop == TimeShield::SEC_PER_DAY) { error_code = 2; return false; } @@ -311,7 +311,7 @@ public: block_bar_time = 0; block_time = 0; const datetime current_time = TimeCurrent(); - const long period_duration = Period() * LEGACY_TRADING_SEC_PER_MIN; + const long period_duration = Period() * TimeShield::SEC_PER_MIN; last_open_bar_time = (datetime)((long)current_time - ((long)current_time % period_duration)); prev_bar_time = Time[0]; logger = NULL; @@ -371,7 +371,7 @@ public: const datetime gmt_time = TimeGMT(); const datetime current_time = TimeCurrent(); const datetime open_bar_time = Time[0]; - const long period_duration = Period() * LEGACY_TRADING_SEC_PER_MIN; + const long period_duration = Period() * TimeShield::SEC_PER_MIN; const datetime last_close_bar_time = last_open_bar_time + (datetime)period_duration; if (current_time >= last_close_bar_time) { diff --git a/mql/legacy_trading_connector/MQL5/Include/OptionX/v1/lib/legacy-time-utils.mqh b/mql/legacy_trading_connector/MQL5/Include/OptionX/v1/lib/legacy-time-utils.mqh index abf03b4..b7ac628 100644 --- a/mql/legacy_trading_connector/MQL5/Include/OptionX/v1/lib/legacy-time-utils.mqh +++ b/mql/legacy_trading_connector/MQL5/Include/OptionX/v1/lib/legacy-time-utils.mqh @@ -9,9 +9,6 @@ #include -const long LEGACY_TRADING_SEC_PER_MIN = time_shield::SEC_PER_MIN; -const long LEGACY_TRADING_SEC_PER_DAY = time_shield::SEC_PER_DAY; - int legacy_trading_sec_of_day(const datetime timestamp) { return time_shield::sec_of_day((long)timestamp); } @@ -48,4 +45,4 @@ public: } }; -#endif // OPTIONX_LEGACY_TRADING_TIME_UTILS_MQH \ No newline at end of file +#endif // OPTIONX_LEGACY_TRADING_TIME_UTILS_MQH diff --git a/mql/legacy_trading_connector/MQL5/Include/OptionX/v1/utils/signal-capture.mqh b/mql/legacy_trading_connector/MQL5/Include/OptionX/v1/utils/signal-capture.mqh index 4ac0918..bcfabf6 100644 --- a/mql/legacy_trading_connector/MQL5/Include/OptionX/v1/utils/signal-capture.mqh +++ b/mql/legacy_trading_connector/MQL5/Include/OptionX/v1/utils/signal-capture.mqh @@ -185,7 +185,7 @@ private: if (StringLen(arrow_name) > 4 && StringSubstr(arrow_name, 0, 4) == "#MC_") continue; datetime arrow_time = (datetime)ObjectGetInteger(0, arrow_name, OBJPROP_TIME); - const datetime period_duration = config.period * LEGACY_TRADING_SEC_PER_MIN; + const datetime period_duration = config.period * time_shield::SEC_PER_MIN; arrow_time -= arrow_time % period_duration; const datetime open_bar_time = get_candle_time(shift); //Print("arrow " + TimeToString(arrow_time, TIME_DATE | TIME_MINUTES | TIME_SECONDS), " t: " + TimeToString(open_bar_time, TIME_DATE | TIME_MINUTES | TIME_SECONDS)); @@ -358,7 +358,7 @@ private: datetime signal_bar_time = 0; const datetime current_time = TimeCurrent(); - const long period_duration = config.period * LEGACY_TRADING_SEC_PER_MIN; + const long period_duration = config.period * time_shield::SEC_PER_MIN; const datetime close_bar_time = open_bar_time + (datetime)period_duration; // обрабатываем событие, когда бар еще не закрылся diff --git a/mql/legacy_trading_connector/MQL5/Include/OptionX/v1/utils/tools.mqh b/mql/legacy_trading_connector/MQL5/Include/OptionX/v1/utils/tools.mqh index e21977f..1773a79 100644 --- a/mql/legacy_trading_connector/MQL5/Include/OptionX/v1/utils/tools.mqh +++ b/mql/legacy_trading_connector/MQL5/Include/OptionX/v1/utils/tools.mqh @@ -238,12 +238,12 @@ public: bool set(const string &arg_str_time_start, const string &arg_str_time_stop) { time_start = legacy_trading_sec_of_day(arg_str_time_start); - if (time_start == LEGACY_TRADING_SEC_PER_DAY) { + if (time_start == time_shield::SEC_PER_DAY) { error_code = 1; return false; } time_stop = legacy_trading_sec_of_day(arg_str_time_stop); - if (time_stop == LEGACY_TRADING_SEC_PER_DAY) { + if (time_stop == time_shield::SEC_PER_DAY) { error_code = 2; return false; } @@ -384,7 +384,7 @@ public: block_time = 0; block_bar_time = 0; const datetime current_time = TimeCurrent(); - const long period_duration = Period() * LEGACY_TRADING_SEC_PER_MIN; + const long period_duration = Period() * time_shield::SEC_PER_MIN; last_open_bar_time = (datetime)((long)current_time - ((long)current_time % period_duration)); prev_bar_time = get_candle_time(); handle = INVALID_HANDLE; @@ -443,7 +443,7 @@ public: const datetime gmt_time = TimeGMT(); const datetime current_time = TimeCurrent(); - const long period_duration = Period() * LEGACY_TRADING_SEC_PER_MIN; + const long period_duration = Period() * time_shield::SEC_PER_MIN; const datetime last_close_bar_time = last_open_bar_time + (datetime)period_duration; if (current_time >= last_close_bar_time) { From 8121c7038a5eac1445a03b1824e65de94207a597 Mon Sep 17 00:00:00 2001 From: Aster Seker Date: Thu, 2 Jul 2026 20:46:32 +0300 Subject: [PATCH 3/8] build(mql): update TimeShield submodule Point the legacy MQL bridge integration at the TimeShield revision that exposes a single MQL4 TimeShield.mqh header. --- external/time-shield-cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/time-shield-cpp b/external/time-shield-cpp index 458e897..9a304da 160000 --- a/external/time-shield-cpp +++ b/external/time-shield-cpp @@ -1 +1 @@ -Subproject commit 458e897df58eff29e064360013bdd169a79808ad +Subproject commit 9a304da066039694b0b4ff5d8db4e6ff2e7a8f23 From 8fc1ad7d2bc37bca231683edd64af2dbe7aa8c33 Mon Sep 17 00:00:00 2001 From: Aster Seker Date: Thu, 2 Jul 2026 21:05:50 +0300 Subject: [PATCH 4/8] build(mql): point TimeShield submodule at merged PR Update the TimeShield submodule to the main-branch merge commit for NewYaroslav/time-shield-cpp#114. --- external/time-shield-cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/time-shield-cpp b/external/time-shield-cpp index 9a304da..d5bb4aa 160000 --- a/external/time-shield-cpp +++ b/external/time-shield-cpp @@ -1 +1 @@ -Subproject commit 9a304da066039694b0b4ff5d8db4e6ff2e7a8f23 +Subproject commit d5bb4aac0d7e9193173d3df96b3e7a0e066bfbbf From 0b740f22036c44e3c7bcd0d72fa8636c53f32bab Mon Sep 17 00:00:00 2001 From: Aster Seker Date: Thu, 2 Jul 2026 21:37:15 +0300 Subject: [PATCH 5/8] fix(mql4): use TimeShield constants compatibly Use the constants exported by TimeShield.mqh in the form accepted by the MQL4 compiler, avoiding unsupported class-qualified enum access. --- .../MQL4/Include/OptionX/v1/utils/signal-capture.mqh | 2 +- .../MQL4/Include/OptionX/v1/utils/tools.mqh | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/signal-capture.mqh b/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/signal-capture.mqh index 60e504e..146bd14 100644 --- a/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/signal-capture.mqh +++ b/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/signal-capture.mqh @@ -378,7 +378,7 @@ private: datetime signal_bar_time = 0; const datetime current_time = TimeCurrent(); - const long period_duration = config.period * TimeShield::SEC_PER_MIN; + const long period_duration = config.period * SEC_PER_MIN; const datetime close_bar_time = open_bar_time + (datetime)period_duration; // обрабатываем событие, когда бар еще не закрылся diff --git a/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/tools.mqh b/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/tools.mqh index 0bd965e..ecaa0d7 100644 --- a/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/tools.mqh +++ b/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/tools.mqh @@ -164,12 +164,12 @@ public: bool set(const string &arg_str_start_time, const string &arg_str_stop_time) { time_start = legacy_trading_sec_of_day(arg_str_start_time); - if (time_start == TimeShield::SEC_PER_DAY) { + if (time_start == SEC_PER_DAY) { error_code = 1; return false; } time_stop = legacy_trading_sec_of_day(arg_str_stop_time); - if (time_stop == TimeShield::SEC_PER_DAY) { + if (time_stop == SEC_PER_DAY) { error_code = 2; return false; } @@ -311,7 +311,7 @@ public: block_bar_time = 0; block_time = 0; const datetime current_time = TimeCurrent(); - const long period_duration = Period() * TimeShield::SEC_PER_MIN; + const long period_duration = Period() * SEC_PER_MIN; last_open_bar_time = (datetime)((long)current_time - ((long)current_time % period_duration)); prev_bar_time = Time[0]; logger = NULL; @@ -371,7 +371,7 @@ public: const datetime gmt_time = TimeGMT(); const datetime current_time = TimeCurrent(); const datetime open_bar_time = Time[0]; - const long period_duration = Period() * TimeShield::SEC_PER_MIN; + const long period_duration = Period() * SEC_PER_MIN; const datetime last_close_bar_time = last_open_bar_time + (datetime)period_duration; if (current_time >= last_close_bar_time) { From 58e157186dc7b58a654a68b38684587c1fff1838 Mon Sep 17 00:00:00 2001 From: Aster Seker Date: Thu, 2 Jul 2026 22:15:07 +0300 Subject: [PATCH 6/8] fix(mql): satisfy MetaEditor compilers Update the TimeShield submodule to the MQL MetaEditor fix branch and adjust the legacy connector MQL4/MQL5 code paths found by local MetaEditor compilation. --- external/time-shield-cpp | 2 +- .../Include/OptionX/v1/utils/signal-capture.mqh | 2 +- .../MQL4/Include/OptionX/v1/utils/tools.mqh | 8 ++++---- .../Include/OptionX/v1/api/legacy-trading-api.mqh | 6 ++++-- .../named_pipe_client.mqh | 15 ++++++++------- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/external/time-shield-cpp b/external/time-shield-cpp index d5bb4aa..2b9fc6f 160000 --- a/external/time-shield-cpp +++ b/external/time-shield-cpp @@ -1 +1 @@ -Subproject commit d5bb4aac0d7e9193173d3df96b3e7a0e066bfbbf +Subproject commit 2b9fc6f201bf38689ad18d4a3253c66ba0d9b5fb diff --git a/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/signal-capture.mqh b/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/signal-capture.mqh index 146bd14..aa51d04 100644 --- a/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/signal-capture.mqh +++ b/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/signal-capture.mqh @@ -378,7 +378,7 @@ private: datetime signal_bar_time = 0; const datetime current_time = TimeCurrent(); - const long period_duration = config.period * SEC_PER_MIN; + const long period_duration = config.period * TimeShield::sec_per_min(); const datetime close_bar_time = open_bar_time + (datetime)period_duration; // обрабатываем событие, когда бар еще не закрылся diff --git a/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/tools.mqh b/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/tools.mqh index ecaa0d7..9524184 100644 --- a/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/tools.mqh +++ b/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/tools.mqh @@ -164,12 +164,12 @@ public: bool set(const string &arg_str_start_time, const string &arg_str_stop_time) { time_start = legacy_trading_sec_of_day(arg_str_start_time); - if (time_start == SEC_PER_DAY) { + if (time_start == TimeShield::sec_per_day()) { error_code = 1; return false; } time_stop = legacy_trading_sec_of_day(arg_str_stop_time); - if (time_stop == SEC_PER_DAY) { + if (time_stop == TimeShield::sec_per_day()) { error_code = 2; return false; } @@ -311,7 +311,7 @@ public: block_bar_time = 0; block_time = 0; const datetime current_time = TimeCurrent(); - const long period_duration = Period() * SEC_PER_MIN; + const long period_duration = Period() * TimeShield::sec_per_min(); last_open_bar_time = (datetime)((long)current_time - ((long)current_time % period_duration)); prev_bar_time = Time[0]; logger = NULL; @@ -371,7 +371,7 @@ public: const datetime gmt_time = TimeGMT(); const datetime current_time = TimeCurrent(); const datetime open_bar_time = Time[0]; - const long period_duration = Period() * SEC_PER_MIN; + const long period_duration = Period() * TimeShield::sec_per_min(); const datetime last_close_bar_time = last_open_bar_time + (datetime)period_duration; if (current_time >= last_close_bar_time) { diff --git a/mql/legacy_trading_connector/MQL5/Include/OptionX/v1/api/legacy-trading-api.mqh b/mql/legacy_trading_connector/MQL5/Include/OptionX/v1/api/legacy-trading-api.mqh index 989e3db..431dbb4 100644 --- a/mql/legacy_trading_connector/MQL5/Include/OptionX/v1/api/legacy-trading-api.mqh +++ b/mql/legacy_trading_connector/MQL5/Include/OptionX/v1/api/legacy-trading-api.mqh @@ -124,8 +124,10 @@ private: //MC_BO_WIN //MC_BO_LOSS - updated_bo.getInt("step", bo.step); - updated_bo.getInt("max_step", bo.max_step); + int step = 0; + int max_step = 0; + if(updated_bo.getInt("step", step)) bo.step = (uint)step; + if(updated_bo.getInt("max_step", max_step)) bo.max_step = (uint)max_step; string status_str = updated_bo.getString("status"); if(status_str == "win") bo.status = MegaConnectorBoStatus::MC_BO_WIN; diff --git a/mql/legacy_trading_connector/MQL5/Include/OptionX/v1/lib/simple-named-pipe-server/named_pipe_client.mqh b/mql/legacy_trading_connector/MQL5/Include/OptionX/v1/lib/simple-named-pipe-server/named_pipe_client.mqh index c9843df..1abbada 100644 --- a/mql/legacy_trading_connector/MQL5/Include/OptionX/v1/lib/simple-named-pipe-server/named_pipe_client.mqh +++ b/mql/legacy_trading_connector/MQL5/Include/OptionX/v1/lib/simple-named-pipe-server/named_pipe_client.mqh @@ -26,7 +26,7 @@ ulong CreateNamedPipe(string pipeName,int openMode,int pipeMode,int maxInstances int WaitNamedPipeW(string lpNamedPipeName,int nTimeOut); bool SetNamedPipeHandleState(HANDLE fileHandle,int &lpMode, int lpMaxCollectionCount,int lpCollectDataTimeout); int WriteFile(HANDLE file,uchar &buffer[],uint number_of_bytes_to_write,uint &number_of_bytes_written,PVOID overlapped); -int ReadFile(HANDLE file,char &buffer[],uint number_of_bytes_to_read,uint &number_of_bytes_read,PVOID overlapped); +int ReadFile(HANDLE file,uchar &buffer[],uint number_of_bytes_to_read,uint &number_of_bytes_read,PVOID overlapped); bool PeekNamedPipe(HANDLE fileHandle, int buffer, int bytes, int bytesRead, int &numOfBytes, int bytesLeftThisMessage); #import //+------------------------------------------------------------------+ @@ -190,7 +190,8 @@ public: bool write(string message) { if (pipe_handle == INVALID_HANDLE_VALUE) return false; if (StringLen(message) == 0) return false; - int bytes_to_write, bytes_written; + int bytes_to_write; + uint bytes_written = 0; uchar utf8_array[]; bytes_to_write = StringToCharArray(message, utf8_array, 0, -1, CP_UTF8); bytes_to_write = ArraySize(utf8_array); @@ -198,10 +199,10 @@ public: WriteFile( pipe_handle, utf8_array, - bytes_to_write, + (uint)bytes_to_write, bytes_written, NULL); - if(bytes_written != bytes_to_write) { + if(bytes_written != (uint)bytes_to_write) { close(); return false; } @@ -216,14 +217,14 @@ public: string ret; uchar char_array[]; ArrayResize(char_array, buffer_size); - int bytes_read; + uint bytes_read = 0; ReadFile( pipe_handle, char_array, - buffer_size, + (uint)buffer_size, bytes_read, 0); - if(bytes_read != 0) ret = CharArrayToString(char_array, 0, bytes_read, CP_UTF8); + if(bytes_read != 0) ret = CharArrayToString(char_array, 0, (int)bytes_read, CP_UTF8); return ret; } From 637be5ed4721c723f59bbedd54b62357ef560647 Mon Sep 17 00:00:00 2001 From: Aster Seker Date: Thu, 2 Jul 2026 23:20:17 +0300 Subject: [PATCH 7/8] fix(mql4): use TimeShield prefixed constants Update the legacy MQL4 connector to use TSHIELD-prefixed TimeShield constants and point the submodule at the matching dependency revision. --- external/time-shield-cpp | 2 +- .../MQL4/Include/OptionX/v1/utils/signal-capture.mqh | 2 +- .../MQL4/Include/OptionX/v1/utils/tools.mqh | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/external/time-shield-cpp b/external/time-shield-cpp index 2b9fc6f..f75c61a 160000 --- a/external/time-shield-cpp +++ b/external/time-shield-cpp @@ -1 +1 @@ -Subproject commit 2b9fc6f201bf38689ad18d4a3253c66ba0d9b5fb +Subproject commit f75c61a1d55577e486c83c4d1a58fa96a6a68935 diff --git a/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/signal-capture.mqh b/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/signal-capture.mqh index aa51d04..118396e 100644 --- a/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/signal-capture.mqh +++ b/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/signal-capture.mqh @@ -378,7 +378,7 @@ private: datetime signal_bar_time = 0; const datetime current_time = TimeCurrent(); - const long period_duration = config.period * TimeShield::sec_per_min(); + const long period_duration = config.period * TSHIELD_SEC_PER_MIN; const datetime close_bar_time = open_bar_time + (datetime)period_duration; // обрабатываем событие, когда бар еще не закрылся diff --git a/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/tools.mqh b/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/tools.mqh index 9524184..4655e4a 100644 --- a/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/tools.mqh +++ b/mql/legacy_trading_connector/MQL4/Include/OptionX/v1/utils/tools.mqh @@ -164,12 +164,12 @@ public: bool set(const string &arg_str_start_time, const string &arg_str_stop_time) { time_start = legacy_trading_sec_of_day(arg_str_start_time); - if (time_start == TimeShield::sec_per_day()) { + if (time_start == TSHIELD_SEC_PER_DAY) { error_code = 1; return false; } time_stop = legacy_trading_sec_of_day(arg_str_stop_time); - if (time_stop == TimeShield::sec_per_day()) { + if (time_stop == TSHIELD_SEC_PER_DAY) { error_code = 2; return false; } @@ -311,7 +311,7 @@ public: block_bar_time = 0; block_time = 0; const datetime current_time = TimeCurrent(); - const long period_duration = Period() * TimeShield::sec_per_min(); + const long period_duration = Period() * TSHIELD_SEC_PER_MIN; last_open_bar_time = (datetime)((long)current_time - ((long)current_time % period_duration)); prev_bar_time = Time[0]; logger = NULL; @@ -371,7 +371,7 @@ public: const datetime gmt_time = TimeGMT(); const datetime current_time = TimeCurrent(); const datetime open_bar_time = Time[0]; - const long period_duration = Period() * TimeShield::sec_per_min(); + const long period_duration = Period() * TSHIELD_SEC_PER_MIN; const datetime last_close_bar_time = last_open_bar_time + (datetime)period_duration; if (current_time >= last_close_bar_time) { From 8e0727c222a519743bcd6c4c9c6928d5a3e71b38 Mon Sep 17 00:00:00 2001 From: Aster Seker Date: Thu, 2 Jul 2026 23:32:31 +0300 Subject: [PATCH 8/8] build(mql): update TimeShield header revision --- external/time-shield-cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/time-shield-cpp b/external/time-shield-cpp index f75c61a..e9d9972 160000 --- a/external/time-shield-cpp +++ b/external/time-shield-cpp @@ -1 +1 @@ -Subproject commit f75c61a1d55577e486c83c4d1a58fa96a6a68935 +Subproject commit e9d99727d705b263636b305d9bddfb4da0c6af0e