How to Check Open Orders in MQL4
Camovia Tray Team · 2026-09-14
If you've written even a basic Expert Advisor in MQL4, you've probably used OrdersTotal() inside a for loop to scan through open orders. It's in every beginner tutorial, and it's often copied and pasted without a second thought. The assumption is simple: OrdersTotal() gives you the count, OrderSelect() lets you loop through them, and you're good to go.
But this "standard" approach has a blind spot that can break your EA or script at the worst possible moment.
The core issue is that OrdersTotal() returns the total number of market and pending orders . When you loop from 0 to OrdersTotal() - 1 while using OrderSelect() by position, you're working with a live, constantly changing list. If an order is closed or modified by another part of your code, a different terminal, or even the trader manually, the order pool shifts. This means an order you already processed might be gone, or a new one could appear before you've finished your loop.
Another common pitfall is misunderstanding the OrderSelect() function itself. It copies the order's data into a program environment. If you select an order and don't reselect it before reading its properties, you might be working with stale data . The official MQL4 documentation strongly recommends calling OrderSelect() directly before you request any order data to ensure it's current .
So, what's the less error-prone way? Many seasoned developers loop backward: for(int i = OrdersTotal() - 1; i >= 0; i--) . This simple change means that even if an order is closed and the list shrinks, you won't accidentally skip an order or try to access an index that no longer exists. It's a small adjustment, but it makes your code significantly more robust.
Another layer of complexity is the pool parameter in OrderSelect(). By default, it uses MODE_TRADES, which selects from open and pending orders . But if you're not careful, you might find your script returning errors because it's trying to select an order that has already moved to the history pool (closed or canceled orders). To work with those, you need to explicitly use MODE_HISTORY .
This brings us to a broader point about how we interact with MT4. Many traders who don't code rely on the Terminal window's "Trade" tab to manually check their open orders . While this works, it requires keeping the MT4 platform visible and navigating through its interface. For a trader who prefers a clean desktop, having the entire terminal window open just to peek at a P&L or close a position is a distraction.
This is where a tool like Camovia Tray changes the workflow. Instead of coding a loop to check orders or switching to the MT4 window, Camovia Tray turns the MetaTrader terminal into a system tray tool [citation:Product Knowledge]. It reads the open positions directly from your local MT4 instance and displays them in a floating order window. You can see the symbol, direction, lot size, open price, and current profit/loss at a glance [citation:Product Knowledge].
And it doesn't just show you the information—it lets you act on it. The "how to check" problem is often followed by "how to close." Camovia Tray includes a one-click close function for any displayed position, with a simple two-step confirmation to prevent accidental clicks [citation:Product Knowledge]. This eliminates the need to open the full terminal, find the order, right-click, and select "Close Order."
Furthermore, while building a proper EA to manage orders with robust error handling takes time and expertise, Camovia Tray provides a ready-made solution for local order management. It acts as a companion that sits quietly in your system tray, ensuring your order data is always visible without being intrusive, all while keeping that data entirely on your machine [citation:Product Knowledge].
The technical details of OrdersTotal() and OrderSelect() are fundamental for any MQL4 developer. But if your goal is simply to check and manage your positions efficiently, the solution doesn't have to be another complex script—it can be a smarter way to interact with the terminal itself.
MT4/MT5 Tray Assistant
Silent tracking, one-click close - check quotes and manage positions right from the tray.
Download Camovia TrayFrequently Asked Questions
How do I restore the MT5/MT4 window after hiding it?
Choose "Show MT5/MT4" from the system tray menu and the window returns to its previous position. You can also hover the tray to check quotes and manage positions without opening the terminal.
Can it replace MT5/MT4 for trading?
No - Camovia Tray is a local shortcut tool. You can close positions right from the popup; all trading operations (opening, closing, etc.) are submitted by your local MT5/MT4 terminal to your own broker account. The app does not hold your funds or provide investment advice.
Can the tray icon be disguised?
Yes. The tray icon can disguise itself as a cloud drive or a common system tool, so market watching stays low-key.
What is the tray lock feature?
Lock the tray function instantly at key moments to protect your privacy and prevent private information from leaking.
Online Tools
Popular Symbols Trading Hours
Open/close times, weekend hours & live market status:
Related Articles
XAUUSD Market Hours Explained: When Gold Trades and How to Stay Ready
XAUUSD market hours explained, from the Sydney open to the London-New York overlap. Learn when gold trades and how Camovia Tray helps you check live quotes and manage positions from the system tray.
MT5 Indicators Every Funded Trader Should Know: Stop Misreading the Signals
Discover the MT5 indicators every funded trader needs—and the common mistakes that ruin signals. Learn how Camovia Tray helps you monitor quotes and manage positions from the system tray for faster, safer execution.
Free Books on MQL4 Language Coding: Where to Start and What to Expect
Learn MQL4 coding with free official books and resources. Discover how Camovia Tray lets you monitor your MT4 EAs and positions discreetly from the system tray.
Brent Crude Oil Market Open Time in India: What Traders Get Wrong
Brent crude oil market open time in India explained: session timings, IST conversion, and how Camovia Tray helps you track quotes and manage positions from the system tray.
XAUUSD Market Close Time in Pakistan: A Practical Guide for Local Traders
Turn your MT5/MT4 into a tray tool with Camovia Tray - check XAUUSD market close time in Pakistan, live quotes and manage positions from the system tray.
More Articles
GER40 Trading Hours in South Africa: Clearing Up the Most Common Misconceptions
Confused about GER40 trading hours in South Africa? Clear up common myths, compare SAST and India times, and see how Camovia Tray helps you track GER40 from your system tray.
How to Make Good Money Day Trading: A Realistic Guide to Consistency, Risk, and Daily Targets
Discover how to make good money day trading with a realistic strategy, risk rules, and clean execution. Camovia Tray helps you manage MT5/MT4 positions from the system tray for faster, focused trading.
How Point and Figure Charts Cut Through Market Noise
Discover how Point and Figure charts filter market noise for clearer signals. Learn to trade breakouts with precision, and keep MT5 discreet with Camovia Tray.
The “100% Win Rate” Myth in Trading: Why It’s the Wrong Goal (and What Actually Matters)
Transform your MT5/MT4 into a tray tool with Camovia Tray. Check live quotes, manage positions, and close trades without opening the full terminal. All data stays local.
MT4 Toolbars Keep Disappearing? The Setting to Check First
MT4 toolbars vanish on every restart? It's usually a profile or toolbar-layout problem—here's the setting that fixes it for good.