Python mt4 dde

Hey all I’m in the middle of learning Python and am trying to tie it in with my trading efforts. I know that its possible to receive data through a DDE client into a Python script but I’m having an issue getting the connection made. Is anyone here familiar with Python development? Here’s the code I got so far.

import win32ui
import dde

#create a DDE client and start conversation
s = dde.CreateServer()

#create a conversation between client and server
c = dde.CreateConversation(s)

#Connect to MT4
c.ConnectTo(“Server Name”,“Item”)
#tests if connection is successful
if c.Connected() == 1:
print (“Connection established”)
print (“Yipee”)

Im figuring this out through google research and what basics I know about Python. Im having trouble finding the right format for the DDE Server name and Item to download. I have seen similar code on many python sites and Think this is the core of what is needed. If any one can help please do. The DDE instructions are different from excel to Python by the way.
Thanks
Matt

Hi Matt,

I am trying to do the same kind of thing with a DDE export of ProRealTime.

I didn’t notice in the first place, but you have to create your server instance before to try to connect to it.
You should add something like
s.Create(“MyMT4connection”)
I dont’ know if the name has an impact, but I don’t think so.

On my side, it seems that the connection is successful, by adding this line.
But each time I am trying to request some data:
c.Request(“Opening”)
I am getting a “dde.error: Request failed"
I have seen in some other place, people using utf-8 to give the name
c.Request(u"Opening”)
But it doesn’t change anything.

Did you fix your own problem? How did you do?
Is your connection with MT4 sucessful?

Thanks

Zyx