Skip to content
All library documents

Supertrend and ADX Rules for ATR-Stopped Trend Trading

Article MQL5 code base

Summary

This MetaTrader 5 expert advisor combines Supertrend direction with ADX trend strength and the relative positions of +DI and −DI. It checks signals once per new signal-timeframe bar using the prior completed candle. A long or short entry requires the corresponding Supertrend direction, ADX at or above the entry threshold, and the matching directional indicator to lead. Positions exit if ADX weakens below a separate threshold, Supertrend reverses, an opposite qualifying signal appears, or the stop is hit.

The initial stop is set at a multiple of ATR from the prior candle close. Position size targets a fixed fraction of current equity, based on estimated loss from the current quote to the stop, subject to broker volume and margin checks. There is no fixed profit target. The document gives backtest snapshots from three brokers, but their returns, drawdowns, trade counts, and real-tick coverage vary; these results do not establish future performance. Gaps, slippage, and execution costs can also make realized losses exceed the risk target, and broker-specific constraints require testing.

Key ideas

  • Entries require Supertrend direction, ADX strength, and +DI/−DI agreement on a completed candle.
  • The EA checks for new signals once per bar on its selected timeframe.
  • Initial stops use an ATR multiple, while volume is calculated from a fixed equity-risk target.
  • Exits can follow weakening ADX, a Supertrend reversal, an opposing signal, or the stop loss.
  • Backtest snapshots differ across brokers, and execution conditions can make realized risk differ from the target.

Tags

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