Discussing the article: "Machine Learning Under Constraint (Part 4): The Stop-Loss Ceiling Meets the Optimal Trading Rule Search"

Check out the new article: Machine Learning Under Constraint (Part 4): The Stop-Loss Ceiling Meets the Optimal Trading Rule Search.

The article constrains the optimal trading rule by a prop-firm stop-loss ceiling and corrects OU fitting by pooling within-trade pairs per AFML eq. 13.6. We apply the ceiling as a feasibility mask on a shared PT–SL mesh, ensuring the constrained set is a subset of the baseline. Practical guidance covers when the ceiling binds, the Sharpe cost, and how exposure and live budget state affect the bound.

Position sizing is only one part of keeping a trading strategy within a prop firm's risk limits. Even when the size of each position is properly constrained, its stop-loss distance can still expose the account to excessive losses, particularly when several positions are open simultaneously. This raises a separate question: given a daily loss limit and a maximum number of concurrent positions, how wide can any individual stop-loss be without allowing a simultaneous worst-case outcome to breach that limit?

The prop_firm_sl_ceiling function, consolidated into afml.prop_firm in Part 1, addresses precisely this question. While Part 3 completed the three modifiers in PropFirmAwareSizer.size() (budget, phase-progress, and news), all of which constrain how large a position can be, this article focuses on how wide its stop-loss is allowed to sit.

That limit becomes particularly important when optimizing trading rules. Part 15 of the companion MetaTrader 5 Machine Learning Blueprint series introduced the AFML Chapter 13 optimal trading rule (OTR) framework, which fits an Ornstein-Uhlenbeck process to a strategy's trades and searches a mesh of profit-taking and stop-loss pairs for the combination that maximizes simulated Sharpe. That article explains the framework in full, so it will not be re-derived here. Instead, we address the question it leaves open: what happens to the optimization when the stop-loss axis of the search mesh is no longer free, but subject to a hard risk ceiling?

Author: Patrick Murimi Njoroge