Skip to content
All library documents

Trading Runs of Identical Candles with Black-Sheep Exits

Article MQL5 code base

Summary

This expert advisor trades after a chosen number of consecutive candles share the same direction: it buys after a bullish run and sells after a bearish run. Version 6 adds configurable exits when the next candle goes against the position, an event the document calls a black sheep. The trader can close all positions, positions opposite that candle’s direction, or positions aligned with it. Optional profit targets, stop losses, trailing stops, trading hours, and account-type limits are also described.

The document supplies a daily-chart test table for several currency pairs and one equity symbol over a stated period. Results vary widely: some instruments show positive profit factors while others lose money, with reported drawdowns reaching above 60%. These are limited historical examples and do not establish robustness or future performance. The page does not detail optimization procedures, transaction costs, or out-of-sample validation, so the table should not be treated as evidence of a reliable strategy.

Key ideas

  • The system enters after a configurable run of candles in one direction.
  • It treats a first candle against the position as an exit event with three selectable position-closing behaviors.
  • Profit targets, stop losses, trailing stops, and trading-hour filters are optional controls.
  • Position caps depend on whether the account uses hedging or netting.
  • The reported tests show substantial variation across instruments and include large drawdowns.

Tags

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