diff --git a/PyMtApi5/client.py b/PyMtApi5/client.py index 429ff6d4..93c20bcf 100644 --- a/PyMtApi5/client.py +++ b/PyMtApi5/client.py @@ -58,6 +58,7 @@ class Mt5ApiApp: "CopySpread": self.process_copy_spread, "CopyTicks": self.process_copy_ticks, "ChartId": self.process_chart_id, + "ChartRedraw": self.process_chart_redraw, } def on_disconnect(self, error_msg=None): @@ -427,6 +428,10 @@ class Mt5ApiApp: result = mtapi.chart_id(int(parameters)) print(f"> ChatId: response = {result}") + def process_chart_redraw(self, mtapi, parameters): + mtapi.chart_redraw(int(parameters)) + print(f"> ChartRedraw: success") + def mtapi_command_thread(self, mtapi): while mtapi.is_connected(): filename = "client.cmd" diff --git a/PyMtApi5/mt5apiclient.py b/PyMtApi5/mt5apiclient.py index 3858cb85..912ae338 100644 --- a/PyMtApi5/mt5apiclient.py +++ b/PyMtApi5/mt5apiclient.py @@ -458,6 +458,10 @@ class Mt5ApiClient: else: return self.__send_command(expert_handle, Mt5CommandType.ChartId) + def chart_redraw(self, chart_id = 0): + cmd_params = {"ChartId": chart_id} + self.__send_command(self.__get_default_expert(), Mt5CommandType.ChartRedraw, cmd_params) + # Private methods def __event_thread_func(self): @@ -489,7 +493,9 @@ class Mt5ApiClient: error_message = response_json["ErrorMessage"] self.__logger.warning(f"send_command: ErrorCode = {error_code}. {error_message}") raise Exception(f"Failed to send command: ErrorCode = {error_code}. {error_message} ") - return response_json["Value"] + if "Value" in response_json: + return response_json["Value"] + return None def __process_tick_event(self, payload): quote_json = json.loads(payload)