Untitled
unknown
plain_text
a year ago
3.9 kB
6
Indexable
import MetaTrader5 as mt5 if not mt5.initialize(path='C:\\Program Files\\MT$2\\terminal64.exe' , login=5022032434, server="MetaQuotes-Demo", password="1yYvTg-g"): print("initialize() failed, error code =", mt5.last_error()) quit() else: print("done1") # prepare the buy request structure symbol = "USDJPY" symbol_info = mt5.symbol_info(symbol) if symbol_info is None: print(symbol, "not found, can not call order_check()") mt5.shutdown() quit() # if the symbol is unavailable in MarketWatch, add it if not symbol_info.visible: print(symbol, "is not visible, trying to switch on") if not mt5.symbol_select(symbol, True): print("symbol_select({}}) failed, exit", symbol) mt5.shutdown() quit() lot = 0.1 point = mt5.symbol_info(symbol).point price = mt5.symbol_info_tick(symbol).ask deviation = 20 request = { "action": mt5.TRADE_ACTION_DEAL, "symbol": symbol, "volume": lot, "type": mt5.ORDER_TYPE_BUY, "price": price, "sl": price - 100 * point, "tp": price + 100 * point, "deviation": deviation, "magic": 234000, "comment": "python script open", "type_time": mt5.ORDER_TIME_GTC, "type_filling": mt5.ORDER_FILLING_RETURN, } # send a trading request result = mt5.order_send(request) print(result) if not mt5.initialize(path='C:\\Program Files\\MT$2\\terminal64.exe' , login=9999727861, server="MetaQuotes-Demo", password="N*U8MjCk"): print("initialize() failed, error code =", mt5.last_error()) quit() else: print("done1") # prepare the buy request structure symbol = "USDJPY" symbol_info = mt5.symbol_info(symbol) if symbol_info is None: print(symbol, "not found, can not call order_check()") mt5.shutdown() quit() # if the symbol is unavailable in MarketWatch, add it if not symbol_info.visible: print(symbol, "is not visible, trying to switch on") if not mt5.symbol_select(symbol, True): print("symbol_select({}}) failed, exit", symbol) mt5.shutdown() quit() lot = 0.1 point = mt5.symbol_info(symbol).point price = mt5.symbol_info_tick(symbol).ask deviation = 20 request = { "action": mt5.TRADE_ACTION_DEAL, "symbol": symbol, "volume": lot, "type": mt5.ORDER_TYPE_BUY, "price": price, "sl": price - 100 * point, "tp": price + 100 * point, "deviation": deviation, "magic": 234000, "comment": "python script open", "type_time": mt5.ORDER_TIME_GTC, "type_filling": mt5.ORDER_FILLING_RETURN, } # send a trading request result = mt5.order_send(request) print(result) if not mt5.initialize(path="C:\\Program Files\\MetaTrader 5 IC Markets (SC)\\terminal64.exe" , login=51273340, server="IC Markets GlobalSC-Demo", password="bvtM5Kk4"): print("initialize() failed, error code =", mt5.last_error()) quit() else: print("done1") # prepare the buy request structure symbol = "USDJPY" symbol_info = mt5.symbol_info(symbol) if symbol_info is None: print(symbol, "not found, can not call order_check()") mt5.shutdown() quit() # if the symbol is unavailable in MarketWatch, add it if not symbol_info.visible: print(symbol, "is not visible, trying to switch on") if not mt5.symbol_select(symbol, True): print("symbol_select({}}) failed, exit", symbol) mt5.shutdown() quit() lot = 0.1 point = mt5.symbol_info(symbol).point price = mt5.symbol_info_tick(symbol).ask deviation = 20 request = { "action": mt5.TRADE_ACTION_DEAL, "symbol": symbol, "volume": lot, "type": mt5.ORDER_TYPE_BUY, "price": price, "sl": price - 100 * point, "tp": price + 100 * point, "deviation": deviation, "magic": 234000, "comment": "python script open", "type_time": mt5.ORDER_TIME_GTC, "type_filling": mt5.ORDER_FILLING_RETURN, } # send a trading request result = mt5.order_send(request) print(result)
Editor is loading...
Leave a Comment