Skip to content
All library documents

Real-Coded Genetic Algorithms for Flexible Optimization

Article MQL5 articles

Summary

The document explains a genetic algorithm that represents each candidate solution as a chromosome of real-valued genes. It describes a population split between parent and offspring groups, fitness-based sorting, selection, crossover, mutation, and replacement across generations. Duplicate chromosomes are removed, the best solution is retained as a reference, and the search stops after a chosen number of generations without improvement. The method is presented as a flexible alternative to exhaustive search for difficult optimization problems, including neural-network training and trading-strategy parameter tuning.

The article outlines configurable search ranges, precision, population size, and genetic-operator proportions, and recommends adjusting these to fit the objective function and problem. It also uses a ZigZag indicator example and discusses practical implementation in MetaTrader. The author reports personal experience rather than a controlled benchmark, and the method is heuristic: it may find useful solutions but does not prove that a global optimum has been reached. Results depend on the fitness function, parameter choices, and search settings.

Key ideas

  • Real-coded chromosomes store candidate parameters directly as real-valued genes.
  • Selection, crossover, and mutation create new candidates across successive generations.
  • Removing duplicates and preserving the best candidate are intended to maintain diversity and retain progress.
  • The fitness function and genetic-operator settings must be adapted to the optimization task.
  • A genetic algorithm can reduce exhaustive-search effort but does not guarantee a global optimum.

Tags

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