I'm using the above script to get weekly data, but I'm getting an empty dataframe. In MetaTrader5 documentation there is nothing about Weekly data, someone knows how to get it?
This is the code I use to get any data from metatrader5 which always works for me. Make sure to change account number, password and pair symbole, also the server name (here i am using Exness trial account)
import numpy as np import pandas as pd import MetaTrader5 as mt5 from datetime import datetime account=12345678 #account number password = "password" pair = 'USDJPYm' #as shown in metatrader5 if not mt5.initialize(login=account, password=password,server="Exness-MT5Trial"): print("initialize() failed, error code =",mt5.last_error()) quit() # attempt to enable the display of the pair in MarketWatch selected=mt5.symbol_select(pair,True) if not selected: print("Failed to select {}".format(pair)) mt5.shutdown() quit() utc_from = datetime.now() #Todays time # get 20 data bars of 'USDJPYm' [ Weekly= W1, 4 Hours= H4, Daily= D1] starting from today's time in UTC time zone rates = mt5.copy_rates_from(pair, mt5.TIMEFRAME_W1, utc_from, 20) # create DataFrame out of the obtained data data = pd.DataFrame(rates) # convert time in seconds into the datetime format data['time']=pd.to_datetime(data['time'], unit='s') data.head()
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