Loading…

Account Health Snapshot

Most accounts are checked by opening four or five different tabs: the terminal window for balance and margin, the trade tab for open risk, and a mental note (or a spreadsheet) for how far underwater the account has been. This script puts the whole picture in one printed block. Two parts of it are worth explaining, because a naive version of either one produces a confidently wrong number. Risk if all stops hit. A position without a stop loss has no defined risk - not zero, undefined. A script that adds it to the total as 0.00 makes an account with one naked position look exactly as safe as one where everything is covered, right up until it isn't. This script prices every stop it can and lists everything else separately under UNBOUNDED, by ticket, so it cannot be missed. Where a stop does exist, the money figure is direction-aware and uses tick value and tick size, never a naive points-times-price guess, so gold, indices and JPY crosses come out right. It is reported as a positive number - what the account gives back if touched - and a stop parked on the wrong side of entry (traders do this on purpose sometimes, to lock in a minimum profit) correctly comes out negative and pulls the total down, because that position cannot lose money from here. Drawdown from peak balance. There is no stored history of what an account's balance was at every point in time - only the current balance and a list of events that changed it. This script rebuilds the missing curve by working backward: current balance minus every loaded balance-changing event (closed trades AND deposits/withdrawals) gives the balance before the oldest of them, and walking forward from there finds the highest point the balance actually reached. The reconstruction is always anchored to the real, live balance, so it cannot drift the way a running total computed from an assumed starting balance can. Balance, equity, margin and margin level are single, whole-account facts and are never filtered - the platform has no per-strategy version of any of them. The magic and symbol inputs instead scope the two sections that ARE naturally sliceable: open-position count/volume/risk, and today's realised result. Filtering the peak-balance section by magic or symbol was considered and rejected - it would produce a curve the account never actually had. Notes and limitations - MT4 can only see what the Account History tab has loaded. If the peak or today's result look short, right-click that tab, choose All History, and run the script again. - Drawdown is balance-based, built from the closed-trade curve - it is not an intraday equity drawdown. A large floating loss that never gets closed will not appear here; it shows up in the separate Floating P/L line. - "Today" is the current server calendar date, not the trader's local date - a broker on a different timezone can make "today" start several hours off from where you are. - Risk if all stops hit assumes every stop currently set is the one that gets hit. A trailing stop, a manual close, or slippage past the stop level in a fast market will all change the real outcome. - The unbounded-risk list and the risk total both respect the magic/symbol filter; a naked position outside the filter will not appear even though it is still real risk on the account.

Script · MT4 · v1.0 · Free

About Account Health Snapshot

Account Health Snapshot is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 4 settings, such as Magic filter, Symbol filter and Peak from date. MQL source code included.

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

Settings

SettingDefaultWhat it does
Magic filter-1Magic filter: open positions & today's result (-1 = all)
Symbol filterSymbol filter: open positions & today's result ("" = all)
Peak from date0Peak-balance search: earliest date (1970.01.01 = all loaded history)
Peak to date0Peak-balance search: latest date (1970.01.01 = up to now)

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: Alerts · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria