Can I use languages other than MQL4 on MetaTrader4?
Asked Answered
A

4

8

I have a task of migrating a C# market strategy to MetaTrader.

  1. Is there any way to automate that job? (For example, is it possible to parse C# into it's AST, then make the translation?)

  2. Does MetaTrader accept other languages by any means?

Acquirement answered 24/5, 2013 at 9:53 Comment(0)
A
7

Approach the task Bottom-Up -- Architecture-wise

Yes, you can simplify the trouble and make MT4 become a Node, which is immediately connected peer-to-peer to your current C# Market Strategy.

This alowed me to operate a cluster-based computing communicating massively parallel with a crowd of MT4 nodes.

MT4 can become anEventFEED-er Node via a more complex "Scaleable Formal Cummunication Framework" in a very intelligent manner.

Do you wish to have a CLI-interface to command your MT4 node(s) -- one as anEventFEED-er, another as anXtoACTOR Node -- selectively, with a syntax & grammar of CLI-instructions ( not speaking about test-automation et al ...)?

Do you wish to have a central <syslog> daemon to off-load HFT-traffic loaded MT4 node(s) and automate + administer scripted monitoring & maintenance tasks?

Do you wish to have an external GPU-computing engine/cluster to communicate in a Client/Server manner with MT4 EA on a per-tickEvent basis?

ZeroMQ and/or nanomsg frameworks will allow you to design and develop many-to-many ( node-network-wise ) & any-to-any ( implementation language-wise ) systems.

MT4/MQL4 has a direct smart wrapper for ZeroMQ >>> thanks to Austen Conrad on GitHub MQL4ZMQ

ZeroMQ >>> thanks to it's great team has many language bindings - C/C++, Python, Java, R, even Erlang, ...

So your Project may jump start on rock solid grounds & independent of any particular architecture gridlocks ( DLL moving sands et al )

Engineering built-ins save you a lot of time and efforts and avoid re-inventing wheel

Ardennes answered 13/6, 2014 at 0:33 Comment(4)
@Viclib There are many traps on the MT4 side on the way to "move a C# market strategy" to this domain. Cross-compilation is not that simple if going to produce a professional-grade service. Tried to get in touch with you, Viclib, to offer further help on this effort, but Error: ENOENT, stat '/home/vh/Viclib/index.html' appeared.Ardennes
@Viclib How is your Conversion Project going, Viclib? Anyway PF2015Ardennes
PF2015! I didn't engage this job for lack of C# knowledge :( - I shifted my focus to functional programming instead. Thanks for asking, how are you?Acquirement
Thanks, I am fine. Good luck in Fun-programming, Vic. Still more ideas than available time to review & implement each one. Keep hacking, Vic! In case you spot a similarly interesting FX/Quant job/Project flying around you, do let me know :o)Ardennes
M
3

How about GET/POST requests and a web based text API service?

You could use your C# strategy to update a web based text file with a ternary signal:

-1 SELL
 0 HOLD
 1 BUY

Then use MQL4 to read the text file once a minute for a trade signal.

As far as technically how to do this; unfortunately I'm a python programmer not MQL4 or C#, so I can't help.

Masonite answered 30/12, 2014 at 23:4 Comment(5)
FYI: a file-based, web-server operated, GET/POST accessed on a one-minute sampling basis is hard to imagine in a world, where milliseconds are "ages" and microseconds matter and nanoseconds are fought to be shaved-off where possible...Ardennes
@user3666197, in my experience most quantitative traders are not HFT traders... which beyond the hype is a really specialized field. This technique would be more than adequate for trading hourly candles, which constitute most retail transactions.Masonite
sure, nanoseconds matter in large-scale computational models, which need not be just for HFT-sharks. Still H1-candles have increased transaction flow int the last few tens of seconds, if you wish, where the final Close-price gets cross-fired between bearish and bullish motivated forces and even H1-based strategy has a fair reason to have minimum TimeDOMAIN "blind-spot" dead-locked in an uncontrollable transaction latency. If something may take a few miliseconds, why to spend hundreds of these or even a few seconds fot the same answer? The FOREX river never waits for someone.Ardennes
I see where you are coming from. Most strategies I dev depend upon "all in" "all out" about once weekly based on H1 and H12 indications. Nanoseconds really don't matter all that much from this perspective; I only check price once a minute. I agree that if your trade frequency is more in line with scalping noise than slaying dragons this technique would fail.Masonite
:) Nice wallpaper on SAR Harmonica.Ardennes
S
1

short answer is no, however, there is a faculty in mql to import dlls. so you could wrap your c# lib with a c++/cli lib that exposes functionally via function exports, you could even run a timer in mql and implement a rudimentary message pump.

Update: MT4 can only access standard calls of unmanaged DLLs. the reason you have to use a c++ wrapper is that c++ DOES have the capability to create unmanaged standard calls. any other language that you can create standard calls with can also work.

Furthermore you need a wrapper just in case you want to use other languages which does not support standard calls. You may just write your entire code in c++ and the whole wrapper concept will be obsolete.

Speciosity answered 25/5, 2013 at 16:14 Comment(0)
H
1

Yes, it's possible to use C# by using some 3rd party solutions like NQuotes http://www.nquotes.net/ , which is essentially a ready-made DLL for a general usage (like Dmitry said, you can create your own, but it involves a bit of work).

Howell answered 27/12, 2013 at 20:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.