Loading…

Margin Series Recorder

The terminal shows margin, free margin and margin level as live numbers that overwrite themselves every tick. There is no built-in way to see how much headroom was actually carried through last week's volatile session once that moment has passed - by the time someone thinks to check, the number is gone. This EA samples account state on a timer, not on ticks, so the series keeps a steady cadence through both busy and quiet stretches. A purely tick-driven sampler would thin out exactly during the quiet periods that are often the most useful baseline for capacity planning. Each sample records balance, equity, margin, free margin, margin level percentage, open position count and total open lots across the whole account, plus - optionally - the chart symbol's current per-lot margin requirement as a sizing reference. Notes and limitations Margin figures are account-wide, aggregating exposure across every symbol currently traded on the account, not just the chart symbol. The optional per-lot margin-requirement column is the one figure that is symbol-specific. Sampling is timer-driven and depends on the terminal being connected and this EA running - gaps in connectivity or a stopped EA produce gaps in the series with no interpolation or backfill. This EA never trades and never modifies an order - it only reads account state.

Expert advisor · MT5 · v1.0 · Free

About Margin Series Recorder

Margin Series Recorder is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 3 settings, such as Sample seconds, Include symbol margin required and Log file name. MQL source code included.

Files in the download: MarginSeriesRecorder.ex5, MarginSeriesRecorder.mq5, MarginSeriesRecorder.txt.

Settings

SettingDefaultWhat it does
Sample seconds30How often a sample is written
Include symbol margin requiredtrueAdd the chart symbol's per-lot margin requirement column
Log file nameMarginSeriesRecorder.csvFile written under MQL5\Files\

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 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 · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria