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

 
Roman:

Thank you Diamond.
There are no errors.
The paths are spelled out correctly.
I deleted the exact path in mt5.initialize (), restarted the terminal and the figure began to be displayed.

You have to use a raw-string or escape all of the backslashes.

option1 = r'C:\Program Files\MetaTrader 5\terminal64.exe'
option2 = 'C:\\Program Files\\MetaTrader 5\\terminal64.exe'
 
nicholi shen:

You have to use a raw-string or escape all of the backslashes.

I also thought about shielding when Almaz wrote for the exact path. Yes it worked too. thank

 
Almaz :

You have a limit on the number of bars in charts, you need to remove this limit in the Terminal (Tools->Options->Max bars in chart).
In future builds of Terminal, we will return error (None) when trying such request.

Thanks for the tip.

MT5 is now delivering all data correctly.

 

Python 3.8

Build 2470

Package 5.0.33


Orders_get function failure

Returns not "NO" if there are no orders.

import MetaTrader5 as mt5

if not mt5.initialize():
    print( "initialize() failed, error code =" , mt5.last_error())
    quit()

orders = mt5.orders_get(symbol= "GBPUSD" )
if orders is None:
    print( "No orders on GBPUSD, error code={}" .format(mt5.last_error()))
elif len(orders) > 0 :
    print( "Total orders on GBPUSD:" , len(orders))
     for order in orders:
        print(order)

mt5.shutdown()


 
Christian:

Python 3.8

Build 2470

Package 5.0.33


Orders_get function failure

Returns not "NO" if there are no orders.


All is correct, empty set returned - sign of no orders, this is not an error, the request worked successfully, None is returned in case of an explicit error. But the fact that it also returns empty set on symbols which are not on broker's server, this is an error, corrected, will be available with next terminal update.
 
Almaz :
This is correct, empty set returned - sign of no orders, it is not error, request was processed successfully, None is returned in case of explicit error. But it also returns empty set on symbols which are not on broker's server, it is error, fixed, will be available with next terminal update.

OK, do I really understand this?


There are only two types of answers:

1. NO

2. A tuple with a length greater than 0


In the next assembly> 2470

 
Christian:

OK, do I really understand this?


There are only two types of answers:

1. NO

2. A tuple with a length greater than 0


In the next build> 2470

No.

1. None if some error raised

2. Tuple with length >=0

 
Rashid Umarov:

No.

1. None if some error raised

2. Tuple with length >=0

Ok, now i get it.

Thx

 
Дмитрий Прокопьев:

Note that mt5.terminal_info() shows:

path='C:\\Works\\\\\MT5 - terminals\\MetaTrader 5', data_path='C:\Works\\\\MT5 - terminals\\\MetaTrader 5',commondata_path='C:\Users\\\rip\AppData\\\Roaming\\MetaQuotes\\Terminal\\\Common'

are identical. Is it supposed to be like this?

The code is below:

 
Almaz:

@Almaz
The first time the copy_xxx_xxx functions are run, when the terminal has not started for some time,
functions immediately return the available result with missing history, without waiting for history swap synchronization.
It means that the first function call returns the result with missing history.
Only subsequent calls will return the correct result, when the history is swapped.
Is it possible to fix this issue? And the copy_xxx_xxx function waits for history to be swapped on the first call.