import MetaTrader5 as mt5
# MetaTrader 5パッケージについてのデータを表示する
print("MetaTrader5 package author: ",mt5.__author__)
print("MetaTrader5 package version: ",mt5.__version__)
# MetaTrader 5ターミナルとの接続を確立する
if not mt5.initialize():
print("initialize() failed, error code =",mt5.last_error())
quit()
# ポジションの存在を確認する
positions_total=mt5.positions_total()
if positions_total>0:
print("Total positions=",positions_total)
else:
print("Positions not found")
# MetaTrader 5ターミナルへの接続をシャットダウンする
mt5.shutdown()
|