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

 
Maxim Dmitrievsky:

and if, hypothetically, you take ONNX support, the imported models will be slower than the MQL itself?

You check it out for yourself.

But don't forget that the real wrapper over ONNX will definitely be in C++ as a library/module for python, and then the driver/libraries of the specific video card (if it is suitable).

Python is just a corridor between calls to efficient libraries, which have to be exchanged with it in the form of fairly expensive data sets.

People don't understand enough that Python is really just a wrapper over library calls and nothing more. They think that python is a powerful and modern language. But in reality it is a bindings between C++ libraries ;)

And each library has monstrous costs to ensure compatibility with python's dynamic structures(even in numpy).

 
Renat Fatkhullin:

You check it out for yourself.

But don't forget that the real wrapper over ONNX will definitely be in C++ in the form of a library/module for python, and then the driver/libraries of the specific video card (if it is suitable).

Python is just a corridor between calls to efficient libraries, which have to be exchanged with it in the form of fairly expensive data sets.

People don't understand enough that Python is really just a wrapper over library calls and nothing more. They think that python is a powerful and modern language. But in reality it is a bindings between C++ libraries ;)

And each library has a monstrous cost to ensure compatibility with python's dynamic structures(even in numpy).

I'll check it out... haven't looked into the details yet

It's clear that python is mostly for research.

But to pull code of some already trained neural network afterwards (and they change every time during research), it's already unreal to transfer something somewhere :)

Maybe I don't fully understand what you wanted to do. Anyway, you have enough possibilities with python api. Unless you can't get it into the marketplace.

 
Renat Fatkhullin:

Nein. Es ist naiv zu glauben, dass wir Selbstmord begehen und eine Sprache wählen werden, die hunderte Male langsamer ist alsere, um den Tester loszuwerden.

Für uns ist es viel rentabler, unsere Idee zu entwickeln, C ++ - Bibliotheken von Drittanbietern in MQL5-Module neu zu kompilieren. Zu diesem Zweck haben wir begonnen, einen externen LLVM-Compiler in den Editor aufzunehmen.

I don't know if my question was translated correctly. The question is slightly different.

Does the Python module receive commands for the strategy tester? Eventually or definitely not?
 

I'll throw in my five kopecks too ))))

I took up Python precisely because it's much easier (it seems to me) to work with networks. There are a lot of developments in it. You just take it and apply it. And you can't get rid of neural networks. In my opinion, MQL just needs libraries to work with this entity...

 
Almaz:

Give me an example of your Python code that slows down, it's not clear from the words what it does and how you get the data. And why does it constantly write to the file? Can't it be done at the end?

I've changed the Python code a bit: I've increased tick request from one day to 30, organized writing into file not line by line, but in blocks of 500 lines. Running time decreased by a couple of seconds. The indicator is about nothing.

I redesigned my indicator. I added buffers and wrote data into the file line by line. Request of ticks remains the same - one day.

I have put the indicator on the chart.

2020.11.29 17:58:07.306 newCandles_F_1.01 (GBPUSD,H2)   00:01:01

The indicator has rendered and written all data to file in a minute.

Python - 3 hours

MQL - 1 minute

 

Greetings all.

Can you tell me why.

I read a csv file into a dataframe. Then I stack a few lines into one and write to a new csv file

....
csv_framе = pd.read_csv(flname, delimiter=',')
#  тут меняю имя файла
if os.path.isfile(flname):
    os.remove(flname)

rows, cols = csv_framе.shape
for i in range(candles_in_train, rows):
    lst = list()
    for k in range(candles_in_train):
        m = i - candles_in_train + k
        l = list(csv_framе.iloc[m])
        if m < i - 1:
            del l[-1]
        lst += l
    mf.write_csv_data(flname, 'a', lst)

This code works for 17 seconds.

But if I put it all at once in a new csv frame and then dump it into a file, then code runtime increases to 1 min. 44 sec.

...
new_frame = pd.DataFrame()

rows, cols = csv_framе.shape
for i in range(candles_in_train, rows):
    lst = list()
    for k in range(candles_in_train):
        m = i - candles_in_train + k
        l = list(csv_fraim.iloc[m])
        if m < i - 1:
            del l[-1]
        lst += l
    #mf.write_csv_data(flname, 'a', lst)
    r, c = new_frame.shape
    if r == 0:
        new_frame = pd.DataFrame([lst])
    else:
        new_frame.loc[r] = lst
new_frame.to_csv(flname, header=None, index=False)

Why so?

 

encoding problem? (Google translator)


 

There is a table (pandas DataFrame). How to create a new column by condition: if column "1" < column "2" then write 145 otherwise write 874?


add:

Anyway solved by

import numpy as np
... np.where(
 
Good afternoon, can Python be used in MT5 to reach WinApi ?

Specifically I want to know if it will work?

keybd_event(VK_CONTROL,0,0,0);
 

How do I make an offset?

This is the table (Data Frame)

      time  
2020-11-25
2020-11-26
2020-11-27
2020-11-30 
2020-12-01        

How to make it like this:

      time             time_1
2020-11-25	   2020-11-26
2020-11-26         2020-11-27
2020-11-27         2020-11-30
2020-11-30         2020-12-01 
2020-12-01         ничего не писать 
Reason: