from MetaTrader5 import * 
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
import matplotlib.pyplot as plt

MT5Initialize() # connect to MT5
MT5WaitForTerminal() # wait till MT5 ready 

### get candle data
eurusd_candle = MT5CopyRatesFromPos("EURUSD", MT5_TIMEFRAME_D1,0,100)

MT5Shutdown()   # shut down connection to MT5

### DATA print as is 
for val in eurusd_candle: 
    print(val)


### DATA format change 
eurusd_candle_dataframe = pd.DataFrame(list(eurusd_candle), 
                                       columns=['time', 'open', 'low', 'high', 'close', 'tick_volume', 'spread', 'real_volume'])

### DATA print data frame 
print(eurusd_candle_dataframe)


### DATA plot

plt.plot(eurusd_candle_dataframe['close'])
plt.title('EURUSD')
plt.show()