Skip to content
All library documents

Calibrating Triple-Barrier Labels with Broker Transaction Costs

Article MQL5 articles

Summary

The article describes a two-stage workflow for measuring costs and using them to set more realistic triple-barrier labeling thresholds. An MQL5 script gathers broker-specific spread history, hourly spread averages, swap settings, and symbol details into a CSV. A Python model converts the inputs to fractional-return costs and provides estimates for labeling and per-trade P&L calculations.

It distinguishes spread, slippage, commission, and swap, explaining that historical spread data can be sampled, while slippage and actual commission require execution records or a reference trade. It also accounts for swap mode and the weekday triple-swap charge. The suggested workflow favors a conservative spread percentile or session-specific spread over a simple mean, and recommends using consistent cost estimates for both labels and P&L.

The method is a calibration framework, not evidence that any strategy is profitable. Historical spread samples may not represent future conditions, and slippage and commission remain user-supplied estimates unless supported by execution data. The article recommends refreshing measurements periodically and after broker or account changes.

Key ideas

  • Broker spread history can be summarized by percentiles and trading hour to support strategy-specific cost estimates.
  • Slippage and actual commission require execution records or a separately calibrated reference trade.
  • Swap costs depend on instrument settings, position direction, holding time, and possible triple-swap days.
  • Expressing the cost components as fractional returns allows them to be combined in a common model.
  • Use consistent cost assumptions in both triple-barrier labeling and trade P&L calculations.

Tags

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