Compiler Fixes
Fix the MQL5 'trade' undeclared identifier error before rewriting the EA.
When MetaEditor says 'trade' is undeclared, the issue is usually structural: the standard trade include is missing, the CTrade object was never created, or the object name changed between functions. Fix that foundation first, then recompile before touching the strategy logic.
Search intent
The developer sees 'trade' - undeclared identifier, CTrade errors, or missing trade.Buy and trade.Sell calls in MetaEditor.
Cluster
Compiler Fixes
Tool path
mql5 compiler fixer
Reader
mq5 developer
Add the standard trade include and object
Most MT5 EAs need the standard trade header plus one CTrade instance in visible scope before calling trade.Buy, trade.Sell, or PositionClose workflows.
Check the exact object name
Some EAs declare CTrade as tradeObj, trader, or m_trade, then later call trade.Buy. The compiler is correct if the names do not match.
Recompile and inspect the next blocker
After the object exists, the next errors usually move into retcodes, stop validation, or position filters. Treat those as separate fixes instead of changing everything at once.
Use the tool
Paste the failing trade block into Workfusion Compiler Fixer to repair the include, object setup, and next compile step.
Related guides
Continue the EA build path.
Compiler Fixes
MQL5 CTrade include and trade object setup
Set up the MQL5 CTrade object correctly so Buy, Sell, PositionClose, and result checks compile cleanly.
Compiler Fixes
Fix undeclared identifier in an MQL5 EA
A practical checklist for fixing undeclared identifier errors in MT5 Expert Advisor code before compiling again.
Code Review
MQL5 logging and diagnostics for EAs
Add useful MQL5 logs that explain EA decisions without flooding the MetaTrader journal.
Optional guide follow-up
Open the free desk first. Opt in only if this guide matches your EA build or compiler blocker.
Choose the workflow you want, then opt in only if you want Workfusionapp updates.