Skip to content
All library documents

Genetic Optimization for Selecting Trading Strategies and Parameters

Article MQL5 articles

Summary

This article describes a self-optimizing Expert Advisor that uses a genetic algorithm to choose among predefined strategies, financial instruments, deposit allocation, and indicator parameters. Candidate settings are evaluated by simulating trades on historical data. The fitness function seeks to maximize simulated balance while keeping relative drawdown under a preset limit. In live operation, the EA checks for new bars, applies the selected strategy’s entry and exit signals, and reruns optimization when balance drawdown exceeds a configured threshold.

The example includes moving-average, parabolic SAR, and stochastic strategies, with trades evaluated at bar boundaries and exits based on indicator signals rather than stop-loss or take-profit orders. The author presents a historical simulation narrative to illustrate changing selections and outcomes, but this is not evidence of robust out-of-sample performance. The optimization objective, trigger, parameter bounds, and strategy set are design choices; the article itself cautions that they can be changed and imposes limits on optimized parameters.

Key ideas

  • The genetic algorithm searches across predefined strategies, instruments, capital allocation, and indicator settings.
  • The fitness function rewards simulated balance growth subject to a relative drawdown ceiling.
  • The EA evaluates signals on new bars and can re-optimize after drawdown crosses a chosen threshold.
  • The example exits on indicator signals and omits stop-loss, take-profit, and trailing-stop rules.
  • Historical simulation examples do not demonstrate that the optimized system will generalize to future data.

Tags

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