Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Facing Same problem for code below :
import MetaTrader5 as mt5 import pandas as pd pd.set_option('display.max_columns', 500) # number of columns to be displayed pd.set_option('display.width', 1500) # max table width to display # display data on the MetaTrader 5 package print("MetaTrader5 package author: ",mt5.__author__) print("MetaTrader5 package version: ",mt5.__version__) print() # establish connection to the MetaTrader 5 terminal if not mt5.initialize(): print("initialize() failed, error code =",mt5.last_error()) quit() # display data on active orders on EURUSD orders=mt5.orders_get() print(orders) if orders is None: print("No orders on EURUSD, error code={}".format(mt5.last_error())) else: print("Total orders on EURUSD:",len(orders)) # display all active orders for order in orders: print(order) print() # Retrieve orders EUR_orders = mt5.orders_get(group="*EUR*") if EUR_orders is None: print("No orders on EURUSD, error code={}".format(mt5.last_error())) else: print("Total orders on EURUSD:", len(EUR_orders)) # Check if there are any orders before creating a DataFrame if len(EUR_orders) > 0: df = pd.DataFrame([order._asdict() for order in EUR_orders]) print(df) else: print("No orders found on EURUSD.") # Shut down connection to the MetaTrader 5 terminal mt5.shutdown()

Fixed it with the below code:
import MetaTrader5 as mt5 import pandas as pd pd.set_option('display.max_columns', 500) # number of columns to be displayed pd.set_option('display.width', 1500) # max table width to display # display data on the MetaTrader 5 package print("MetaTrader5 package author: ",mt5.__author__) print("MetaTrader5 package version: ",mt5.__version__) print() # establish connection to the MetaTrader 5 terminal if not mt5.initialize(): print("initialize() failed, error code =",mt5.last_error()) quit() # get open positions on EURUSD positions=mt5.positions_get(symbol="EURUSD") if positions==None: print("No positions on EURUSD, error code={}".format(mt5.last_error())) elif len(positions)>0: print("Total positions on EURUSD =",len(positions)) # display all open positions for position in positions: print(position) # get the list of positions on symbols whose names contain "*EUR*" usd_positions=mt5.positions_get(group="*EUR*") if usd_positions==None: print("No positions with group=\"*EUR*\", error code={}".format(mt5.last_error())) elif len(usd_positions)>0: print("positions_get(group=\"*EUR*\")={}".format(len(usd_positions))) # display these positions as a table using pandas.DataFrame df=pd.DataFrame(list(usd_positions),columns=usd_positions[0]._asdict().keys()) df['time'] = pd.to_datetime(df['time'], unit='s') df.drop(['time_update', 'time_msc', 'time_update_msc', 'external_id'], axis=1, inplace=True) print(df) # shut down connection to the MetaTrader 5 terminal mt5.shutdown()


You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
account_info is work
output No open orders found