Skip to content
All library documents

Monitoring and Recording Bid-Ask Spread Statistics in an Expert Advisor

Article MQL5 code base

Summary

This page describes an expert advisor that measures the current spread, displays spread statistics on a chart, and prints collected statistics to the trading journal when it stops. The journal output can be used with a strategy tester to inspect historical spread information for a selected testing period. This makes the tool relevant to execution analysis and to understanding transaction costs in simulated trading.

Users can set a maximum spread in points; exceeding that level triggers an alert. A separate minimum interval setting limits how frequently alerts can recur, and setting the maximum spread to zero disables that alert function. The version notes say the interval setting and current-spread display were added in later releases. The page explains the tool’s behavior but provides no measured spreads, performance tests, supported instruments, or guidance on how to incorporate spread estimates into a strategy’s fills or profitability assumptions.

Key ideas

  • The expert advisor tracks spread information and displays statistics on the chart.
  • It writes collected spread statistics to the journal when it stops, which can support strategy tester review.
  • A maximum spread threshold can trigger an alert when the current spread exceeds it.
  • A minimum alert interval controls how soon another alert can occur.
  • The page describes functionality but gives no spread measurements or evidence of trading performance.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.