Python module (A script for extracting data from Metatrader)

ali Mohammadi  

Hello All

As a new user, I'm using MQL5 module in Python!

All things are good, But a problem i have.

I couldn't find any way to go through symbols at Market watch!

The module's methods just list all instruments in the Metatrader and therefor just going through all instruments is possible! Something about 9000 instrument! So slowly!

Is there any way to just identifying active instruments in the Market Watch and going through them?

this is my code.

from datetime import datetime,date
import MetaTrader5 as mt5
import pandas as pd
import pytz

pd.set_option('display.max_columns', 500) 
pd.set_option('display.width', 1500)    

# establish connection to MetaTrader 5 terminal
if not mt5.initialize():
    print("initialize() failed, error code =",mt5.last_error())
# get all symbols

for s in symbols:
    if count>=total_count: 
        contains_digit = False

        for character in
            if character.isdigit():
                contains_digit = True

        if not contains_digit:
            ticks = mt5.copy_ticks_from( ,, 10, mt5.COPY_TICKS_ALL)
            c = 0
            for tick in ticks:
            if c >= 2:
                rates = mt5.copy_rates_from_pos(, mt5.TIMEFRAME_H1, 0, 4)
                rates_frame = pd.DataFrame(rates)
                rates_frame['time']=pd.to_datetime(rates_frame['time'], unit='s',errors='ignore')

If you can, Please help me.

Sorry for my bad english

Thanks in advanced

Stefano Fazzino  


    # symbols of Market watch
    for items in mt.symbols_get(""):
        if items.visible:
            print(, "visible")