Skip to content
All library documents

Hot-Reloading MQL5 Strategy Settings from JSON

Article MQL5 articles

Summary

This article describes replacing per-chart input edits with a shared JSON configuration file that an MQL5 Expert Advisor can reload while running. It defines a typed configuration structure for trade volume, stop and target distances, a spread limit, a magic number, and an order comment. A default configuration provides known values if loading fails, while a diagnostic method prints the settings currently held by the EA.

The loader uses a hand-written tokenizer for a deliberately limited JSON format: one flat object with quoted keys and string or numeric values. A demo EA loads settings at startup and supports a keyboard-triggered reload; a verification script checks parsed values against a known example. This approach avoids external parser dependencies and supports a shared source of settings across instances, but it does not implement full JSON, robust schema validation, automatic file-change detection, or nested data. The article presents an implementation pattern, not evidence that configuration changes improve strategy returns. File location, malformed input, and safe fallback handling remain operational concerns.

Key ideas

  • External JSON files provide a shared configuration source that multiple EA instances can read.
  • A typed configuration structure separates strategy settings from file parsing and EA logic.
  • The sample tokenizer supports only flat objects with quoted keys and string or numeric values.
  • Defaults and per-field checks help the EA handle missing or malformed configuration data.
  • The demonstration reloads settings on a keyboard trigger rather than detecting file changes automatically.

Tags

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