WebSocket Sample¶
Overview¶
The WebSocket Sample plugin enables real-time data integration in cTrader through the following key functionalities:
- Connects cTrader to an external WebSocket server to receive real-time data streams.
- Displays live content such as news or trading alerts directly in Active Symbol Panel using a custom text block.
- Automatically updates the panel with new messages when received, enabling timely information.

The plugin operates through a user-configurable panel. It remains active while cTrader Windows or Mac is running and automatically releases system resources when stopped.
Plugin creation¶
Learn how to create plugins, using either C# or Python, in our step-by-step guides.
WebSocket Sample plugin code is available in our public C# and Python repositories. The same code is provided as a template in the algorithm creation wizard in cTrader Windows or Mac, or you can simply copy and use the snippet below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
Customisation options¶
The plugin combines WebSocket settings with UI elements to deliver live text content. Below is a breakdown of its key components and their functions:
| Parameter | Description | Possible values |
|---|---|---|
Text | Displays the initial content in the text block. | Starting news feed… |
AddBlock | Adds a block to Active Symbol Panel. | asp.symboltab.addblock(news) |
_textBlock.Text | Updates the text block with the received WebSocket message. | args.text |
FontSize | Sets the size of the text. | 16, 18, 20, etc. |
FontWeight | Defines the thickness of the text. | regular, bold, extrabold, etc. |
TextAlignment | Aligns the text within the text block. | left, centre, etc. |
Padding | Specifies the space around the text block. | (5, 5, 5, 5), (8, 8, 8, 8), etc. |
aspBlock.Height | Sets the height of the custom block in the user interface. | 300px, 350px, etc. |
_targetUri | Provides the WebSocket endpoint for the data feed. | wss://marketdata.tradermade.com/feedadv |
KeepAliveInterval | Defines the interval for WebSocket keep-alive pings. | (0, 1, 30) (hours, minutes, seconds) |
_webSocketClient.Send | Sends the initial subscription message to the WebSocket server. | {userkey:..., symbol:eurusd} |
UseDefaultCredentials | Configures the authentication setting for the WebSocket connection. | true or false |
Note
Ensure the WebSocket server supports the protocol and message formats expected by your implementation.
Use cases¶
WebSocket Sample provides a powerful and flexible way to extend cTrader with real-time data feeds. It supports a wide range of integrations tailored to various trading needs. Below are practical use cases that demonstrate how the plugin can enhance the trading experience.
| Use case | Scenario | Value |
|---|---|---|
| Newswire feeds | View real-time economic news, market-moving headlines and breaking events directly in the platform. | Keeps you informed of breaking news that may impact market movements. |
| Crypto exchange data | Stream live trade updates, price tickers, order book changes or alerts on volatility for crypto assets. | Enhances real-time awareness of crypto market conditions and sudden price moves. |
| Volatility and macro metrics | Display real-time volatility levels or unusual activity indicators for target instruments in Active Symbol Panel. | Supports macro-level awareness and helps identify trading opportunities during market extremes. |
| Quant model output viewer | View dynamic model output (such as momentum increase on EURUSD). | Connects quantitative analysis with trading decisions in a visually accessible way. |
| External trading signal streams | Stream automated signals from external services machine learning (ML) models routed through WebSocket. | Enables immediate signal delivery for users following algorithmic strategies or third-party bots. |
Summary¶
This plugin sample shows how to integrate real-time external content into cTrader using a WebSocket connection. While the sample demonstrates a live news feed in Active Symbol Panel, the same approach supports signals, alerts, analytics and more.
For further development details, refer to our plugin documentation.