QuantForum

Structuring a multi-symbol EA without it becoming spaghetti

@ea_architectjoined Mar 23, 2025Jul 4, 2026624 views3 replies

I'm refactoring an EA that trades 6 symbols and the OnTick handler is becoming an if-else forest. Every symbol has slightly different state and filters and it's getting unmaintainable.

How do you structure multi-symbol logic cleanly in MQL5? Separate class per symbol? A symbol router? Event-driven? Looking for patterns from people who have done this at 10+ symbols.

3 Replies

  1. @mt5_tinkererjoined Jul 14, 2025#1 · 4 weeks ago
    0

    One strategy class per symbol instance, registered in an array. The EA loops the array on each tick or timer and calls strategy.OnTick(). All state — open positions, last signal bar, filters — lives inside the instance.

    Changed my life when I went from 2 to 12 symbols. No more symbol-specific if branches anywhere.

  2. @pips_and_pythonjoined Jun 20, 2025#2 · 4 weeks ago
    0

    Two more things that matter at 6+ symbols: do the heavy analysis in OnTimer (once a second) instead of OnTick, and create all indicator handles at init and cache them. Multi-symbol EAs that create handles on the fly leak resources and eventually freeze the tester.

  3. @ea_architectjoined Mar 23, 2025#3 · 4 weeks ago
    0

    Class-per-symbol plus a timer loop it is. Thanks both — I'll post the refactored skeleton here when it's done in case it helps the next person.

Log in or create an account to join the discussion.