Skip to content
All library documents

Training an XGBoost Trading Classifier and Testing Its Returns in Python

Article MQL5 articles

Summary

This article continues a machine learning trading project by choosing binary classification and training an XGBoost model on engineered features. It describes separating labels from numeric inputs, fitting the classifier, and evaluating predictions on a later data split. The author reports accuracy of about 53% for labels defined by whether price reaches a take profit before touching a stop, and argues that this can still be useful given the target and stop relationship.

The article also presents a Python tester that turns predicted long or short signals into simulated trades, subtracts a markup intended to represent spread and commissions, and tracks cumulative balance. Swap costs are omitted, and the simulation closes trades at a fixed future bar rather than modeling all execution details. The author says alternative, simpler features led to account losses, emphasizing feature quality alongside model choice. The reported results are the author's own test outcomes; the excerpt does not establish robustness across markets or unseen regimes.

Key ideas

  • Binary classification is chosen because the project’s labels encode whether a take-profit condition is reached before a stop.
  • The article selects XGBoost and trains it on engineered numeric features.
  • The reported classifier accuracy is about 53% for the article’s specific profitable-label definition.
  • A custom tester maps predictions to long and short trades and subtracts a markup from outcomes.
  • The tester omits swaps and simplifies trade exits, so its profitability estimates have execution limits.

Tags

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