mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-07-29 03:27:48 +00:00
PyMtApi5: implemented function ChartTimePriceToXY
This commit is contained in:
@@ -62,6 +62,7 @@ class Mt5ApiApp:
|
||||
"ChartApplyTemplate": self.process_chart_apply_template,
|
||||
"ChartSaveTemplate": self.process_chart_save_template,
|
||||
"ChartWindowFind": self.process_chart_window_find,
|
||||
"ChartTimePriceToXY": self.process_chart_time_price_to_xy,
|
||||
}
|
||||
|
||||
def on_disconnect(self, error_msg=None):
|
||||
@@ -459,6 +460,14 @@ class Mt5ApiApp:
|
||||
result = mtapi.chart_window_find(int(pieces[0]), pieces[1])
|
||||
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):
|
||||
while mtapi.is_connected():
|
||||
filename = "client.cmd"
|
||||
|
||||
@@ -479,6 +479,14 @@ class Mt5ApiClient:
|
||||
cmd_params = {"ChartId": chart_id, "IndicatorShortname": indicator_short_name};
|
||||
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
|
||||
|
||||
def __event_thread_func(self):
|
||||
|
||||
Reference in New Issue
Block a user