Loading…

Margin Usage Timeline

The terminal's own Account tab shows used margin right now, but not whether it has been climbing steadily over the session or spiked briefly and recovered. This indicator samples AccountMargin() and AccountEquity() on a timer, plots margin used as a percentage of equity as a simple line, and draws two configurable level lines - a warning level and a critical level - so a trend toward over-leverage is visible before it becomes an emergency. An optional single Alert fires the first time usage crosses the critical level, re-arming only once usage has dropped back below the warning level, so it does not spam on every tick spent above it. Notes and limitations Like every "recorder"-style MQL4 indicator, only the current (rightmost) bar is ever written; earlier bars keep whatever value was last written while they were current. History before the indicator was attached shows nothing, since MQL4 keeps no record of past margin usage to backfill from. This measures used margin against equity, not the broker's own margin-level formula (equity/margin), which some brokers vary slightly (e.g. how hedged positions are netted for margin purposes) - treat this as a consistent internal trend indicator, not a byte-exact reproduction of the broker's own stop-out math.

Indicator · MT4 · v1.0 · Free

About Margin Usage Timeline

Margin Usage Timeline is an indicator for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 4 settings, such as Warn level, Critical level and Sample seconds. MQL source code included.

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

Settings

SettingDefaultWhat it does
Warn level70.0Level line shown as an early-warning threshold
Critical level90.0Level line shown as the critical threshold
Sample seconds5How often margin usage is refreshed independently of price ticks
Alert on criticaltrueFire one Alert per crossing above InpCriticalLevel

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 → Indicators.
  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 indicator from the Navigator onto a chart and adjust the settings.

Download the PDF guide

Tags: Trend · Trading Sessions · Alerts · MT4 Indicator · MQL4 Source Code

MetaTrader 4 & 5 indicators · PolyMaria