How to establish a WebSocket connection with MT5 server for real-time symbol pricing?

361 views Asked by At

I am exploring the potential of creating a real-time data streaming application that involves integration with the MT5 server. The application aims to fetch real-time symbol pricing and trade profit data. Currently, I have managed to connect to the MT5 server through a traditional Web API provided by MetaQuotes. However, this doesn't provide real-time data fetching capabilities that are critical to my project. I've also tried using some pre-existing codes (https://www.mql5.com/en/code/169) to establish connection for single instruments, but they lack the feature of real-time trade profit fetching and tracking multiple instruments simultaneously. Also there are stick to one instruments and show the result in the journal of mt5 server.

I am currently facing challenges in establishing a WebSocket connection with the MT5 server to receive real-time symbol pricing and trade profit data. Although I've managed to successfully connect to the MT5 server through a Web API provided by MetaQuotes, I want this to be a WebSocket connection to get the real-time data stream.

This code (https://www.mql5.com/en/code/169), which works well for a single instrument, has been a starting point for me. However, it lacks the capability of multiple instrument tracking and real-time trade profit fetching, which is crucial for the application I'm building.

Additionally, I've attempted to establish a connection with a simple NodeJS application, but it has been producing an error message as follows: { errno: -4077, code: 'ECONNRESET', syscall: 'read' } Error image of nodeJs connection as my IP is whitelisted on the mt5 server

Also out there are expert advisors but I don't want to use them what should be the alternative please help me.

1

There are 1 answers

1
Umair Ahmad On

I have done it by using the Python MetaTrader5 package to get real-time data from the server. You can install it using this command: "pip install MetaTrader5" You can also use any expert advisor that resides in your client terminal and acts as a server that will send you the symbol's pricing data for this. It will be done by meta quotes.