Engineering discipline
Logging and observability for Expert Advisors
A bot that cannot explain its state is difficult to trust. Design logs that help you distinguish no signal from no execution.
Log decisions, not every tick
A useful log records new bars, signal evaluations, order requests, broker responses, position changes, protection events, and errors. Logging every tick usually creates noise that hides the events you need.
Include symbol, timeframe, strategy version, state, and a correlation identifier when an order moves through several steps.
Make normal inactivity visible
A bot may correctly produce no trade for hours. A heartbeat should show that the terminal is alive, the latest bar was processed, the account is connected, and the strategy is not halted by a protection rule.
- Record the last processed bar time.
- Report protection state and current exposure.
- Separate informational, warning, and error events.
- Avoid logging secrets, credentials, or unnecessary personal account data.
Turn logs into alerts
Not every log line deserves a notification. Alert on stale heartbeat, repeated order rejection, unexpected position state, connection loss, and protection halt. Keep the alert actionable so it does not become background noise.
Review a sample of logs after deployment and confirm they answer the questions you would ask during a live incident.
Discuss this article
Ask a setup question, share a backtest, or compare notes with other algorithmic traders. Use a display name; your email remains private.
Create an account or sign in above to join the conversation.
Loading discussion…