SignalR makes possible to have two side connectivity with web server to get/send (streaming) data in real-time. For example, you can get quotes, margin updates of your MT4 clients, online users list, open orders at real time as it happen in MT4. Once you get subscribed to whatever you need you would get updates, no need to ask web server about new portion of data every time.

Quick examples

Here you can get working examples. Simply open source code of any page below and get client side code which demonstrates basic while negotiating with SignalR endpoint.

This example shows data coming from server every second - current server time. No authentication needed.
- This example shows how you can get real-time date from WebAPI host server. - Be aware, you need to adjust page source code (to make it work) to whatever you have for your installation (client_id, client_secret, tradeplatform_id, etc). Get page source, adjust settings and run the page.

How to use

Add links to required libraries within your page's header:

Within page header
<script src=""></script>
<script src=""></script>
<script src=""></script>

Then create connection to SignalR endpoint:

Initialization (JavaScript )
// access token obtained after authentication should be saved here
var access_token = '';

// create connection
const connection = new signalR.HubConnectionBuilder()
            accessTokenFactory: () => {
                return access_token;
            // let's skip negotiation and start right with websockets
            transport: (signalR.HttpTransportType.WebSockets),
            skipNegotiation: true

To connect just call:

Connect (JavaScript )
await connection.start();

You need an authentication token obtained from authentication server ( Once you get a token, provide it to SignalR client through accessTokenFactory() function


There are few hubs available to work with. Test and MT4. More details about each one you can find in corresponding section.

  • No labels