EA operations resources

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.

Open the free EA desk

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.

Include <Trade/Trade.mqh>
Declare one CTrade object
Keep the object visible to the functions that use it

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.

Match declaration and usage
Avoid duplicate trade objects
Fix the first missing-name error before the cascade

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.

Recompile after the include fix
Log retcodes after trade calls
Keep spread and risk gates intact

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.

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.