MQL5 Portable Issue

 

I Have Run Python Code On 2 Different Terminals

1st code

path=r'C:\Program Files\MT1\terminal64.exe', portable=True,

2nd code

path=r'C:\Program Files\MT2\terminal64.exe',
portable=True,

Both Terminals are connected with different brokers

Now When I Start Getting Prices of a coin ( XAUUSD ) From 1st Code

Its Working Perfectly

But As soon as a start the code 2 to get the price of the same coin from different brokers
It Prints 
1740
1741
0
0
1742

The Issue is Its Printing 0 In between As Soon As I Start The 2nd Code
I Mean I am Not Able To Run Both code Simultaneously

Please Guide


 
MLM4MLM:I Have Run Python Code On 2 Different Terminal. 1st code. path=r'C:\Program Files\MT1\terminal64.exe', portable=True, 2nd code...

On Windows, normally the " C:\Program Files" directory is protected against writing to it without administrator privileges.

So unless you are running under the administrator role, or have allowed the folders MT1 or MT2 to have user write permissions, you will not be able to run MetaTrader in portable mode on those directories.

Normally, portable mode is used for other root directories and not for standard installation on "Program Files" which usually store data in user's profile path.

 
Fernando Carreiro #:

On Windows, normally the " C:\Program Files" directory is protected against writing to it without administrator privileges.

So unless you are running under the administrator role, or have allowed the folders MT1 or MT2 to have user write permissions, you will not be able to run MetaTrader in portable mode on those directories.

Normally, portable mode is used for other root directories and not for standard installation on "Program Files" which usually store data in user's profile path.

I Have Already Given The Rights

And Both Terminals Work Good If Run Separetely

Problem comes When I Connect To Both Terminals At The Same Time

Output Of Terminal 1 Before Starting Terminal 2

1753.527

1753.589

1753.527

1753.589

1753.527

1753.589

1753.527

1753.589

1753.527

Output Of Terminal 1 After Starting Terminal 2

1753.39

1753.216

1753.278

'NoneType' object has no attribute '_asdict'

0.0

'NoneType' object has no attribute '_asdict'

0.0

'NoneType' object has no attribute '_asdict'

0.0

1753.39

1753.13

1753.39

1753.13

1753.39

1753.13

1753.38

 
MLM4MLM #: I Have Already Given The Right. And Both Terminals Work Good If Run Separetely. Problem comes When I Connect To Both Terminals At The Same Time.

I personally don't use python, but do remember other posts about users also having difficulties about accessing two terminals at the same time via the python api.

Run a search on the forum, to find those threads and see if they had a solution.

 
Fernando Carreiro #:

I personally don't use python, but do remember other posts about users also having difficulties about accessing two terminals at the same time via the python api.

Run a search on the forum, to find those threads and see if they had a solution.

i already searched and then came here for a solution

 
MLM4MLM #:

i already searched and then came here for a solution

Do they have to run in the same Windows account? Could you create 2 Windows users and run them in parallel on the same host?

 
R4tna C #:

Do they have to run in the same Windows account? Could you create 2 Windows users and run them in parallel on the same host?

already tried

 
MLM4MLM #:

already tried

It could be they are transmitting on the same ports and conflicting - that could occur even when using separate Windows accounts.

Some software offers the ability to allow multiple instances to run on the same host by providing the option to customize separate port ranges for each instance, or separate IP addresses, or both - you would have to explore whether MQL5 can do this.

One way you could test this is to create 2 separate windows accounts and use VPN's software to isolate their protocol stacks - it may work if the 2nd instance can use an isolated IP stack.

Alternatively you could try and create 2 separate IP address and see if you can customize the instances to use different ones

 
R4tna C #:

It could be they are transmitting the the same ports and conflicting - that could occur even when using separate Windows accounts.

Some software offers the ability to allow multiple instances to run on the same host by providing the option to customize separate port ranges for each instance, or separate IP addresses, or both - you would have to explore whether MQL5 can do this.

One way you could test this is to create 2 separate windows accounts and use VPN's software to isolate their protocol stacks - it may work if the 2nd instance can use an isolated IP stack.

Alternatively you could try and create 2 separate IP address and see if you can customize the instances to use different ones

I did now notice in your message:

'NoneType' object has no attribute '_asdict'

Shared memory conflict?

Again I have worked with software which allows allocation of different memory regions, but as MT may not offer this, you could try a separate virtual machine if they must run on the same host 

 
I disagree with the possibility to have 2 or more processes share a network port. This is not possible on Linus/Unix or windows.

Either, they bind to different IPs and use the same port, or they do not bind to an IP and the port is blocked by the first process to allocate the port.

Shared memory is allocated and has access handles. It be a very bad programming error in MT side.

My pr esonal guess would be as follows. The python process tries to find the MT process on the host, and uses the executable name to do so.

To rule this out, you could try to rename the exe of the portable version and see if you still get these errors.

Reason for this is, python needs to connect somehow to the terminal, not knowing where to find it without addressing it somehow.


 
My theory is supported by the documentation.

The function "Initialize" takes in the path of the corresponding MT5 terminal as a parameter.


Giving the path to the correct exe should resolve the issue.