Skip to content
All library documents

Moving-Average Price Signals with Position and Reversal Controls

Article MQL5 code base

Summary

This Expert Advisor uses a moving average to generate directional trading signals. When the current ask is above the moving-average value from the prior bar, it signals a buy; when the current bid is below that value, it signals a sell. The description explains three controls: limiting the system to one open position, reversing the signals, and closing an opposite position when a new signal arrives.

An example walks through an existing buy being closed before a sell is opened when opposite-position closing is enabled. This clarifies the order of operations but does not establish whether the strategy is profitable. The document gives no details about the moving-average period, instrument, timeframe, stop or exit rules, transaction costs, or backtest results. Its description is therefore useful for understanding the signal and position-management mechanics, but not for evaluating performance or risk.

Key ideas

  • A buy signal occurs when the current ask is above the moving average on the prior bar.
  • A sell signal occurs when the current bid is below that moving-average value.
  • The advisor can restrict trading to one open position and can reverse its signals.
  • With opposite-position closing enabled, it closes the existing position before opening the new one.
  • The description provides no backtest or full risk-management specification.

Tags

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