Friday, February 17, 2012

Data from MT4 to Amibroker & Orders from Amibroker to MT4

After learning all about MT4 and MQL language, I thought “MT4 is MT Shit”, too many limitations and I know AFL way better than MQL.  Besides that the Amibroker back tester is far superior to the MT4 back tester.  I’ll do my system up in Ami and send the order to MT4. 
Here are the steps to do this:
  1. Load historical data into Ami (See this post Forex MSN Data)
  2. Get streaming data from MT4 to Amibroker
  3. Find or make AFL and MQL files to interact between the two platforms.  I found an MQL file (on a forum) that will read a text file.  Now I just need to make the trading system AFL write the text file.  I’ll make this code as an AFL include file.
I just finished setting up the DDE feed from MT4 to Amibroker.  Here is how to set up the Amibroker DDE price feed.  One thing to watch out for is the fields, I got that part wrong initially.  See this screen shot and make sure it looks EXACTLY like this, notice the Ticker Price fields, which one comes first?  I wasn’t paying attention and spent a while figuring this out.
By the way, I’m using this on Windows 7 64 bit.
image
Notice the {Field}!{Ticker} – Field is first, when you open up this window for the first time, these fields are reversed.
image
Add the symbol to Amibroker, the same as it appears in MT4, some brokers add some stuff after the symbol, mine was only EURUSD for example.  So I added EURUSD to Amibroker.  Once you see the green box at the lower right side of Ami, add the symbol to the real time feed and watch the quotes come in. 
In MT4, you have to enable the “DDE Server”.  Go to “Tools->Options” and check the box.

To see errors, look at the MT4 "Journal" tab.  View->Terminal, then goto the new thingy that just opened and click the Journal tab.  You might see some errors that begin with "DDE......"

If you have any questions, use Google first, than ask me if your stuck.

image

image

10 comments:

  1. I'm looking forward to hear more about sending orders to MT4 from Ami. I already use Mt4 as FX data source and am connecting AB to MT. I don't really like MT4 so a better solution to connect to my broker would be better. But for now I must live with that and accept MT4 sending data through DDE to Ami. I've also made a backfill script since DDE doesn't provide that by nature. So it's better than nothing. But I'm working on a plugin to connect to my broker since AB provides a free development kit. But it's a project being at an early stage

    Yeah that's for now.

    Best regards

    ReplyDelete
  2. Would you be willing to share the backfill script here? I can post it and write some instructions for use.

    Can you elaborate of the plug-in your working on?

    ReplyDelete
  3. Brian, I will get back to you regarding this topic in a few days. This week I'm quite busy.

    Best regards

    ReplyDelete
  4. Hi,

    I really found this post very useful and i was trying since long to utilise it on Windows7 platform. Thanks for it. I am getting quotes for forex data but not for commodities.

    ReplyDelete
  5. Hi,

    you can use "Rateserver" for MT4 to Ami, with Backfill.
    http://www.marketcalls.in/amibroker/mt4-plugin-for-amibroker.html

    To order from Ami, use a simple textfile, that you write with ami and read with MT4.
    like: "buy;stoploss,takeprofit..."
    e.g. "buy;95;120"
    Best regards

    ReplyDelete
  6. Rateserver doesn't work on my Windows 7 64 bit machine. I would have liked to use it since it has backfill. Perhaps I'll try it again, I didn't spend to much time on it.

    I have the order part working from Amibroker to MT4, but it's basic and I haven't tested it yet. I can post what I have so far if anyone want it.

    ReplyDelete
  7. The other thing is that both Amibroker and MT4 have to be on the same timeframe.

    ReplyDelete
  8. I use Rateserver with 5min Timeframe im MT4 and Ami. In Ami only the "base time interval" has to be the same. In the ami-chart you can use then any timeframe. To order with a text-file I use a second EA in MT4.

    ReplyDelete
  9. You don't need rateserver and that plug-in for backfill of MT4 DDE connection. Just DDE plugin plus export and import script

    ReplyDelete
  10. Hello,

    Is backfill possible with this approach of using DDE? If so can you please let me know how to do it? I'm struggling to figure this out.

    Thanks

    ReplyDelete

Let's hear what you have to say!

Disclaimer

The information presented on this site is for educational and entertainment purposes only. This site contains no suggestions or instructions that you must follow, do your own research and due diligence before committing your cash to the markets. Your on your own.