Spread and Liquidity Clock: Time-of-Day Cost-to-Range Profile

Spread and Liquidity Clock: Time-of-Day Cost-to-Range Profile
Download ALL MT5 indicators (6071)
YouTube Video Thumbnail



Similar MetaTrader Tools

Spread and Liquidity Clock: Time-of-Day Cost-to-Range Profile

Info

The Spread and Liquidity Clock: Time-of-Day Cost-to-Range Profile is a Indicator for MetaTrader 5 that spread and liquidity clock: time-of-day spread, activity and cost-to-range profile from your broker's historyoverviewmost spread tools display the current spread. This tool answers a different question: when is it cheapest and most liquid to trade a specific symbol on your broker, and is the current time favorable.

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 and Liquidity Clock: Time-of-Day Cost-to-Range Profile

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 and Liquidity Clock: Time-of-Day Spread, Activity and Cost-to-Range Profile from Your Broker's HistoryOVERVIEWMost spread tools display the current spread.

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: Prop Firm News Countdown and Spread Monitor for MT5 - another powerful indicator for MetaTrader 5 traders.

Spread and Liquidity Clock: Time-of-Day Spread, Activity and Cost-to-Range Profile from Your Broker's History

Also recommended: Gold Session Liquidity Free MT5 - XAUUSD Sessions, Sweeps, and Risk Planner - similar indicator with strong performance on MetaTrader 5.


OVERVIEW

Most spread tools display the current spread. This tool answers a different question: when is it cheapest and most liquid to trade a specific symbol on your broker, and is the current time favorable?
The answer is dependent on the broker, the symbol, and the time of day, and this information is already present in your chart history. Each bar contains a spread value, tick volume, and price range. This indicator aggregates these values by time of day to illustrate typical patterns for each time slot.

For each time slot of the day (defaulting to 30 minutes, in server time), the indicator calculates three median values:

Typical Spread
: Measured in points. The median is used to mitigate distortions from rollover events and news spikes that could affect an average.

Typical Activity
: The median tick volume of bars within the slot. This reflects the number of price changes, not the traded volume.

Typical Cost-to-Range
: The typical spread divided by the typical bar range, expressed as a percentage. A low value indicates significant price movement relative to trading costs, while a high value suggests high trading costs for minimal price movement.

These time slots are then ranked against each other. The cheapest 25% of slots are designated as "cheap," and the most expensive 25% are designated as "expensive" (this percentage is adjustable via the InpCutoffPercent input). A slot with a typical spread identical to all others, as seen on a fixed-spread account, will not be classified as cheap or expensive.

The profile is constructed without future data. Each bar is evaluated against the profile of preceding bars, and a bar is incorporated into the profile only after it has closed. Consequently, a forming bar is ranked against its slot, but it does not contribute to its own calculation. A slot with fewer than the minimum required samples (InpMinSamples) remains empty until sufficient historical data is available. The calculation is incremental; upon each update, only the new bars and the currently forming bar are processed, and the profile is stored in small, fixed-size histograms, eliminating the need for historical data rescanning or sorting.

Regarding the data:
Values from 0 to 127 are recorded precisely. Larger values, such as the bar's range in points, are grouped into bins approximately 4% wide, which may introduce up to a 4% margin of error in the medians. A spread of 0 in the history indicates that the broker did not record a spread for that bar. Such bars are excluded from spread statistics and are reflected in the percentage of bars with usable spread shown in the panel.

How to Interpret the Indicator

Histogram (in the indicator window):
Each bar represents a chart bar. Its height corresponds to the typical spread of that bar's time slot, in points. Dark gray indicates a cheap slot, light gray a normal slot, and white an expensive slot. As time slots repeat daily, the histogram displays the daily pattern as a recurring comb structure. Bars for slots lacking sufficient samples will appear empty.

Dotted Line:
Represents the spread recorded for each bar. When the dotted line is significantly above the bars, it signifies that the bar's spread was higher than usual for its time slot. Bars without spread data are omitted.

Dots:
Indicate bars falling within the rollover window. This window commences at the hour specified by InpRolloverHour (server time) and extends for the duration set by InpRolloverMinutes. Spreads typically widen around the daily rollover; these dots help identify these jumps as predictable patterns rather than anomalies. The dot is positioned on the bar's spread.

Dotted Horizontal Line:
Shows the median spread across the entire day, encompassing all slots. Slots falling below this line are cheaper than the day's average.

Data Window:
"Typical spread / range (%)" displays the cost-to-range for the slot. "Typical tick volume" indicates the activity level of the slot. "Spread rank in slot (%)" shows the percentage of preceding bars within the same slot that had a lower spread (equal spreads are counted as half); a value of 50% signifies a typical spread, while 95% indicates it falls within the most expensive 5% for that time of day.

Panel (located in the top-left corner of the chart):

Line 1: Displays the symbol, timeframe, slot length, and profile type (all weekdays or the weekday of the most recent bar).

Line 2: Shows the number of days and bars included in the profile, along with the percentage of bars with usable spread data. "LOW" is indicated if this percentage falls below 50%.

Line 3: Presents the median spread and median bar range for the entire day, as well as the overall cost-to-range.

Lines 4 and 5: List the three cheapest and three most expensive slots based on typical spread.

Lines 6 and 7: Identify the three slots with the lowest and highest cost-to-range ratios.

Line 8: Details the most recent bar, including its slot, spread, rank within the slot, the slot's typical spread, and its classification (cheap, normal, or expensive).

Line 9: Compares the activity (tick volume) of the most recently closed bar with the typical tick volume of its corresponding slot.

