Skip to content
All library documents

Optimizing a Two-Moving-Average and RSI Trading Expert Advisor

Article MQL5 code base

Summary

This document describes an expert advisor that combines fast and slow moving averages with RSI to generate buy and sell signals. It evaluates signals when a new bar appears, while managing open positions on each tick. The slow moving average period is set to twice the fast period, and the RSI period matches the fast period, reducing the number of parameters to optimize. Users can also change the comparison directions used in the signal rules.

The advisor supports configurable stop loss, take profit, trailing, position limits, profit-based closing, and opposite-position closing. Position size can be fixed or calculated from a risk setting. For optimization, the author recommends testing an M15 setup in the MetaTrader tester, disabling exit levels initially, limiting positions per direction, and using genetic optimization for maximum balance. The document reports a brief cloud optimization example on USDJPY data from 2017, but gives no strategy performance results. Its recommendations are setup guidance, not evidence of robust profitability; the suggested optimization can also be sensitive to the selected period and parameters.

Key ideas

  • The expert advisor combines two moving averages and RSI to generate trade signals.
  • Signals are evaluated on new bars, while position management runs on every tick.
  • The slow moving average period is twice the fast period, and RSI uses the fast period.
  • Signal comparison directions and several position-management settings can be optimized.
  • The document provides tester setup advice and a runtime example, but no performance validation.

Tags

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