Seasonality Heatmap with T-Statistics: Identifying Optimal Trading Hours and Days
Info
The Seasonality Heatmap with T-Statistics: Identifying Optimal Trading Hours and Days is a Indicator for MetaTrader 5 that robustness lab: seasonality heatmap with t-statistics (hour x weekday)most 'best hour to trade' tables present averages without statistical validation. This indicator introduces hypothesis testing to identify significant trading opportunities and warns against the multiple-testing trap.
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 Seasonality Heatmap with T-Statistics: Identifying Optimal Trading Hours and Days
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
Robustness Lab: Seasonality Heatmap with T-Statistics (Hour x Weekday)Most 'best hour to trade' tables present averages without statistical validation.
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 Heatmap: Hourly Spread Analysis by Day and Time - another powerful indicator for MetaTrader 5 traders.
Robustness Lab: Seasonality Heatmap with T-Statistics (Hour x Weekday)Also recommended: Session Volatility Heatmap - similar indicator with strong performance on MetaTrader 5.
Most 'best hour to trade' tables present averages without statistical validation. This indicator introduces hypothesis testing to identify significant trading opportunities and warns against the multiple-testing trap.
How It Works
The indicator analyzes price bars of a selected timeframe (M5 to H1) over a specified lookback period. For each trading day, it calculates the return of every hour (defined as (close - open) / open) and categorizes it by weekday and hour. Server time is used, with an option to apply an hourly shift.
For each hour and weekday combination, the indicator computes the mean return, the t-statistic (measuring the significance of the mean return), the hit rate (percentage of positive trading bars), and the average range in points.
Cells meeting the criteria for a minimum number of bars and a t-statistic magnitude at or above a defined threshold are highlighted with a gold frame.
Given approximately 120 cells (24 hours x 5 weekdays, excluding weekends if disabled), around 5 cells might appear statistically significant by chance alone (|t| >= 2). The indicator displays the count of framed cells compared to the number expected by chance. The indicator's visual feedback turns green when the observed count of significant cells is substantially higher than what would be expected by random chance.
Inputs
Timeframe: M5 to H1 (higher timeframes lack intraday hourly data).
Lookback Period: Specified in calendar days (default is 730 days, representing approximately 2 years).
Coloring Method: Choose to color cells based on t-statistic, mean return percentage, hit rate, or mean range.
Additional Parameters: Hour shift from server time, |t| threshold for significance, minimum bars required per cell, option to include or exclude weekends, panel position, cell size, and font size.
Notes
The heatmap is recalculated once per day, ensuring no performance impact on every tick.
This indicator requires the RL_Common.mqh library, which should be placed in the MQL5\Include\RobustnessLab directory (included in this package).
Statistical analysis is based on historical data and does not guarantee future results. A framed cell serves as an area for further investigation, not as a direct trading signal.
The provided example screenshot displays the XAUUSD H1 chart on a MetaQuotes demo account, utilizing a 730-day lookback period.
You may also like: interactive correlation matrix heatmap for mt5 - 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
#include <RobustnessLab\RL_Common.mqh>
enum ENUM_RL_SEAS_METRIC
{
RL_SEAS_TSTAT=0,
.......
⚠ 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.