Spread By Hour - average and max spread per hour, live spread vs usual
Info
The Spread By Hour - average and max spread per hour, live spread vs usual is a Indicator for MetaTrader 5 that spread by hour shows the average and maximum spread for each hour of the day (broker server time), calculated from the symbol's own bar history, as a compact panel on the chart. Below the table it compares the current spread with the usual spread of the current hour and shows the spread cost of 1 lot in the account currency.
Usage
This tool is typically used for enhancing chart analysis and decision making.
Platform
This Indicator works exclusively on MetaTrader 5 (both build 600+ and newer versions).
Setup
Place the downloaded file in MQL5/Indicators folder via File ? Open Data Folder in MetaTrader 5.
How to Install and Use Spread By Hour - average and max spread per hour, live spread vs usual
1. Installation: Place your file in the MQL/Indicators folder via "Open Data Folder" and restart your terminal.
2. Loading: Find the indicator in the Navigator, drag it onto your chart, and configure the input parameters in the popup window.
3. Customization: Press Ctrl+I to open the indicator list, select your tool, and click "Properties" to change colors, levels, or visual styles.
4. Updating: Replace the old file in the Indicators folder with the new version and restart the platform to apply changes.
Frequently Asked Questions
Q: Why is my indicator not showing? A: Verify the file is in the MQL/Indicators folder, or try right-clicking the "Indicators" tree in the Navigator and clicking "Refresh."
Q: Do custom indicators slow down the platform? A: Too many complex indicators can impact performance; remove unused ones via the "Indicator List" (Ctrl+I).
Q: Can I use MT4 indicators on MT5? A: No, MQL4 and MQL5 are distinct languages; ensure the indicator is compiled specifically for your platform version.
What this tool does
Spread By Hour shows the average and maximum spread for each hour of the day (broker server time), calculated from the symbol's own bar history, as a compact panel on the chart.
Typical Use Case
This Indicator excels in automated trading and technical analysis on MetaTrader 5.
Compatible Platform & Setup
This Indicator works on MetaTrader 5. Place the file in the MQL5/Indicators folder and restart the terminal.
Description & Settings
Related: Spread and Tick Velocity Monitor for MT5 - another powerful indicator for MetaTrader 5 traders.
Spread By Hour
shows the
average and maximum spread for each hour of the day
Also recommended: Spread and Cost Monitor Panel - similar indicator with strong performance on MetaTrader 5.
(broker server time), calculated from the symbol's own bar history, as a compact panel on the chart. Below the table it compares thecurrent spread
with the usual spread of the current hour and shows the
spread cost of 1 lot
in the account currency.
It answers a simple question that matters for every intraday strategy: at which hours is trading on this symbol cheap, and at which hours does the spread blow up at my broker? On the screenshot (gold, 20 days of M5 bars) the spread is about 5-6 points most of the day, but around the daily rollover hour it averages 15 points with spikes to 50.
How it works
Reads the bars of the last
InpDays
days on the timeframe
InpTF
(M5 by default) with CopyRates and groups the bar spread by server hour (0-23).
Each hour gets a bar coloured from green (cheapest hours) to red (most expensive), with the average and maximum spread in points. Hours without data (market closed) are shown as "no data".
The current hour is marked with ">". The live line turns red when the current spread is more than 1.5 times the usual spread of this hour.
Cost of 1 lot = spread in points converted with the symbol's tick value and tick size, in the account currency.
The table is recalculated every 10 minutes; the live line updates on every tick. If the history is not loaded yet, it retries every second.
Optional CSV export of the table to MQL5\Files\SpreadByHour_<symbol>.csv.
Example
Gold (XAUUSD), M15 chart, 20 days of M5 bars:
Inputs
InpDays
(20) - days of history to analyse.
InpTF
(M5) - timeframe of the bars used for the statistics (H1 or lower; M1 gives the most detail).
InpSkipZero
(true) - ignore bars with spread 0 (no data).
InpExportCSV
(false) - write the table to a CSV file.
InpX / InpY / InpBarWidth
- position and size of the panel.
InpLowColor / InpHighColor / InpTextColor / InpBgColor
- colours.
Notes
MetaTrader stores one spread value per bar, and many brokers store the lowest spread of the bar. Treat the averages as a floor: the spread you actually pay at a given moment can be higher, which is why the live line is shown next to the history.
Hours are broker server time, so they shift when the broker changes daylight saving time.
The indicator only draws chart objects (prefix SPRH_), has no buffers, and removes its objects when deleted.
You may also like: Candle Countdown Timer and Spread Display - excellent alternative for indicator users on MetaTrader 5.
Source Code
#property copyright "RobotFX"
#property version "1.00"
#property description "This code is educational. Feel free to use, modify and upgrade as you wish. Visit ROBOTFX.ORG for professional trading tools"
#property indicator_chart_window
#property indicator_buffers 0
#property indicator_plots 0
input int InpDays = 20;
input ENUM_TIMEFRAMES InpTF = PERIOD_M5;
input bool InpSkipZero = true;
input bool InpExportCSV = false;
.......
⚠ Limitations & Risk Warning
- This tool is provided for educational and testing purposes only.
- Past performance does not guarantee future results.
- Trading involves substantial risk of loss. Use on a demo account first.
- Results may vary depending on market conditions, broker, and settings.
- We recommend thorough backtesting and forward testing before using with real funds.