Example: Figure 1 depicts two days of M30 bars. The histogram illustrates the typical spread for each 30-minute slot (dark gray for cheap, light gray for normal, white for expensive). The dotted line represents the actual spread recorded for each bar. White dots mark the rollover window, and the dotted horizontal line indicates the median spread for the entire day. The panel provides a summary of the cheapest and most expensive slots and ranks the most recent bar within its slot. This is a black and white screenshot, adhering to Code Base image guidelines.

External Variables (Inputs)

Input Name

Default Value

Purpose

InpSlotMinutes

30

Duration of a time slot in minutes (range: 5-240). This value is adjusted to match the chart bar's length but will not be less than 5. It is rounded up to the nearest value that evenly divides the day (e.g., 50 minutes becomes 60 minutes).

InpWeekdaySplit

false

Enables a separate profile for each weekday (up to 7). This reduces the number of samples per slot by approximately five times, thus requiring more historical data.

InpMinSamples

20

Minimum number of bars required in a slot for its values to be used (range: 5-500). When using the weekday split, a slot receives approximately one bar per week; therefore, 20 samples correspond to about 20 weeks of data.

InpHistoryBars

20000

The number of most recent bars used when the indicator initially loads or performs a full recalculation. Setting this to 0 utilizes all available bars. New bars are automatically incorporated as they arrive.

InpCutoffPercent

25

Determines the percentage of slots classified as cheap and expensive (range: 5-45). A value of 25 designates the cheapest quarter and the most expensive quarter of the slots.

InpRolloverHour

0

The server hour (0-23) when the daily rollover window begins. A value of -1 disables the rollover marker.

InpRolloverMinutes

60

The duration of the rollover window in minutes (range: 1-720).

InpShowPanel

true

Toggles the display of the statistics panel.

InpCheapColor

clrDimGray

The color used for histogram bars representing cheap slots.

InpNormalColor

clrDarkGray

The color used for histogram bars representing normal slots.

InpExpensiveColor

clrWhite

The color used for histogram bars representing expensive slots.

InpActualColor

clrSilver

The color of the dotted line displaying the spread of each individual bar.

InpTextColor

clrSilver

The color of the text within the panel.

InpFontSize

8

The font size for the panel text (using the Consolas font). Line height adjusts proportionally to the font size.

InpPanelX, InpPanelY

8, 14

The offset in pixels of the panel from the upper-left corner of the chart.

Recommended Usage

Timeframes:
Suitable for any intraday timeframe from M1 to H4. On D1 and longer timeframes, the concept of "time of day" is not applicable, and the indicator will display a message and render no data. M15 to H1 are generally recommended, as M1 bars often have insufficient ticks and noisy range data, and slots cannot be shorter than the chart bar.

Historical Data:
Refer to the "Days" figure in the panel to assess the stability of the profile. A profile based on only a few weeks of data may still be evolving, and the initial lists of cheap and expensive slots might change. A period of 100 days or more provides greater stability. Utilize the weekday split option only when you have substantial historical data, recognizing that Monday openings and Friday closings may exhibit different characteristics compared to mid-week trading.

Server Time:
All time slots are based on the broker's server time, not your local time. If the broker observes daylight saving time, a specific slot may correspond to a different real-world hour during summer versus winter, and the profile will average these variations. It is advisable to align the slot times with market sessions rather than your personal clock.

Spread Data in History:
The spread recorded for a historical bar represents a single value for that bar, not an average over the bar's duration. Some brokers may record a spread of 0 or a constant value. Check the "usable share" statistic in panel line 2. A constant spread results in a flat profile where no slots are designated as cheap or expensive, which accurately reflects the behavior of a fixed-spread account.

Costs Not Included in Spread:
This indicator exclusively measures the spread. It does not incorporate commissions charged per lot on certain account types (e.g., ECN, raw spread accounts).

Tick Volume:
"Activity" refers to the number of price changes reported by the broker's feed, not the actual traded volume. It serves as a reliable relative measure of activity within a specific slot on the same broker but cannot be directly compared between different brokers.

Past Performance Indicator:
The profile generated by this indicator reflects historical patterns and does not predict future market behavior. External events, such as news releases, can impact spreads in typically cheap slots. The "rank" value in line 8 indicates whether the current bar's spread deviates from the norm for its time slot.

Cost-to-Range:
This metric represents the typical spread divided by the typical bar range for the same timeframe. Consequently, it varies across different timeframes. Use it for comparisons within the same chart, not across charts of different timeframes.

Performance and Memory Usage:
With the default settings, the histograms consume approximately 0.3 MB of memory. With the weekday split enabled and 5-minute slots, memory usage can increase up to approximately 11 MB. Once the historical data is loaded, it is processed once. Subsequent ticks only affect the most recent bars and the panel display.

Chart Objects:
The indicator creates only the panel lines within the main chart window, which are named with the prefix SC_. These objects are automatically removed when the indicator is deactivated (OnDeinit()).

Account Types:
This indicator is non-trading and functions independently of account types, whether netting or hedging.

You may also like: Spread By Hour: Analyze Average and Maximum Spreads Per Hour - excellent alternative for indicator users on MetaTrader 5.

Source Code

#property copyright "RobotFX"
#property link "https://robotfx.org"
#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_separate_window
#property indicator_buffers 7
#property indicator_plots   6
#property indicator_label1  "Typical spread (points)"
#property indicator_type1   DRAW_COLOR_HISTOGRAM
#property indicator_color1  clrDimGray,clrDarkGray,clrWhite

.......

Leave your opinion, ask a question, share some knowledge

⚠ 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.
© ROBOTFX Free educational tools by RobotFX. Use entirely at your own risk; we are not liable for any financial losses incurred.