To use chat, please login.
Back to contacts

MT4 API

Mar 31, 2014 at 14:27
2,261 Views
3 Replies
Member Since Oct 28, 2009   1423 posts
Mar 31, 2014 at 14:27
Hi Folks,
I'm looking to start using an MT4 API. Does anyone have experiences, good or bad with any of the API solutions out there? Ideally I'd like it to work with pre and post version 600.
Best regards Steve
11:15, restate my assumptions: 1. Mathematics is the language of nature. 2. Everything around us can be represented and understood through numbers. 3. If you graph these numbers, patterns emerge. Therefore: There are patterns everywhere in nature.
Member Since Mar 28, 2011   86 posts
Mar 31, 2014 at 19:13
I have used https://www.mt4api.net/ (https://www.tradingapi.net/mt4-net-api) and it is quite good. Internally it uses WCF and the developer answered promptly to all of my questions. Works at least pre build 600.
I run one robot in a headless VPS server and booted it once a month to be on the safe side.
Did not use it for history testing because pre 600 MT4 is so slow.

On hindsight I might choose https://www.nj4x.com/ now. It is not targeted specifically for algo trading but I think could do that and it is cheaper. Might take more time on planning how to setup properly? Build 600 status unknown to me.

I think that the next time I will roll out my own API and replace MT4API with it.
Did a prototype for MT5 using VB and Java server side using plain sockets and it is relatively easy.
Now as MT4 has same data types as MT5 it is possible to write socket or pipe based protocol that is optimized for your specific needs without writing a C/C++ DLL.
The problem with MT4API or NJ4X is that they implement MT4 API 1:1 that is not efficient for algo trading if you need heavy optimizations for speed. If your robot trades just few times an hour or day MT4API or NJ4X can do it.
Being Bearish or Bullish Makes No Difference
Member Since Oct 28, 2009   1423 posts
Apr 01, 2014 at 08:32
Thanks Petays,
I emailed MT4API.net a few days ago and haven't had a response yet - maybe he's on holiday.

If I'm understanding you correctly you are saying that the two API's on the market can only process single threaded commands rather than multi threaded? Is that what 1:1 means?

Best regards Steve
11:15, restate my assumptions: 1. Mathematics is the language of nature. 2. Everything around us can be represented and understood through numbers. 3. If you graph these numbers, patterns emerge. Therefore: There are patterns everywhere in nature.
Member Since Mar 28, 2011   86 posts
Apr 01, 2014 at 09:13
1:1 API means that almost all MT4 MQL4 functions are implemented in MT4API product using same method names and parameters.
See https://tradingapi.net/mt4-api-doc/ MT4 Class -> MT4 Methods then you get the idea!

Threading is a different story because everything is driven by MT4 Terminal event loop, that is inside OnTick() method.
But the concept is similar as in pure MQL4 EAs that are using classical 'Hollywood principle'.

MT4 Terminal -> OnTick() -> MT4API -> your C# code here can call back any MT4API method only inside OnTick

If you need multi-threading then you have to internally queue your commands and dispatch them inside OnTick, nowhere else.
Being Bearish or Bullish Makes No Difference
Sign In / Sign Up to comment
You must be connected to Myfxbook in order to leave a comment
*Commercial use and spam will not be tolerated, and may result in account termination.
Tip: Posting an image/youtube url will automatically embed it in your post!
Tip: Type the @ sign to auto complete a username participating in this discussion.