• hems posted an update in the group Group logo of Node.js + MQL4 DevelopmentNode.js + MQL4 Development 7 years, 10 months ago

    I’m trying to figure out a way to have some sort of bi-directional communication between node.js and MT4.

    First goals:
    – List open positions and orders and make them available to my node.js application
    – Be able to close positions and cancel orders from node.js
    – Fetch current balance from account

    Second goals:
    – On every new bar for a period, broadcast the last X bars to node.js
    – Be able to open orders from node.js
    – List deposits / withdrawals

    I could partially reach those goals by tweaking your example EA and continuously push data to node.js which could sync my database, but still i wouldn’t be able cancel/open/close orders/positions from node.js.

    Also using your example i could continuously query node for “pending actions” then execute the action and reply to node something like “closed order successfully”, but that seems to be a very ugly workaround.

    I suspect on an ideal world i would have a node.js server on the same machine as MT4, issue a command to that node.js instance and then somehow “natively” call functions on MT4, but i still don’t know how to achieve this communication ( node.js ~> MT4 action ), but unfortunately i’m not sure what would be the easiest way.

    Ideally i would avoid having to write DLLs or any other sort of “windows programming” on the machine, is there a way? For instance some command line access to MT4 that would execute a command and print some meaningful response?

    Any ideas, recommendations and suggestions will will be highly appreciated.

    :heart: :rose: :mail:

    • Sorry for the delay. I have actually done this and it worked out perfectly. Start small :-) If you can send data back and forth, then you can translate those into MT4 functions that run based on the data. Let me know if you get stuck and I will try to help.

      • Hi Saver0 ,
        I hope you are fine.
        I would like to have your idea on something .
        I am building my own software for copy trading with MQL4 . I already finished . My question is related to the way the communication is done. I used HTTP connection with the event OnTimer() via a webrequest to an php API. Each time ( every second) I make a webrequest to communicate with my server to see if trades are open.When you said you have done this with node js, did you work with Websocket or you just used Node Js as an API ? I am just questioning because I am afraid that the server will be overwhelmed if I have like 100 clients connected on the software in the same time.
        Do you think HTTP connection is ok for this ?

        Thank you in advance.

Scroll to Top