Code Review
Filter MQL5 positions by symbol and Magic Number before changing signal logic.
PositionSelect, PositionGetTicket, and PositionsTotal can make a bug look like a strategy problem when the EA counts account-wide exposure instead of the strategy instance it owns. Fix the ownership filter first: symbol, Magic Number, order type, and the exact block reason should be visible before max-trade, cooldown, or close logic runs.
Search intent
The developer needs to stop an MT5 EA from counting the wrong positions, blocking valid trades, or managing another strategy instance.
Cluster
Code Review
Tool path
mql5 code review
Reader
mq5 developer
Optional follow-up for MQL5 PositionSelect and Magic Number filter
Open the free desk first. Opt in only if this guide matches your compiler blocker for MQL5 PositionSelect and Magic Number filter.
Lead activation handoff
No email wait is required. After saving the opt-in, continue into the free desk with the same blocker so the visitor-to-lead-to-workflow path is measurable.
Continue in free deskChoose the workflow you want, then opt in only if you want Workfusionapp updates.
Separate position selection from ownership
Selecting a position by symbol or ticket is not the same thing as proving the EA owns it. Read the selected position properties and compare them against the EA inputs before acting.
Count pending orders separately
Pending orders and open positions are different exposure states. A max-trade gate should say exactly whether it counted market positions, pending orders, or both.
Log the blocker once
A good ownership gate explains why a trade was skipped without flooding every tick. Log the symbol, Magic Number, counted positions, counted orders, and next allowed action.
Use the tool
Paste the position or order-count loop into Workfusion Debugger to add MQL5 ownership filters before the next Strategy Tester run.
Related guides
Continue the EA build path.
MT4 Debugging
Debug an EA that opens too many trades
Find duplicate-entry, missing cooldown, magic number, and signal-state issues in an EA that overtrades.
Compiler Fixes
Fix MQL5 history and deal functions
Fix MT5 EA errors around HistoryDeals.mqh, HistoryDealGetTicket, deal properties, magic numbers, and closed-trade PnL.
Prop Firm Risk
Max open trades and cooldown for EAs
Use max-trade and cooldown controls to prevent duplicate entries and runaway exposure in Expert Advisors.