Loading…

Copy Presets Between Experts

A saved preset is tied to the filename you gave it, not to the expert it was made for. Rename an expert, or fork it into a second variant, and every .set file you built for it - one per symbol, one per timeframe, however you organise them - is still sitting under the old name. The usual fix is opening the tester or the Expert Properties dialog and re-typing every input from scratch, which is slow and the exact kind of task where one field gets mistyped. This script copies the file bytes unchanged and only changes the name. Point it at the old prefix and the new one, and it finds every .set file that starts with the old prefix - not just an exact match, so "MyStrategy_H1.set", "MyStrategy_H4.set" and "MyStrategy_EURUSD.set" all come along in one pass - and writes a copy of each with the prefix swapped, suffix intact. Reading and writing in binary mode rather than as text keeps whatever encoding the original file used, ANSI or Unicode, instead of risking corruption from a text-mode round trip. It refuses to overwrite a target file that already exists unless told to, because a silent overwrite of a preset you have since hand-tuned is exactly the kind of accidental data loss a rename utility should not be capable of by default. Notes and limitations - Works only on files already inside the terminal's own Files sandbox (MQL4\Files or MQL5\Files). It cannot read or write the Presets folder, or any folder outside its own sandbox - that restriction is enforced by the terminal, not by this script. - Matching is a plain "starts with" prefix test, not a wildcard pattern. A prefix of "My" will also match "MyOtherStrategy.set" if one exists - pick a prefix specific enough to mean only what you intend. - Copies exact bytes. It does not open or validate the preset's contents, so a corrupted source file produces a corrupted copy under the new name. - Does not delete or rename the source files. Run a separate cleanup pass by hand once you have confirmed the copies are correct.

Script · MT5 · v1.0 · Free

About Copy Presets Between Experts

Copy Presets Between Experts is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 4 settings, such as Source prefix, Target prefix and Overwrite existing. MQL source code included.

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

Settings

SettingDefaultWhat it does
Source prefixExisting preset filename prefix, e.g. MyStrategy
Target prefixNew prefix to copy the presets to, e.g. MyStrategyV2
Overwrite existingfalseOverwrite a target file if one already exists
Confirm firsttrueAsk for confirmation before writing anything

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: Alerts · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria