I’m developing a private MT5 Expert Advisor and I do not want to share the source code. I’m looking only for architectural feedback, not strategy optimization.
The EA uses a hybrid approach: SARSA/QTable plus rule-based guards, position protection with BE / trailing / StepLock / GBP profit protection, daily limits, ghost-position recovery, startup guard, diagnostic panel and CSV logging.
The main issue is that the project has grown into a large monolithic EA, and different modules can sometimes produce conflicting signals. I’m considering moving toward a central Decision Engine:
Signal → Override Candidate → Guards → Final Decision → Execution → Protection
My question: should I first create a central MakeDecision() / selectBestAction() structure before splitting the code into .mqh modules? What is the safest refactoring order for a complex EA without breaking existing trading logic?
My current idea is:
1. First create a central Decision structure that returns:
- final action: BUY / SELL / HOLD
- source of the decision
- confidence / priority
- block reason, if any
2. Then separate decision logic from execution:
- MakeDecision()
- ExecuteDecision()
3. Then move position protection into a separate Protection Manager:
- Break Even
- trailing
- StepLock
- profit protection
- close conditions
4. Only after that, split the EA into separate .mqh modules.
I’m not asking for trading strategy advice or parameter optimization. I’m only interested in safe architecture/refactoring advice for a complex production-style MT5 EA.
Any suggestions about the safest order of refactoring would be appreciated.
- Why valenok2003 is against MT5
- Accessing child function from base class
- Help needed with EA
A proposal
Here's how to read this diagram:
The Agnostic Expert Advisor (the large frame) acts as the overall container and conductor, redistributing the price feed (Market Data).
The Trend Agent is the "brain" that listens to this feed and deduces a market state.
The triggering workflow goes from the Expert Advisor to the Setup, then to the Order.
The Execution Gateway (OnTradeTransaction) is the bottleneck that validates orders with the broker's server.
The Maintenance Agent runs in parallel to manage the risk of open trades, while remaining attentive to the market state defined by the Trend Agent. A
Global Risk Module oversees everything for ultimate security.
Files:
1780137980756.png
1114 kb
It was nothing
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register