Skip to content
All library documents

Inspecting, Backing Up, and Restoring MetaTrader Terminal Global Variables

Article MQL5 code base

Summary

This document describes a MetaTrader 5 utility for reviewing terminal global variables, which Expert Advisors often use to preserve state such as trade timestamps, balance references, and lock flags. Users can list or export variables, delete filtered matches, and import values from a CSV backup. Filters include name prefix, contained text, and minimum time since last access; output includes values, access times, age, and date interpretations for plausible timestamp values.

The script first captures names and access times before reading values, because reading a variable refreshes its access time and extends its retention period. Deletion can prompt for confirmation and write a backup before removing anything. The tool applies only to the current terminal, uses the local clock for age, and can alter the state of running EAs if their variables are removed. CSV imports may lose precision for unusually precise values and restore variables without their original temporary status.

Key ideas

  • The utility filters, lists, exports, deletes, and restores terminal global variables used by Expert Advisors.
  • Reading a variable refreshes its last-access time, so the script captures access times before reading filtered values.
  • Deletion can require confirmation and a successful CSV backup before variables are removed.
  • Each MetaTrader terminal has its own variables, and removing a variable can affect an EA that is running.
  • CSV import has limits involving precision and the restoration of temporary variables.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.