From 5f55fa68f15f69128e9e35331828177927262400 Mon Sep 17 00:00:00 2001 From: Vyacheslav Demidyuk Date: Tue, 11 Mar 2025 18:57:57 +0200 Subject: [PATCH] PyMtApi5: implemented function ChartSetString --- PyMtApi5/client.py | 12 +++++++++++- PyMtApi5/mt5apiclient.py | 5 +++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/PyMtApi5/client.py b/PyMtApi5/client.py index 8ba92c17..d8c9bde4 100644 --- a/PyMtApi5/client.py +++ b/PyMtApi5/client.py @@ -72,6 +72,7 @@ class Mt5ApiApp: "ChartPeriod": self.process_chart_period, "ChartSetDouble": self.process_chart_set_double, "ChartSetInteger": self.process_chart_set_integer, + "ChartSetString": self.process_chart_set_string, } def on_disconnect(self, error_msg=None): @@ -532,9 +533,18 @@ class Mt5ApiApp: print(f"! Invalid parameters for command ChartSetInteger: {parameters}") return prop_id = mt5enums.ENUM_CHART_PROPERTY_INTEGER(int(pieces[1])) - result = mtapi.chart_set_integer(int(pieces[0]), prop_id, float(pieces[2])) + result = mtapi.chart_set_integer(int(pieces[0]), prop_id, int(pieces[2])) print(f"> ChartSetInteger: response = {result}") + def process_chart_set_string(self, mtapi, parameters): + pieces = parameters.split(" ", 2) + if len(pieces) != 3 or not pieces[0] or not pieces[1] or not pieces[2]: + print(f"! Invalid parameters for command ChartSetString: {parameters}") + return + prop_id = mt5enums.ENUM_CHART_PROPERTY_STRING(int(pieces[1])) + result = mtapi.chart_set_string(int(pieces[0]), prop_id, pieces[2]) + print(f"> ChartSetString: response = {result}") + def mtapi_command_thread(self, mtapi): while mtapi.is_connected(): filename = "client.cmd" diff --git a/PyMtApi5/mt5apiclient.py b/PyMtApi5/mt5apiclient.py index dbbc658c..0c29a657 100644 --- a/PyMtApi5/mt5apiclient.py +++ b/PyMtApi5/mt5apiclient.py @@ -534,6 +534,11 @@ class Mt5ApiClient: cmd_params = {"ChartId": chart_id, "PropId": prop_id, "Value": value} return self.__send_command(self.__get_default_expert(), Mt5CommandType.ChartSetInteger, cmd_params) + # ChartSetString + def chart_set_string(self, chart_id, prop_id: ENUM_CHART_PROPERTY_STRING, value): + cmd_params = {"ChartId": chart_id, "PropId": prop_id, "Value": value} + return self.__send_command(self.__get_default_expert(), Mt5CommandType.ChartSetString, cmd_params) + # Private methods def __event_thread_func(self):