mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-19 05:38:12 +00:00
PyMtApi5: implemented function ChartTimePriceToXY
This commit is contained in:
@@ -62,6 +62,7 @@ class Mt5ApiApp:
|
|||||||
"ChartApplyTemplate": self.process_chart_apply_template,
|
"ChartApplyTemplate": self.process_chart_apply_template,
|
||||||
"ChartSaveTemplate": self.process_chart_save_template,
|
"ChartSaveTemplate": self.process_chart_save_template,
|
||||||
"ChartWindowFind": self.process_chart_window_find,
|
"ChartWindowFind": self.process_chart_window_find,
|
||||||
|
"ChartTimePriceToXY": self.process_chart_time_price_to_xy,
|
||||||
}
|
}
|
||||||
|
|
||||||
def on_disconnect(self, error_msg=None):
|
def on_disconnect(self, error_msg=None):
|
||||||
@@ -459,6 +460,14 @@ class Mt5ApiApp:
|
|||||||
result = mtapi.chart_window_find(int(pieces[0]), pieces[1])
|
result = mtapi.chart_window_find(int(pieces[0]), pieces[1])
|
||||||
print(f"> ChartWindowFind: response = {result}")
|
print(f"> ChartWindowFind: response = {result}")
|
||||||
|
|
||||||
|
def process_chart_time_price_to_xy(self, mtapi, parameters):
|
||||||
|
pieces = parameters.split(" ", 3)
|
||||||
|
if len(pieces) != 4 or not pieces[0] or not pieces[1] or not pieces[2] or not pieces[3]:
|
||||||
|
print(f"! Invalid parameters for command ChartTimePriceToXY: {parameters}")
|
||||||
|
return
|
||||||
|
result = mtapi.chart_time_price_to_xy(int(pieces[0]), int(pieces[1]), int(pieces[2]), float(pieces[3]))
|
||||||
|
print(f"> ChartTimePriceToXY: response = {result}")
|
||||||
|
|
||||||
def mtapi_command_thread(self, mtapi):
|
def mtapi_command_thread(self, mtapi):
|
||||||
while mtapi.is_connected():
|
while mtapi.is_connected():
|
||||||
filename = "client.cmd"
|
filename = "client.cmd"
|
||||||
|
|||||||
@@ -479,6 +479,14 @@ class Mt5ApiClient:
|
|||||||
cmd_params = {"ChartId": chart_id, "IndicatorShortname": indicator_short_name};
|
cmd_params = {"ChartId": chart_id, "IndicatorShortname": indicator_short_name};
|
||||||
return self.__send_command(self.__get_default_expert(), Mt5CommandType.ChartWindowFind, cmd_params)
|
return self.__send_command(self.__get_default_expert(), Mt5CommandType.ChartWindowFind, cmd_params)
|
||||||
|
|
||||||
|
# ChartTimePriceToXY
|
||||||
|
def chart_time_price_to_xy(self, chart_id, sub_window, time, price):
|
||||||
|
cmd_params = {"ChartId": chart_id, "SubWindow": sub_window, "Time": time, "Price": price}
|
||||||
|
res = self.__send_command(self.__get_default_expert(), Mt5CommandType.ChartTimePriceToXY, cmd_params)
|
||||||
|
if res is not None and res["RetVal"] == True:
|
||||||
|
return (res["Result"]["X"], res["Result"]["Y"])
|
||||||
|
return None
|
||||||
|
|
||||||
# Private methods
|
# Private methods
|
||||||
|
|
||||||
def __event_thread_func(self):
|
def __event_thread_func(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user