MQLArticles/Utils/SetFiles/README.md

39 lines
1.6 KiB
Markdown
Raw Permalink Normal View History

2026-09-06 11:15:27 -05:00
[← Utils](../README.md)
# Utils/SetFiles
Programmatic generation and editing of MetaTrader `.set` files (the parameter files used to run/optimize EAs).
## Main features
- Build a `.set` file from scratch, line by line, with typed parameters: number, real, bool, enum, datetime, color (`CSetFile.AddParamLine*`).
- Load an existing `.set` file and modify specific parameter values or optimization ranges (`InitByFile`, `ModifyParamValue*`, `ModifyParamOpt*`).
- Insert lines at a specific position, remove lines, and export back to string or file (`InsertParamLine*`, `RemoveLine`, `Save`, `GetAsString`).
- Print/debug helpers for inspecting the current parameter table (`Imprimir`, `Summary`).
## Basic usage
```mql5
void OnStart()
{
CSetFile sf;
sf.Init("BotSimple");
sf.AddParamLineNumber("InpMagic", 100, 100, 1, 999);
sf.AddParamLineReal("InpRisk", 1.0, 2, 0.1, 0.1, 10.0);
sf.AddParamLineBool("InpUseFilter", false);
sf.AddParamLineDatetime("InpStartDate", D'2024.01.01', D'2020.01.01', 86400, D'2025.12.31');
sf.AddParamLineColor("InpLineColor", clrRed);
sf.ModifyParamValueNumber("InpMagic", 999);
sf.ModifyParamValueRealNumber("InpRisk", 5.5, 2);
sf.ModifyParamValueBoolean("InpUseFilter", true);
sf.ModifyParamValueDatetime("InpStartDate", D'2025.06.01');
sf.ModifyParamValueColor("InpLineColor", clrBlue);
sf.ModifyParamOptDatetimeStart("InpStartDate", D'2023.01.01');
sf.ModifyParamOptDatetimeStep("InpStartDate", 3600);
sf.ModifyParamOptDatetimeStop("InpStartDate", D'2026.01.01');
sf.Imprimir();
}
```
> Only the most representative methods are shown here.