Skip to content
All library documents

Tick-Based Broker Cost Profiling for Triple-Barrier Labels

Article MQL5 code base

Summary

The document describes a MetaTrader script that collects broker-specific trading costs for one symbol and exports them for a companion model used in triple-barrier labeling. It samples spreads from ticks and reports tick-weighted, dwell-time-weighted, and execution-boundary distributions, alongside symbol properties, execution constraints, swap rates, and sampling coverage. A bar-field audit can compare broker-stored minute spreads with reconstructed tick data.

For cost modeling, the document recommends the execution-conditional spread distribution and discusses using a high percentile such as the 95th percentile rather than the mean, since average spreads may understate costs around signal entries. Spread and swap inputs are converted to fractional returns by the companion Python class to set a symbol-specific minimum return threshold. The script only diagnoses commission; per-lot commission may need to be derived from a reference trade. The document also cautions that poor tick coverage weakens the reported distributions and that older CSV formats require a fresh export.

Key ideas

  • Tick-level spread sampling can better reflect the quotes a trade crosses than bar-resolution spread history.
  • The script reports separate tick-weighted, time-weighted, and execution-conditional spread distributions.
  • The execution-conditional spread percentile is recommended as an input to minimum-return calculations for triple-barrier labels.
  • Sampling coverage should be checked before relying on exported cost estimates.
  • Commission may require a separate reference-trade measurement because broker APIs do not expose it consistently.

Tags

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