Discussion of article "MetaTrader 5 and Python integration: receiving and sending data" - page 10

[Deleted]  
Maxim Dmitrievsky:
Check out the example from my last article. Here an old version of the package was used. And it needs to be installed first via pip install, of course

Thanks, Maxim. I looked at the example even before the question ))) But my experience does not allow me to notice the differences right away. But I will learn )))

 
Gentlemen, it's awkward to ask (I feel the question is stupid), but this thing - SocketCreate() knows how to Strategies Tester?
[Deleted]  
immediacy:
Gentlemen, it's awkward to ask (I feel the question is stupid), but this thing - SocketCreate() knows how to Strategies Tester?

No

 

Good afternoon! when starting socketserver I get the following error: help me please "dummy")

Traceback (most recent call last):

File "C:C:{python\Socket_client-server\Socket client-server\socketserver\socketserver.py", line 48, in <module>
serv = socketserver('127.0.0.1', 9090)
File "C:C:\python\Socket_client-server\Socket client-server\socketserver.py", line 15, in __init__
self.sock.bind((self.adress, self.port)))
AttributeError: 'socketserver' object has no attribute 'adress'
>>>
 

Hi, interesting article. Thanks for that.


Was wondering. Why did you decide to implement the server in Python and the EA as the client in MT5?


Wouldnt it be more natural to have the server as an EA in MT5 providing data and executing traders and the client(s) in python, processing the data and making the trade decisions that are sent to the server?


Is there some obvious advantage to using the client as an EA and the server in python, that I am missing?



If i remember correctly, from past experience with ZeroMQ the server was as an EA in MT5 and the client in python.

 
yogibass:

@Maxim Dmitrievsky

I just wanted to say thank you for making this available. I always wanted to be able to code my indicators in Python and since you began this thread I've been able to access realtime futures data and use it to develop and run my indicators. I use my Python to plot and analyze the live feed and I place trades through the MT5 platform - it works great. Please keep up the good work and I truly hope Python will be full embraced my the MT community.

Thank you and best regards!

Hi, I want to connect mt5 with live data using an api. Because in my country, there are no authorised broker or data vendor that support mt5. Can you pls help me. 
 
Maxim Dmitrievsky #:

Hi, sockets don't work in tester at this time. Also, you mus add localhost to allowed webrequests in mt5 settings



after i add the localhost,it still remind me the error '4014'

 

Thank you for complete description. 

i have a question:

is it possible for us to run a script of .ex5 type by a command in python environment?

i wanna run it through python, and the script save the results in an excel file, so can i use the excel data again in my website or android program.

Thanks a lot.

 
Hello Maxim.
Your article on integration of Python and mt5 encouraged me to dive deeper into the topic. I wrote a lot of things in Python using almost all functions of the library.
It came to the need to draw something on a chart in mt5, calculated in Python. Taking as a basis your code on communication via socket, I wrote the following scenario: on click in the corner of the chart mt5 sends a request for data to draw fibs and channels. In your example python returns two values, but I have to return data for up to 12 different structures with three coordinate points each.
At first I got stuck with the fact that mt5 did not return a long string describing all structures at once. I made the exchange through several shorter queries. Everything seems to work, but from time to time.
Something tells me that it's about the timeout setting. Could you please suggest a direction to find a solution?
I am grateful to you in advance
 

Hello - Can someone please help me!!!


I'm trying to execute this code in Python and keep getting an error:


Below is my code and it results in the error:


>>> # Copying data to dataframe

>>> d = pd.DataFrame()

>>> for i in sym:

... rates = mt.copy_rates_from_pos(i, mt.TIMEFRAME_M1, 0, 1000)

  File "<stdin>", line 2

    rates = mt.copy_rates_from_pos(i, mt.TIMEFRAME_M1, 0, 1000)

    ^

IndentationError: expected an indented block

>>> d[i] = [y.close for y in rates]

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

  File "<stdin>", line 1, in <listcomp>

AttributeError: 'numpy.void' object has no attribute 'close'


# sbcapitalfx Heat Map - version 1.0



import MetaTrader5 as mt

import pandas as pd

from datetime import datetime

import matplotlib.pyplot as plt



# Initializing MT5 connection 



mt.initialize()



login = ************

password = ' ************ '

server = 'MetaQuotes-Demo'



mt.login(login,password,server)



# Create currency watchlist for which correlation matrix is to be plotted

sym = ['EURUSD','USDJPY','USDCHF','USDNZD']



# Copying data to dataframe

d = pd.DataFrame()

for i in sym:

        rates = mt.copy_rates_from_pos(i, mt.TIMEFRAME_M1, 0, 1000)

        d[i] = [y.close for y in rates]