Asynchronous web requests for MetaTrader [closed]
Asked Answered
F

1

7

I am trying to see whether it is feasible to build a custom indicator for MetaTrader that can make asynchronous internet requests, in order to post data to a server with a PHP interface.

These requests might take some time for the webserver to process, so I am worried that they will block the indicator from continuously updating new tick data if they are performed in a synchronous manner.

Are there any asynchronous libraries available for MT4?

Fortuity answered 22/11, 2014 at 14:24 Comment(0)
F
12

Yes, there are

MT4 can directly use ready-made bindings for great platform-to-platform & process-to-process messaging library, be it ZeroMQ or nanomsg.

Having used the former for several years, MQL4 processes can form a non-synchronised ( i.e. independently of a aMarketEVENT arrival a.k.a. quote, or less exact called also a "tick" ) ExpertAdvisor->script or script->script inter-process communication solutions, that allow to build a powerful augmented GUI services for professional trading and many other features for soft real-time systems & low intensity HFT clustering.

On the other hand, one may equip MT4 EA with a few indispensable services with this same messaging technology platform:

  1. add an interactive remote-keyboard for a CLI alike interface to the running EA
  2. add a remote ( non-blocking (!!) ) file-IO for the HFT services
  3. add a remote / centralised syslog service for the ( non-blocking ) logging
  4. add a remote / clusterised GPU-based AI/ML real-time models for advanced trading

Nota bene

From the design/architecture point of view, an MT4 indicator thread has certain limitations one shall be aware of.

An otherwise common POST-based publication to a php-process on a remote WebServer will definitely take much more than a few tens of milliseconds, that are causing an un-avoidable issue for the above asked formal achitecture.

jasuk.neumannova@gmail.com?Subject=StackOverflow-HFT-27078423(MQL4)

One shall rather minimise all MT4.CustomIndicator-embedded part of the processing, so as to avoid the processing to slip behind the next aMarketEVENT arrival, thus to prevent a skew in synchronicity of calculated values.

This can be achieved by dispatching all the non-core functionalities "outside" of the scope of the MT4.CustomIndicator code ( using ZeroMQ process-to-process communication framework ) and solve all the rest of the logic in a different thread, outside of the MT4. The postprocessing is the least of the issue, the handshaking and values' update & retransmit logic are the focal point of the off-loading from the very fragile thread-synchronicity of the MT4 ( one may have observed this issue to become more and more dangerous in recent Builds. Many robust augmented GUI solutions start to suffer from choppy responsiveness in Builds post 7xx and required slight adaptation of their core real-time control loops to regain their UI-robustness and their smooth UI-responsivness under heavy loads )

Do not hesitate to ask for more details on this MQL4 or HFT or other subjects.

Firearm answered 30/11, 2014 at 17:2 Comment(2)
Looks very interesting. So at a high level perspective what components would I be looking at to build a lets say a Mt4 component which will send out Tick data from a MT4 terminal ? I am assuming I will need the 1) Download ZeroMq library 2) Create Mt4 Script that uses the ZeroMq 3) A Server maybe php 0MQ server component to receive the connection 4) Connect the client to the server and start sending the data ? Sorry for noob question just trying to understand at a highlevel the complete picture of what is needed. Thanks !Fortuity
1) is a bit tricky ( a-ToDo-List is a bit longer ) 2) is principally correct, a design with a strictly non-blocking mode of messaging may allow for an indicator to bear the responsibility on MT4 side and another "fast-proxy" for fast mediation between MT4-sender-thread (be it the Script/ a lightweight Custom Indicator) and the remote-end post-processing 3) is principally free to decide, the key issue is to avoid blocking on the "fragile-RT" MT4-side. Leave me a note if interested in going further to some hands-on project assignment to make it work in your project/environment, ok?Firearm

© 2022 - 2024 — McMap. All rights reserved.