mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-07-28 19:17:48 +00:00
PyMtApi5: implemented function ChartXYToTimePrice
This commit is contained in:
@@ -63,6 +63,7 @@ class Mt5ApiApp:
|
||||
"ChartSaveTemplate": self.process_chart_save_template,
|
||||
"ChartWindowFind": self.process_chart_window_find,
|
||||
"ChartTimePriceToXY": self.process_chart_time_price_to_xy,
|
||||
"ChartXYToTimePrice": self.process_chart_xy_to_time_price,
|
||||
}
|
||||
|
||||
def on_disconnect(self, error_msg=None):
|
||||
@@ -468,6 +469,14 @@ class Mt5ApiApp:
|
||||
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 process_chart_xy_to_time_price(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 ChartXYToTimePrice: {parameters}")
|
||||
return
|
||||
result = mtapi.chart_xy_to_time_price(int(pieces[0]), int(pieces[1]), int(pieces[2]))
|
||||
print(f"> ChartXYToTimePrice: response = {result}")
|
||||
|
||||
def mtapi_command_thread(self, mtapi):
|
||||
while mtapi.is_connected():
|
||||
filename = "client.cmd"
|
||||
|
||||
@@ -476,7 +476,7 @@ class Mt5ApiClient:
|
||||
|
||||
# ChartWindowFind
|
||||
def chart_window_find(self, chart_id, indicator_short_name: str):
|
||||
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)
|
||||
|
||||
# ChartTimePriceToXY
|
||||
@@ -487,6 +487,14 @@ class Mt5ApiClient:
|
||||
return (res["Result"]["X"], res["Result"]["Y"])
|
||||
return None
|
||||
|
||||
# ChartXYToTimePrice
|
||||
def chart_xy_to_time_price(self, chart_id, x, y):
|
||||
cmd_params = {"ChartId": chart_id, "X": x, "Y": y}
|
||||
res = self.__send_command(self.__get_default_expert(), Mt5CommandType.ChartXYToTimePrice, cmd_params)
|
||||
if res is not None and res["RetVal"] == True:
|
||||
return (res["Result"]["SubWindow"], res["Result"]["Time"], res["Result"]["Price"])
|
||||
return None
|
||||
|
||||
# Private methods
|
||||
|
||||
def __event_thread_func(self):
|
||||
|
||||
Reference in New Issue
Block a user