Preset Rotation Automator
Manually flipping an EA's risk percent and stop/target distances when conditions change is easy to forget and easy to get wrong under pressure. This tool does not invent new parameter values on the fly - it only rotates between a short, human-written list of already-approved presets (name, risk percent, stop-loss pips, take-profit pips, trail pips), selecting one either by an ATR-based volatility regime score or by a time-of-day schedule, and writes the active preset to a plain CSV file that any other EA in the terminal can read on its own polling cycle. In ATR mode, the current ATR in pips is linearly mapped between InpAtrCalmPips and InpAtrStormPips onto the preset list ordered calmest to stormiest, so adding a fourth or fifth preset between Calm and Storm works without changing any code. In schedule mode, a list of HHMM-HHMM:PresetName windows (server time) picks the preset covering the current time. Every switch - including the very first one at startup - is appended to a log file with a timestamp, the previous preset's name, the new one, and the reason (the ATR score or the matched schedule window). The automator also remembers the single most recent previous preset, so dropping a flag file (InpRevertFlagFile) into MQL4\Files\ (or MQL5\Files\ on the native MQL5 build) restores it on the next poll and logs that as a "manual revert" - a deliberate, one-step way to undo a switch that turned out to be premature, without having to know or retype the old preset's values. Notes and limitations - This EA does not open, close, or modify any trade itself - it only selects and publishes a preset. Pairing it with a trading EA that actually reads InpActiveFile is required for the rotation to affect live trading. - Only one level of revert history is kept (the single previous preset), not a full undo stack - a second revert request immediately after the first swaps back to what was active before that, which is the expected "toggle" behaviour, not a multi-step undo. - Schedule windows are read against server time, with no timezone conversion; align InpScheduleList to the broker server's clock. - ATR mode reacts to volatility only - it has no concept of scheduled news events or session boundaries; combine with Calendar Driven Automation from this catalogue if that matters. - A malformed entry in InpPresetList or InpScheduleList is skipped rather than aborting startup, so check the Experts log at first attach to confirm every intended preset/window actually parsed.
Expert advisor · MT4 · v1.0 · Free
About Preset Rotation Automator
Preset Rotation Automator is a script for MetaTrader 4 based on ATR. It has 10 settings, such as Preset list, Rotation mode and Atr period. MQL source code included.
Files in the download: PresetRotationAutomator.ex4, PresetRotationAutomator.mq4, PresetRotationAutomator.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Preset list | Calm:0.5,20,40,10|Normal:1.0,30,60,15|St | |
| Rotation mode | ATR | "ATR" = pick by volatility regime, "SCHEDULE" = pick by time of day |
| Atr period | 14 | ATR period used for the volatility regime score |
| Atr calm pips | 15.0 | ATR at or below this many pips maps to the calmest preset |
| Atr storm pips | 45.0 | ATR at or above this many pips maps to the stormiest preset |
| Schedule list | 0000-0800:Calm|0800-1600:Normal|1600-240 | |
| Active file | active_preset.csv | Written on every switch - other EAs read this |
| Log file | preset_rotation_log.csv | Append-only switch history |
| Revert flag file | preset_revert.flag | Create this file in MQL4\Files\ to restore the previous preset |
| Poll seconds | 30 | Seconds between regime/schedule re-evaluation |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: ATR · MT4 Expert Advisor · MQL4 Source Code