Discussing the article: "MetaTrader 5 Machine Learning Blueprint (Part 15): How to Calibrate Profit-Taking and Stop-Loss Targets from Synthetic Data"

 

Check out the new article: MetaTrader 5 Machine Learning Blueprint (Part 15): How to Calibrate Profit-Taking and Stop-Loss Targets from Synthetic Data.

This article applies the Optimal Trading Rule from AFML Chapter 13 to set profit targets and stop-losses without in-sample calibration. We model post-entry P&L with a discrete Ornstein–Uhlenbeck process, run a 100,000-path search, and implement Python, multiprocessing, and a Numba @njit parallel kernel (242× faster). The result is an optimal (PT, SL) under three forecast specifications, constrained by the prop-firm daily loss limit.

This is the second article in a two-part series. The preceding article built a transaction cost model that derives a cost-calibrated per-trade P&L series and a labeling threshold (min_ret) from measured broker costs. If you have not read that article, read it first — the P&L series this article operates on should come from that pipeline, not from a hardcoded spread constant. The quality of the O‑U parameter estimates, and therefore the quality of the PT and SL derived here, depends directly on the accuracy of the cost deduction applied to each trade outcome. The E[P&L] and average winning trade values that become the Case B and Case C forecasts are only as reliable as the spread, slippage, and commission deductions behind them.

One distinction is worth establishing before going further. The min_ret threshold from the preceding article is a labeling parameter: it determines which historical trade outcomes are treated as genuine signal versus execution friction when constructing a training set. The optimal PT derived in this article is an execution parameter: it tells the EA where to place its profit order. The two are related — the execution PT should exceed min_ret, or you are deploying a rule that would have been labeled zero in the training data — but they are derived by different procedures and should not be confused with each other. This article handles the execution side; the preceding one handles the labeling side.

MetaTrader 5 Machine Learning Blueprint (Part 15): How to Calibrate Profit-Taking and Stop-Loss Targets from Synthetic Data

Author: Patrick Murimi Njoroge