Discussing the article: "Building a Prop-Firm Rule Guard in MQL5 (Part 1): The Observation Layer"

Check out the new article: Building a Prop-Firm Rule Guard in MQL5 (Part 1): The Observation Layer.

Prop-firm accounts operate under a second rulebook that MetaTrader 5 does not model. This first part builds the observation layer: a per-pass frozen account snapshot read by every rule, a verdict record that reports without acting, explicit enable flags in the profile, and a session clock aligned to the firm's reset time. The result is a reproducible pass that prevents cascading effects and prepares the ground for safe decisions in Part 2.

An Expert Advisor that trades a funded or challenge account works under two rulebooks at once. The first one is its own strategy logic. The second one belongs to the proprietary trading firm, and the EA usually knows nothing about it. Break the first rulebook and you lose a trade. Break the second one and you lose the account, usually while the terminal is doing exactly what you told it to do.

MetaTrader 5 offers nothing for that second rulebook. There is no account-level constraint object, no prop-day calendar, and no notion of a challenge that started with a fixed initial balance. The daily limit resets at an hour the broker's clock does not match. The overall floor may sit still, or it may ratchet up behind the account and then freeze there for good.

In practice, the guard is written by hand and converges on a common shape: input thresholds, an OnTick() if-block, a close-all helper, and one per-protection boolean to prevent re-firing. That shape is where the interesting part of this article lives, because it fails in specific ways that stay invisible while the account is healthy.


Author: Bruno Nunes Myrrha Ribeiro