MQL5 CTrade blocker

Fix CTrade setup before rewriting the EA strategy.

Fix MQL5 CTrade setup errors by checking Trade.mqh includes, CTrade object scope, trade.Buy/trade.Sell calls, result retcodes, and execution guardrails before manual retesting.

Common CTrade evidence

'trade' - undeclared identifier
'CTrade' - unexpected token
trade.Buy - undeclared identifier
PositionClose call fails
ResultRetcode not logged

These are wiring and evidence failures. Treat them as software diagnostics before changing strategy logic or testing order behavior.

Fix Trade.mqh and CTrade object setup
Check trade.Buy, trade.Sell, and PositionClose scope
Log ResultRetcode and broker comments
Route opt-in source as CTrade fixer interest
Fix CTrade in MQL5

Audience

For MQL5 builders whose EA fails around Trade.mqh, CTrade trade, trade.Buy, trade.Sell, PositionClose, or a 'trade' undeclared compiler cascade.

Problem

CTrade issues usually start with structure: the standard trade include is missing, the CTrade object is declared in the wrong scope, or the EA calls a different object name than the one it created.

Outcome

Workfusionapp keeps the repair path narrow: wire the include and object once, keep calls behind risk gates, log retcodes, then route the fixed block into the free desk and support handoff.

Support path

One problem, one fix path.

Start with the concrete blocker, keep the full EA context attached, then move to a reviewable output.

1. Add the include and object once

Use the standard Trade.mqh include and create one CTrade instance in a scope visible to OnTick and helper functions.

2. Match object name and call site

If the EA declares tradeObj but calls trade.Buy, the compiler is correct. Pick one object name and use it consistently.

3. Keep execution behind guardrails

Do not call trade.Buy or trade.Sell before spread, session, exposure, max-trade, stop-distance, and risk checks pass. Log ResultRetcode after each attempt.

Workflow

From CTrade compiler cascade to one valid trade object.

The fix is not to rename everything randomly. The fix is to prove the include, object declaration, call site, risk gate, and retcode logging are wired consistently.

Step 1

Paste the first CTrade error

Step 2

Check include and object scope

Step 3

Review trade call and retcodes

Step 4

Retest manually with execution logs

CTrade handoff

Route the trade-object blocker into the right MQL5 setup check.

Open the guide that matches the failed CTrade wiring, then run the free desk with the first compiler line, include block, object declaration, failing trade call, and any retcode evidence.

Trade object setup guide

Use this when the first blocker is missing Trade.mqh, missing CTrade trade, inconsistent object naming, or trade.Buy/trade.Sell scope.

Execution audit trail

Use this when trade calls compile but retcodes, broker comments, or order evidence are not being recorded cleanly.

Send me the CTrade repair workflow

Opt in only if your MQL5 EA is blocked by Trade.mqh, CTrade object scope, trade.Buy/trade.Sell, PositionClose, or retcode logging. This captures the CTrade source for conversion measurement.

Intent locked: Paste compiler errors

Choose the workflow you want, then opt in only if you want Workfusionapp updates.

Should I create a new CTrade object in every function?

No. Use one clearly named object in visible scope unless there is a deliberate reason to isolate execution state.

Does fixing CTrade mean the EA should trade live?

No. It only fixes one code and execution-evidence layer. Manual compile, Strategy Tester review, demo testing, and risk review remain separate.

Does this require broker credentials?

No. Use code, compiler errors, Strategy Tester or demo retcodes, broker comments, and logs. Workfusionapp does not need broker login.