Skip to content
All library documents

Trading Consecutive Candles with a Time Filter and Position Limits

Article MQL5 code base

Summary

This Expert Advisor looks for a run of identical-direction candlesticks and trades in the direction of those candles: bullish runs prompt buys and bearish runs prompt sells. The number of consecutive candles required is configurable. The fifth version adds a working-hours filter, letting the user set when trading may begin and end.

The listed controls include trade volume, take profit, stop loss, trailing stop and step, and limits on directional positions or total position volume. It also accounts for whether an account uses hedging or netting, with different position controls for each. The document describes the strategy and its inputs but provides no evidence of profitability, market selection, or rules for closing positions beyond the listed stop mechanisms. A run of candles alone does not establish that momentum will persist, so the entry rule requires independent testing and risk management.

Key ideas

  • The EA buys after bullish candles and sells after bearish candles according to a configurable run length.
  • A working-hours filter restricts when the EA may trade.
  • The EA provides stop loss, take profit, and optional trailing-stop controls.
  • Position limits differ between hedging and netting account types.
  • The document gives no backtest results or evidence that consecutive-candle direction persists.

Tags

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