We implement an MQL5 program that validates consolidations by counting edge switches, height capped to the typical candle, and net drift, then requires a buffered close beyond an edge and a move away before arming. Entry follows a return to the broken edge and a strong close back on the breakout side. The stop anchors beyond the retest extreme; the target is an R-multiple, and failed attempts can rearm the same range after a fresh breakout and retest.
A breakout is only one piece of evidence: a single close beyond a line we drew. So we take it. Often, price closes back inside the range on the next bar, and we get stopped out for a loss, one the chart warned us about in hindsight. Two failures sit underneath that. First, the range itself may be invalid. A window can drift while oscillating and still look like a consolidation, but its edges are meaningless because no one defended them. Second, timing is poor. The close that clears the edge is the least proven and most extended moment of the move, and we lack a mechanism to wait for confirmation. When the first attempt does fail on a setup that was sound, we have usually deleted the level and moved on, so the second chance passes us by.
This article is for MetaQuotes Language 5 (MQL5) developers and traders who want the range proved before the break, and the break proved before the entry. Success means every trade the program takes has passed three checks first, a valid range, a confirmed break and a rejected retest, and that a backtest shows how the full system performs on real history.
In our previous article (Part 53), we built a double top and double bottom reversal model. In this article, we validate a consolidation before trading it. We count edge-to-edge crossings, cap the height by the symbol's typical candle size, and reject windows with excessive net drift. Only then do we look for a close that clears an edge by a buffer and moves away from the zone. Instead of entering immediately, we wait for price to return to the broken edge and reject it. By the end of this article, we will be able to:
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Check out the new article: Automating Trading Strategies in MQL5 (Part 54): Consolidation Breakout and Retest Entry Model.
A breakout is only one piece of evidence: a single close beyond a line we drew. So we take it. Often, price closes back inside the range on the next bar, and we get stopped out for a loss, one the chart warned us about in hindsight. Two failures sit underneath that. First, the range itself may be invalid. A window can drift while oscillating and still look like a consolidation, but its edges are meaningless because no one defended them. Second, timing is poor. The close that clears the edge is the least proven and most extended moment of the move, and we lack a mechanism to wait for confirmation. When the first attempt does fail on a setup that was sound, we have usually deleted the level and moved on, so the second chance passes us by.
This article is for MetaQuotes Language 5 (MQL5) developers and traders who want the range proved before the break, and the break proved before the entry. Success means every trade the program takes has passed three checks first, a valid range, a confirmed break and a rejected retest, and that a backtest shows how the full system performs on real history.
In our previous article (Part 53), we built a double top and double bottom reversal model. In this article, we validate a consolidation before trading it. We count edge-to-edge crossings, cap the height by the symbol's typical candle size, and reject windows with excessive net drift. Only then do we look for a close that clears an edge by a buffer and moves away from the zone. Instead of entering immediately, we wait for price to return to the broken edge and reject it. By the end of this article, we will be able to:
Author: Allan Munene Mutiiria