#property copyright "Copyright 2025, MetaQuotes Ltd."
#property link "https://www.mql5.com"
#property version "1.00"
#property script_show_inputs
#property description "The script deletes global variables of the client terminal."
#property description "Limit date: Variables before the specified date are deleted."
#property description "If is zero, then variables that match the Name prefix criterion are deleted."
#property description "Name prefix: Prefix of the variable name. If not specified, then variables are deleted based on the Limit date criterion."
#property description "If all input parameters are zero, then all global variables are deleted."
#property description "If both parameters are specified, then global variables corresponding to each of the specified parameters are deleted."
//--- 输入变量
input datetime InpLimitDate= 0; // 限制日期
input string InpPrefix = NULL; // 名称前缀
//+------------------------------------------------------------------+
//| 脚本程序起始函数 |
//+------------------------------------------------------------------+
void OnStart()
{
//--- 获取客户端的全局变量总数,
//--- 根据脚本设置中选择的删除标准删除变量,并且
//--- 在日志中打印删除结果
int total=GlobalVariablesTotal();
int deleted=GlobalVariablesDeleteAll(InpPrefix, InpLimitDate);
PrintFormat("Of %d global variables, %d have been removed. %d remain", total, deleted, total-deleted);
/*
结果:
Of 21 global variables, 21 have been removed. 0 remain
*/
}
|