Skip to content
All library documents

Automating the Darvas Box Breakout and Pyramiding System

Article MQL5 articles

Summary

The article translates the Darvas box method into an MQL5 Expert Advisor. It defines a box from a price extreme that holds for three sessions, then requires a breakout above the box boundary with increased volume. The implementation adds filters for low volume during consolidation, minimum box height relative to ATR, and a lookback extreme. It also mirrors the rules for short trades using bear boxes.

A state machine handles box formation, confirmation, breakout monitoring, and trade management. After an initial entry, each higher box breakout can add another position unit; all units share a stop at the newest box floor, which moves upward as the staircase advances. The EA closes the campaign if that stop is breached or if a new box fails to form within a configured interval. The article reports compiling and testing the EA in MetaTrader 5, but offers no performance statistics. Results will depend on the chosen inputs, market, and timeframe; the recommended daily timeframe and currency pairs are suggestions rather than evidence of profitability.

Key ideas

  • A box is confirmed when an extreme remains unbroken for three consecutive sessions.
  • Breakouts require volume above the box-period average, while box formation is filtered for contracting volume.
  • The EA can pyramid by adding a unit on each subsequent box breakout.
  • All open units share a stop at the latest box floor, which advances with higher boxes.
  • A state machine lets the EA monitor open positions and search for the next box at the same time.

Tags

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