Skip to content
All library documents

EMA and LWMA Trend Signals with Loss-Based Position Reduction

Article MQL5 code base

Summary

This Expert Advisor uses two moving averages to identify directional trades. It opens a long position when the exponential moving average is above the linear weighted moving average and both are rising; it opens a short position when the reverse relationship holds and both are falling. Positions close when the averages cross back against the trade.

Position size may be fixed or calculated in relation to free margin. An optional loss response reduces lot size after consecutive losing trades, with the minimum permitted size used when further reduction is not possible. The document describes the rules and parameters but provides no numerical performance results or independent evaluation. Moving averages can lag price changes, and the loss-based sizing rule does not establish a maximum drawdown or ensure recovery; users would need to evaluate execution, risk limits, and robustness separately.

Key ideas

  • Long and short entries require both a moving-average relationship and agreement in the averages’ direction.
  • Positions close when the two averages cross against the open trade.
  • Position size can be fixed or linked to free margin.
  • An optional factor lowers trade size after consecutive losses.

Tags

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