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?

MaiaVictor
  • 45,122
  • 42
  • 127
  • 254

4 Answers4

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

Community
  • 1
  • 1
user3666197
  • 1
  • 6
  • 43
  • 77
  • @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. – user3666197 Jun 14 '14 at 09:59
  • @Viclib How is your Conversion Project going, Viclib? Anyway PF2015 – user3666197 Dec 31 '14 at 12:30
  • 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? – MaiaVictor Dec 31 '14 at 17:29
  • 1
    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) – user3666197 Jan 05 '15 at 16:40
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.

halfer
  • 18,701
  • 13
  • 79
  • 158
litepresence
  • 2,645
  • 1
  • 24
  • 30
  • 2
    **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... – user3666197 Dec 31 '14 at 12:22
  • @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. – litepresence Jun 10 '16 at 11:58
  • 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.** – user3666197 Jun 10 '16 at 13:49
  • 1
    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. – litepresence Jun 28 '16 at 13:35
  • :) Nice wallpaper on SAR Harmonica. – user3666197 Jun 28 '16 at 16:09
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.

mustaccio
  • 16,627
  • 14
  • 44
  • 49
Dmitry
  • 1,473
  • 13
  • 32
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).

battlmonstr
  • 3,898
  • 1
  • 18
  • 29