Loading…

Live Account Banner Guard

It is easy to lose track of which chart is pointed at a demo account and which is pointed at a live one, especially with several terminals open. This EA checks ACCOUNT_TRADE_MODE on attach: on a demo or contest account it does nothing but leave a quiet Comment() note; on a real account it draws a full-width banner across the top of the chart naming the account number, currency and broker, with an "I understand - acknowledge" button. Until that button is clicked the banner stays at full height and, if InpAlertOnAttach is on, a popup Alert() also fires the moment the EA attaches. After acknowledgement the banner shrinks to a slim reminder strip that stays visible for the rest of the session rather than disappearing entirely - the point is a permanent, low-noise reminder, not a one-time popup that gets dismissed and forgotten. The acknowledgement is intentionally per-session: reattaching the EA or restarting the terminal resets it, so the warning cannot be silenced once and then forgotten for months. Notes and limitations This tool only detects and displays; it never blocks trading, closes positions, or enforces anything beyond visual reminder. It reads ACCOUNT_TRADE_MODE once at OnInit - it does not re-detect an account change mid-session, because MQL4 does not change the underlying account without a terminal reconnect/restart, which already re-runs OnInit for every attached EA. The banner width is re-measured on a 2-second timer and on CHARTEVENT_CHART_CHANGE so it keeps spanning the window after a resize, but there can be a brief visible lag between resizing and the redraw.

Expert advisor · MT4 · v1.0 · Free

About Live Account Banner Guard

Live Account Banner Guard is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 5 settings, such as Banner color, Strip color and Banner height. MQL source code included.

Files in the download: LiveAccountBannerGuard.ex4, LiveAccountBannerGuard.mq4, LiveAccountBannerGuard.txt.

Settings

SettingDefaultWhat it does
Banner colorclrFireBrickBackground colour of the full warning banner
Strip colorclrDarkRedBackground colour of the shrunk reminder strip
Banner height34Height in pixels of the full warning banner
Strip height16Height in pixels of the shrunk reminder strip
Alert on attachtrueFire a popup Alert() the moment a live account is detected

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: Trading Sessions · Alerts · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria