Overview
cTrader is a professional trading platform used by a significant number of retail and institutional forex and CFD brokers as an alternative to MetaTrader. Where MetaTrader dominates the retail forex market through sheer broker count, cTrader has established a strong position among brokers that prioritise transparent execution, direct market access, and the advanced charting and algorithmic trading infrastructure that professional traders require. cTrader's open platform architecture — the Open API for external connectivity and cAlgo for native algorithmic development — makes it a more accessible integration target than MetaTrader for external systems that need programmatic access to trading functionality.
The cTrader Open API is a protocol buffer-based API that provides external applications with full access to cTrader account data, trading operations, historical market data, and real-time price streams. Unlike MetaTrader's DLL-based external integration which requires Windows hosting and COM interoperability, the cTrader Open API is a modern gRPC-style API accessible from any language and platform that supports protocol buffers and TCP socket communication. This makes cTrader integration more accessible for server-side applications built in Rust, Python, C#, or other languages without MetaTrader's platform constraints.
cAlgo is cTrader's native algorithmic development environment — the C# programming environment within cTrader for building cBots (automated trading programs equivalent to MetaTrader's Expert Advisors) and custom indicators. cAlgo provides direct access to cTrader's internal data and execution infrastructure through a type-safe C# API, making it the most capable development environment for algorithms that run within the cTrader platform itself.
We build cTrader integrations for forex traders, systematic trading firms, signal providers, and technology companies that need to connect external systems to cTrader's execution and data infrastructure — covering both the Open API for external application connectivity and cAlgo for native platform algorithm development.
What cTrader Integration Covers
cTrader Open API authentication. The cTrader Open API uses an OAuth 2.0-based authentication flow that issues access tokens authorising specific scopes of access.
Application registration: cTrader Open API applications are registered at connect.ctrader.com, producing a client ID and client secret. The application registration specifies the scopes the application requires — trading for order placement and account management, accounts for account data access. The redirect URI for the OAuth callback.
OAuth authorisation flow: the authorisation code flow that the user follows to grant the application access to their cTrader account. The authorisation URL with the client ID, redirect URI, scope, and response type parameters. The authorisation code received at the redirect URI, exchanged for access token and refresh token using the token endpoint.
Access token management: access tokens have a limited lifetime and must be refreshed using the refresh token before expiry. The token refresh logic that requests a new access token using the refresh token, handling token refresh failures with appropriate retry and fallback. The token storage that securely persists the refresh token across application restarts.
Application authentication: separate from the account OAuth flow, the application itself authenticates to the Open API server by sending an OAApplicationAuthReq message with the client ID and client secret immediately after establishing the TCP connection. Account-level authentication using OAAccountAuthReq with the access token for each specific trading account.
Open API connection management. The cTrader Open API uses persistent TCP connections with protocol buffer message framing — not HTTP REST or standard WebSocket.
TCP connection: the connection to the Open API endpoint (live.ctraderapi.com:5035 for live, demo.ctraderapi.com:5035 for demo). The custom message framing: each message is prefixed with a 4-byte big-endian integer indicating the message length, followed by the serialised protocol buffer payload. The message parsing loop that reads the length prefix, reads that many bytes, and deserialises the protocol buffer.
Heartbeat: the OAHeartbeatEvent message that the server sends periodically to confirm the connection is alive. The client-side heartbeat send at regular intervals to prevent the server from closing an idle connection. The reconnection logic that detects a dropped connection (heartbeat timeout, socket error) and re-establishes the TCP connection and re-authenticates.
Request-response correlation: cTrader Open API requests include a clientMsgId field that is echoed in the corresponding response. The correlation map that matches responses to their originating requests — critical for associating asynchronous responses with the code that initiated the request.
Order placement and management. The Open API trading operations for order execution.
New order: the OANewOrderReq message for placing market and limit orders. The symbolId (the cTrader symbol identifier, not a string symbol name), the orderType (MARKET, LIMIT, STOP, STOP_LIMIT), the tradeSide (BUY, SELL), the volume in units (1 lot = 100,000 units for standard forex), the limitPrice and stopPrice for conditional orders, the takeProfit and stopLoss for protective levels, and the timeInForce for limit order validity. The OAExecutionEvent response that confirms order execution with the position details and execution price.
Order cancellation: the OACancelOrderReq for cancelling pending limit or stop orders by order ID. The OAOrderCancelledEvent that confirms cancellation.
Position management: the OAClosePositionReq for closing an open position fully or partially. The OAAmendPositionSLTPReq for modifying the stop loss and take profit levels of an open position. The OAAmendOrderReq for modifying pending order parameters.
Position queries: the OAReconcileReq message that returns all open positions and pending orders for the authenticated account — the synchronisation point used after reconnection to restore accurate position state.
Account and portfolio data. Retrieving account-level financial data from the Open API.
Account information: the OATraderReq message that returns account details — the balance, the equity, the unrealised PnL on open positions, the margin used, the free margin, the margin level, the account currency, and the account leverage.
Transaction history: the OAGetTransactionsByIdReq and OAGetTickDataReq for historical transaction and tick data. The deal history for performance tracking — the historical trades with entry and exit prices, volumes, and PnL.
Asset classes and symbols: the OASymbolsListReq message that returns all symbols available on the account with their IDs. The OASymbolByIdReq for detailed symbol specifications — the tick size, the pip value, the minimum volume, the maximum volume, the contract size, and the commission structure. The symbol specifications that order sizing calculations require.
Real-time price streaming. Subscribing to live price feeds through the Open API.
Price subscription: the OASubscribeSpotsReq message that subscribes to real-time bid and ask price updates for specified symbol IDs. The OASpotEvent messages that the server pushes for each price update — the symbol ID, the bid price, the ask price, and the timestamp. Unsubscription with OAUnsubscribeSpotsReq when price data is no longer required.
Depth of market: the OASubscribeDepthQuotesReq message for subscribing to order book depth data for ECN accounts that have access to market depth information. The OADepthEvent messages with bid and ask depth levels.
Historical market data. The Open API provides access to historical tick and bar data.
Tick data: the OAGetTickDataReq message for historical tick data for a symbol within a time range. The response containing bid and ask tick records with timestamps. The tick data for backtesting and indicator initialisation.
Trend bars: the OAGetTrendBarsReq message for historical OHLCV bar data. The period parameter specifying the bar timeframe — M1, M5, M15, M30, H1, H4, D1, W1, MN1. The bar data for strategy backtesting and indicator calculation.
cAlgo cBot development. Native C# algorithmic trading within the cTrader platform using cAlgo's API.
cBot structure: the C# class inheriting from Robot that overrides OnStart(), OnTick(), OnStop(), and other event handlers. The entry point for the automated strategy — OnStart() for initialisation, OnTick() or OnBar() for signal evaluation on each price update or bar close, OnStop() for cleanup.
Order execution in cAlgo: the ExecuteMarketOrder(), PlaceLimitOrder(), PlaceStopOrder() methods for order placement. The Position.Close() and Position.ModifyStopLossPrice() methods for position management. The Trade event callbacks that fire when orders are executed, positions are opened, and positions are closed.
cAlgo indicators: the Indicators.SimpleMovingAverage(), Indicators.RelativeStrengthIndex(), and the other built-in technical indicators accessible through the cAlgo API. Custom indicator development with the Indicator base class and the IndicatorDataSeries output buffers that render on the chart.
Risk management in cAlgo: the Account.Balance, Account.Equity, and Account.FreeMargin properties for account state. The Symbol.PipValue and Symbol.TickValue properties for position sizing calculations. The lot size calculation that risks a defined percentage of account equity on each trade.
Parameter inputs: the [Parameter] attribute that exposes cBot and indicator parameters to the cTrader UI — the configurable values that traders adjust through the parameter dialog without modifying code. Parameter validation and default values.
Signal provider integration with cTrader. cTrader's signal provider functionality for copy trading.
Signal subscription: accounts following signal providers receive trade copies from the provider's account. The position sizing rules that determine how each subscriber's positions are sized relative to the signal provider's positions.
Custom signal distribution via Open API: the external signal system that places trades in follower accounts via the Open API in response to signals from a master account. The trade copier architecture that monitors the master account's positions through the Open API and replicates trades in follower accounts.
Open API vs cAlgo — Choosing the Right Integration Approach
Open API is appropriate when the trading logic or signal generation runs outside the cTrader platform — a Python strategy engine, a Rust execution system, an external signal provider — that needs to place orders and read account data through an external connection. The Open API requires TCP socket management, protocol buffer serialisation, and OAuth token handling, but is accessible from any platform and language.
cAlgo is appropriate when the strategy runs within the cTrader platform — the automated cBot that runs in cTrader's native execution environment. cAlgo provides the most direct access to cTrader's internal data (indicators, price history, account state) and requires no external connection management. The C# development environment within cTrader, with the platform's built-in backtesting and optimisation infrastructure.
Hybrid approaches: a cAlgo cBot that bridges between the cTrader platform and an external system — receiving signals from an external source via file polling or socket connection and executing orders through cAlgo's native order placement API. The approach that keeps signal generation in a preferred external environment while using cAlgo for the execution layer.
FIX API Integration
Institutional cTrader brokers may offer FIX API access — the industry-standard Financial Information eXchange protocol for programmatic trading.
FIX session management: the FIX session establishment (Logon), the heartbeat management (Heartbeat), and the session termination (Logout) messages. The FIX session configuration — the SenderCompID, the TargetCompID, the heartbeat interval, and the connection credentials provided by the broker.
FIX order placement: the NewOrderSingle (D) message for order placement. The ExecutionReport (8) message for order status updates and fill confirmations. The OrderCancelRequest (F) for order cancellation.
FIX market data: the MarketDataRequest (V) for subscribing to price quotes. The MarketDataSnapshotFullRefresh (W) and MarketDataIncrementalRefresh (X) messages for snapshot and incremental price updates.
Technologies Used
- C# — cAlgo cBot and indicator development; Open API integration leveraging the .NET ecosystem and the official cTrader Open API SDK
- Rust — high-performance Open API client for low-latency execution and real-time price processing
- Python — Open API integration for strategy prototyping, signal generation, and portfolio analysis
- Protocol Buffers — cTrader Open API message serialisation and deserialisation
- TCP sockets — cTrader Open API transport layer
- OAuth 2.0 — cTrader Open API authentication
- QuickFIX / QuickFIXn — FIX protocol implementation for institutional broker FIX API access
- SQL (PostgreSQL / MySQL) — trade history, position records, performance data
- Redis — access token storage, order state, connection management
- Docker — containerised Open API client deployment
- GitHub Actions — CI/CD pipeline for deployment
cTrader in the Broader Trading Architecture
cTrader's Open API accessibility — TCP-based with protocol buffers, accessible from any language — makes it a more flexible external integration target than MetaTrader's DLL-based approach. The trading firm that runs its strategy logic in Rust or Python and connects to cTrader brokers for execution through the Open API does not need a Windows environment or COM interoperability — the TCP socket connection works from any hosting environment.
For traders who operate across both MetaTrader and cTrader brokers, the execution layer of the trading system needs connectors for both platforms. The normalisation layer above the connectors translates between the broker-specific APIs and the internal order model, allowing the strategy to be broker-agnostic while the connectors handle platform-specific execution details.
Professional cTrader Integration
cTrader Open API and cAlgo integrations built to production standards — correct protocol buffer message handling, robust TCP connection management with reconnection and state recovery, accurate OAuth token lifecycle management, complete position and order tracking, and the monitoring that surfaces connectivity issues before they affect trading operations.