MetaTrader 5 Python User Group - how to use Python in Metatrader - page 63

 
MetaQuotes:

Will be available next beta version tonight:

https://www.mql5.com/en/forum/306742/page16#comment_16148685

MetaTrader 5 Python User Group - the summary
MetaTrader 5 Python User Group - the summary
  • 2020.04.24
  • www.mql5.com
The Main Study MetaTrader module for integration with Python - documentation Python Releases for Windows - website MetaTrader5 : Python Package...
 
Новая версия платформы MetaTrader 5 build 2360: Расширение интеграции с SQLite
Новая версия платформы MetaTrader 5 build 2360: Расширение интеграции с SQLite
  • 2020.05.03
  • www.mql5.com
В пятницу 6 марта 2020 года будет выпущена обновленная версия платформы MetaTrader 5...
 
https://www.mql5.com/ru/docs/integration/python_metatrader5
I tried to run the start script - everything runs, prints an array of data on the trading pairs from the example, starts the window on which it draws the chart
But I tried to replace "EURAUD" with "DAX30", for example - after I ran the script, it says Failed to select DAX30
Please advise what may be the problem? Terminal version 2402

I do connection with the login and the password and a server to the demo account of the broker through mt5.initialize
Документация по MQL5: Интеграция / MetaTrader для Python
Документация по MQL5: Интеграция / MetaTrader для Python
  • www.mql5.com
Python является современным высокоуровневым языком программирования для разработки сценариев и приложений. Содержит множество библиотек для машинного обучения, автоматизации процессов, анализа и визуализации данных. Пакет MetaTrader для Python предназначен для...
 
Lol Kek:
https://www.mql5.com/ru/docs/integration/python_metatrader5
I tried to run the start script - everything runs, prints an array of data on the trading pairs from the example, runs a window on which it draws the chart
But I tried to replace "EURAUD" with "DAX30", for example - after I ran the script, it says Failed to select DAX30
Please advise what may be the problem? Terminal version 2402

I connect with login password and server to my broker's demo account via mt5.initialize
Check what is returned in mt5.last_error() after call of function working with DAX30
 

# let's try to enable display of DAX30 symbol in MarketWatch
selected = mt5.symbol_select("DAX30", True)
if not selected:
print("initialize() failed, error code = ", mt5 .last_error())
mt5 .shutdown()
quit()


this is the error (-1, 'Terminal: Call failed')
 
Lol Kek:

# let's try to enable the DAX30 symbol in MarketWatch
selected = mt5.symbol_select("DAX30", True)
if not selected:
print("initialize() failed, error code = ", mt5 .last_error())
mt5 .shutdown()
quit()


This is the error (-1, 'Terminal: Call failed')

Are you sure you have the DAX30 symbol in your trading account?

Show a screenshot of market overview with this symbol on your trading account, please.

 
Renat Fatkhullin:

Are you sure you have the DAX30 symbol in your trading account?

Show a screenshot of the market overview with this symbol on your trading account, please.

***
I take this code -https://www.mql5.com/ru/docs/integration/python_metatrader5/mt5copyratesrange_py, I initialize it by connecting it to my demo account. If I run it with USDJPY from the example - everything is OK, it displays a table. If I change it to DAX30


For rates in rates:
TypeError: 'NoneType' object is not iterable

 
Lol Kek:

https://prnt.sc/sbapam
I take this code and initialize it by connecting it to my demo account. If I run it with USDJPY from the example - everything is OK, it displays a table. If I change it to DAX30

For rates in rates:
TypeError: 'NoneType' object is not iterable

Lol Kek:

# let's try to enable the display of DAX30 symbol in MarketWatch
selected = mt5.symbol_select("DAX30", True)
if not selected:
print("initialize() failed, error code = ", mt5 .last_error())
mt5 .shutdown()
quit()


error like this (-1, 'Terminal: Call failed')
You have Dax30 in square brackets. That's the right error you're getting.
 
Dmitriy Skub:
You have Dax30 in square brackets. The error you are being given is correct.

Ugh, never paid attention to that, thanks
And thanks to the developers for the opportunity to transfer the logic to a 3rd party language, specifically Python.
I will try to provide feedback here as logic is being analyzed and implemented.

 

Hi All,


I hope you don't mind an English man here. Looking for some guidance after spending lots of time searching the web without success.

I am using the MetaTrader5 Python library after some inspiration from Maxiums articles. I have noticed a problem with memory handling.

When I make a Dataframe using mt5 lib the resultant dataframe works as expected. I have done this within a function that collects the ticks and then performs various analysis before outputting the manipulated df.

However, if I rerun the function that creates the DataFrame I have noticed that the memory is just keeping accumulating from the previous instance.

I get the same problem using mt5.copy_ticks_range () and mt5.copy_rates_range (). I have to reset the kernel in order to clear out the memory.

I get the same problem even after removing all code except the line creating the dataframe. For instance:

def vel (symbol, lookback, lookforward, start_date, end_date, quantile_size):

ticks = pd.DataFrame (mt5.copy_ticks_range (symbol, datetime (start_date.year, start_date.month, start_date.day), datetime (end_date.year, end_date.month, end_date.day), mt5.COPY_TICKS_ALL), columns = [ 'time', 'bid', 'ask', 'last', 'volume', 'time_msc', 'flags', 'volume_real'])

If I run this several times the memory usage goes up 27MiB each time:

Line # Mem usage Increment Line Contents ================================================== 126.3 MiB 126.3 MiB def vel (symbol, lookback, lookforward, start_date, end_date, quantile_size): 153.3 MiB 26.9 MiB ticks = pd.DataFrame (mt5.copy_ticks_range (symbol, datetime (start_date.year, start_date.month, start_date.day), .


Line # Mem usage Increment Line Contents

================================================== 140.9 MiB 140.9 MiB def vel (symbol, lookback, lookforward, start_date, end_date, quantile_size): 166.5 MiB 25.7 MiB ticks = pd.DataFrame (mt5.copy_ticks_range (symbol, datetime (start_date.year, start_date.month, start_date.day), ...
Reason: