This article shows how to build a native Cassandra CQL v4 client in MQL5 over a raw socket, without a REST or gRPC proxy. It details CQL frame encoding, correct handling of prepared-statement ids as short bytes, and a lot-sizing error found in the Strategy Tester, with targeted guards. You get a reusable client class, an EA that batches closed-trade inserts, and a script that reads rows back and cross-checks them with terminal history.
Say an EA is already trading and it's time to get its trade log out of local files and into a proper database. The usual move is a REST or gRPC gateway sitting in front of Cassandra, but that's another process to keep alive next to the terminal, configured and patched on its own. This article takes the more direct route instead: CQL v4 straight over an MQL5 socket - SocketConnect/SocketSend/SocketRead - no driver, no proxy service, no third-party DLL. It's the same approach the rest of this series has used for other wire protocols; earlier entries covered SFTP and a WebSocket bridge the same way.
The target here is specific and checkable: queue every closed deal - matched by symbol and magic number - into a Cassandra table in small batches, then read that table back through a separate connection and confirm its row count lines up with what the terminal's own deal history shows for the same filter. Three pieces get built toward that. First, CassandraStream_EA.mq5, a Donchian-breakout EA with ATR stops that does the writing. Second, CCassandraClient inside CassandraCore.mqh, the reusable client class any other EA or script can include on its own. Third, CassandraQuery_Dashboard.mq5, the script that does the reading back and the reconciling. It's a working integration example, not a durable trade log: the EA keeps trading if Cassandra never comes up, but the pending queue lives only in memory and isn't replayed later - more on that in Limitations.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Check out the new article: Native Apache Cassandra Client in MQL5: Writing Trade and Market Data via the CQL Binary Protocol.
Say an EA is already trading and it's time to get its trade log out of local files and into a proper database. The usual move is a REST or gRPC gateway sitting in front of Cassandra, but that's another process to keep alive next to the terminal, configured and patched on its own. This article takes the more direct route instead: CQL v4 straight over an MQL5 socket - SocketConnect/SocketSend/SocketRead - no driver, no proxy service, no third-party DLL. It's the same approach the rest of this series has used for other wire protocols; earlier entries covered SFTP and a WebSocket bridge the same way.
The target here is specific and checkable: queue every closed deal - matched by symbol and magic number - into a Cassandra table in small batches, then read that table back through a separate connection and confirm its row count lines up with what the terminal's own deal history shows for the same filter. Three pieces get built toward that. First, CassandraStream_EA.mq5, a Donchian-breakout EA with ATR stops that does the writing. Second, CCassandraClient inside CassandraCore.mqh, the reusable client class any other EA or script can include on its own. Third, CassandraQuery_Dashboard.mq5, the script that does the reading back and the reconciling. It's a working integration example, not a durable trade log: the EA keeps trading if Cassandra never comes up, but the pending queue lives only in memory and isn't replayed later - more on that in Limitations.
Author: Adewumi Babatunde Gbadebo