How to Draw Filled Rectangles in MQL4 & MQL5 (Code)
Camovia Tray Team · 2026-09-11
There’s a moment every MetaTrader developer knows well. You've just coded a custom indicator or a script that needs to visually highlight a specific price zone on the chart—a support level, a breakout range, or a time-based session. You write the ObjectCreate() function, define your OBJ_RECTANGLE, and compile. But when you attach it to the chart, the rectangle doesn't look quite right. In MT4, it's filled solid, hiding the price action beneath it. In MT5, it's just an empty outline, barely visible. Getting the filled state right across both platforms is one of those small but critical details that can derail a perfectly good implementation.
The root of the confusion lies in how the two MetaTrader versions handle the same visual property. In MQL4, the OBJPROP_BACK property controls whether a rectangle is filled. Setting it to false makes it unfilled (transparent), while true or the default state makes it a solid, opaque block . If you're coming from an MQL4 background, you might instinctively try the same approach in MQL5. But in MQL5, OBJPROP_BACK only controls whether the object is drawn behind the chart's price bars or in front of them—it has nothing to do with the fill state . To get a filled rectangle in MQL5, you need to use the OBJPROP_FILL property and set it to true .
Let's look at a typical scenario. Suppose you're building a range-breakout indicator that draws a filled rectangle to visually mark the consolidation zone. In MT4, your code might look something like this to create an unfilled box:
ObjectCreate("RangeBox", OBJ_RECTANGLE, 0, time1, price1, time2, price2);
ObjectSet("RangeBox", OBJPROP_BACK, false); If you ported this logic directly to MT5, you'd need to adjust it to:
ObjectCreate(0, "RangeBox", OBJ_RECTANGLE, 0, time1, price1, time2, price2);
ObjectSetInteger(0, "RangeBox", OBJPROP_FILL, true); As shown in the MQL5 documentation, OBJPROP_FILL is the dedicated property for this purpose, and it even applies to other shapes like triangles and ellipses .
Now, what if you need to manage these objects on a live chart that's constantly updating? You might want a box that follows the latest price. One practical approach is to redraw your rectangle so its second anchor point always ties to the current time, ensuring the highlight moves with the market . But repeatedly creating and deleting graphical objects can be computationally expensive and might slow down your chart's performance . This becomes especially noticeable when managing multiple instances simultaneously. This is where having an efficient workflow matters. If you're frequently switching between coding, testing your indicator in MT4, then porting it to MT5, juggling terminal windows becomes another distraction.
This is where a tool like Camovia Tray offers a subtle but practical benefit. While it won't write your code for you, it can streamline the environment where you do your development and testing. Camovia Tray lets you run your MetaTrader 4 or 5 instance minimized directly from your system tray [Product Knowledge]. It provides quick access to view live quotes and even manage open positions without needing to restore the full terminal window [Product Knowledge]. Instead of wrestling with Alt+Tab to find your terminal among multiple open windows, you can hover over the tray icon to check if a new price tick has triggered your rectangle condition. Your charts and scripts can continue running in the background, while you manage your development and testing from a single, unobtrusive point on your taskbar.
Whether you're debugging a for loop that cycles through all rectangles on a chart to toggle their filled status, or you're meticulously setting the OBJPROP_FILL property in MQL5's ObjectSetInteger function, the focus should be on the logic, not on window management . By keeping your MT5 or MT4 tucked away, Camovia Tray lets you maintain that focus, ensuring your environment is as streamlined as your code.
MT4/MT5 Tray Assistant
Silent tracking, one-click close - check quotes and manage positions right from the tray.
Download Camovia TrayFrequently Asked Questions
Do I need MT5/MT4 installed? Does the terminal need to stay open?
Yes. Camovia Tray reads quote and position data from your locally running MT5/MT4 terminal, so the terminal must be installed, running, and logged in. MT5 connects directly with no EA; MT4 needs the bundled bridge EA attached once (one-click copy in Settings, then double-click in the Navigator - see the docs).
Are my quotes and positions uploaded anywhere?
No. Quote and position data is read 100% from your local MT5/MT4 terminal and never leaves your computer. See the privacy policy for details.
Which systems and terminals are supported?
Windows 10 / 11, with MetaTrader 5 or MetaTrader 4 (installed and logged in; MT4 needs the bridge EA attached once).
Is the MT4 bridge EA safe? What do I need to enable?
Yes. The bridge EA (CamoviaBridge) is bundled with the app - it only reads quotes/positions locally and executes close commands; no DLLs, no data uploads. Closing positions requires turning on AutoTrading in the MT4 toolbar.
Online Tools
Popular Symbols Trading Hours
Open/close times, weekend hours & live market status:
Related Articles
Trading with Andrews' Pitchfork: A Practical Guide for MT4/MT5 Users
For traders using Andrews' Pitchfork in MT4/MT5, Camovia Tray lets you monitor price levels and manage positions from the system tray—no need to keep the terminal open all day.
The Weekly Breakout Edge: Why Your MetaTrader EA Deserves More Than Just a Chart
Streamline your weekly breakout EA management with Camovia Tray. Check MT5/MT4 positions and quotes from the system tray—privately and efficiently.
Beginners Guide to the DeMarker Indicator in Forex: How to Spot Exhaustion and Enter with Confidence
Discover the DeMarker indicator for Forex trading: spot exhaustion, use divergence strategies, and manage MT4/MT5 setups smoothly with Camovia Tray.
Best MT5 Trade Copier: What Traders Actually Need in 2026
Best MT5 trade copier comparison for 2026. Camovia Tray offers a smarter alternative — turn MT5/MT4 into a tray tool for quick quotes and position management.
Prop Firm EA Free vs. Manual Monitoring: Why Your Setup Is Only Half Complete
Transform your MT5/MT4 into a tray tool with Camovia Tray. Check live quotes and manage positions without opening the terminal—perfect for prop firm EA setups.
More Articles
Why Every Trader Needs a Market Data Pivot Calculator — and How to Use One Without Cluttering Your Screen
Discover how Camovia Tray streamlines your workflow with market data tools like pivot calculators, keeping MT5/MT4 accessible from the system tray without cluttering your screen.
Copying MetaTrader Chart Settings: MT4 vs MT5 – What Works, What Doesn’t
Learn how to copy MetaTrader chart settings between MT4 and MT5, and discover how Camovia Tray helps you check quotes and manage positions from the system tray without interrupting your workflow.
Gold Risk per Trade: Why 1% Beats 5% on XAUUSD
Risk per trade decides how long you survive gold's losing streaks. Compare 1%, 2% and 5% on XAUUSD, and Camovia Tray keeps risk per trade and open loss visible.
Why Every Trader Needs a Fibonacci Calculator (and How to Access It Without Leaving Your Tray)
Discover how a Fibonacci calculator fits into your daily workflow—and how Camovia Tray lets you check live price levels from the system tray without reopening MT4/MT5.
Keeping an ICT EA Compliant with News Trading Rules – A Practical Guide
Turn your MT5/MT4 into a tray tool and keep your ICT EA compliant with news trading rules. Camovia Tray gives you instant position visibility without opening the terminal – all data stays local.