Skip to content
All library documents

Building a Supertrend Expert Advisor with Signal and Risk Controls

Article MQL5 articles

Summary

This article explains how to build an MQL5 Expert Advisor that trades confirmed Supertrend state changes. It waits for a completed candle to close beyond the relevant band, closes an opposing position opened by the EA, and may enter in the new direction. Configuration choices include long-only, short-only, or two-way trading; fixed or balance-based position sizing; and no stop, a recent candle extreme, or the Supertrend band as the stop reference.

The document presents a practical development workflow for connecting an EA to a custom indicator, reading its values, managing positions, and running historical tests. It frames automation as a way to execute explicit rules consistently, but the supplied material does not establish that the strategy is profitable across instruments or market regimes. Signal confirmation on completed bars can reduce intrabar instability, while stop placement, sizing, spreads, and test conditions remain important limitations to evaluate.

Key ideas

  • A bullish or bearish signal is recognized only after a completed candle closes across the relevant Supertrend band.
  • The EA closes its own opposing position before considering entry in the newly indicated direction.
  • Users can configure trade direction, stop-loss approach, and fixed or balance-based position sizing.
  • The article shows how to connect an MQL5 EA to a custom indicator and test it in the Strategy Tester.
  • The implementation workflow does not itself demonstrate robust profitability across markets or periods.

Tags

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