Skip to content
All library documents

Moving Average Trend EA with Direction and Position Controls

Article MQL5 code base

Summary

This page describes an Expert Advisor that uses a moving average as a reference for opening trades. With its default signal rules, it opens a buy when the current ask is above the moving average value from the prior bar, or a sell when the current bid is below that value. Users can restrict trading to buys, sells, or both, and can choose to reverse signals.

Additional controls limit the strategy to one open position or close an opposing position when a new signal arrives. The page illustrates how the closing rule works when a sell signal follows an existing buy. These settings describe basic execution and position handling, but the source provides no backtest, transaction-cost analysis, market selection, or parameter study. The rules alone do not establish profitability, and the excerpt does not discuss risk sizing or exit logic beyond closing opposing positions.

Key ideas

  • The EA compares current bid or ask prices with the moving average value from the prior bar.
  • Users can restrict the EA to buy signals, sell signals, or both directions.
  • Signal reversal, one-position limits, and closing opposing positions are configurable.
  • The page provides no evidence about profitability, costs, or risk-adjusted performance.

Tags

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