Set Timeframe On All Charts
Switching a whole workspace of charts to a different timeframe - dropping everything to M15 before a news release, or back to H4 afterwards - is normally one dropdown click per chart. This script does every open chart in one pass while leaving each chart's own symbol exactly as it was. ChartSetSymbolPeriod carries the same two traps as ChartApplyTemplate. The call is asynchronous, so a true return means the change was accepted into that chart's message queue, not that the timeframe has switched yet - the per-chart result here is worded as "queued" for that reason. And changing a chart's period re-initialises whatever is attached to it, which means a script that changed its own chart mid-loop could be unloaded before it finished the rest of the list. This script processes every other chart first, prints the full summary, and only then changes the timeframe on the chart it is running on, as the very last action. Anything reported before that line is guaranteed to have been logged; the final line covering the script's own chart might not be, if that change is the one that ends the script. Notes and limitations - A "queued" result is not proof the timeframe actually changed - it only means the chart accepted the request. The real switch happens on that chart's own schedule. - The chart running this script is always done last, even if its natural position in the chart list would put it earlier. - Changing an Expert Advisor's chart period re-initialises that EA, which restarts its internal state as if it had just been attached. Be aware of that before running this across charts carrying live strategies. - Bars for the new timeframe must already exist or be downloadable from the broker; an illiquid symbol with no history on the requested timeframe will simply show an empty chart until data arrives. - The chart walk is capped at 200 charts as a defensive limit.
Script · MT5 · v1.0 · Free
About Set Timeframe On All Charts
Set Timeframe On All Charts is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 2 settings, such as Timeframe and Confirm first. MQL source code included.
Files in the download: SetTimeframeAll.ex5, SetTimeframeAll.mq5, SetTimeframeAll.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Timeframe | PERIOD_H1 | Timeframe to set on every chart |
| Confirm first | true | Ask for confirmation before changing |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: News Trading · Alerts · MT5 Script · MQL5 Source Code