Loading…

Average Range By Hour

Some hours of the trading day are simply busier than others - a session open produces bigger candles than the middle of a quiet Asian session, and that pattern is stable enough to be worth tracking. This indicator builds that baseline itself: for each of the 24 server-time hours, it keeps a running sum and count of every closed bar's high-low range that opened in that hour, then plots the average as a grey histogram alongside a blue line showing each bar's actual range for direct comparison. The average is strictly causal. The value shown for a given bar is built only from earlier bars of the same hour - never from the bar itself, and never revised by bars that close later. Contrast this with the naive approach of averaging "this hour, across all history" fresh on every recalculation: that number would keep quietly shifting every single bar's plotted value each time a new bar of that hour closed, which is repainting in substance even though no arrow is ever erased or redrawn. Here, once a bar's average is computed, a full history reload reproduces the exact same number - it does not move. The practical cost of that honesty: the very first bars of each hour bucket in a fresh history plot nothing (no prior data yet for that hour), and the average only becomes meaningful after enough occurrences of that hour have accumulated. That is the correct behaviour for a causal statistic, not a bug. Notes and limitations - Hour buckets use server time (the time[] array as delivered by the terminal), which is the broker's clock, not necessarily the trader's local time zone. Check your broker's server time offset before reading hour numbers as local clock hours. - The running sums persist only for the lifetime of the indicator on the chart; removing and re-adding it, changing symbol/timeframe, or a history reload all trigger a fresh rebuild from whatever history is then available. - Uses no chart objects - both plots are ordinary indicator buffers with nothing to clean up in OnDeinit.

Indicator · MT4 · v1.0 · Free

About Average Range By Hour

Average Range By Hour is an indicator for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 2 settings, such as Alert multiplier and Alerts. MQL source code included.

Files in the download: AverageRangeByHour.ex4, AverageRangeByHour.mq4, AverageRangeByHour.txt.

Settings

SettingDefaultWhat it does
Alert multiplier2.0Alert when actual range >= average x this, closed bar
AlertstrueAlert once per closed bar on an outsized range

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Indicators.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the indicator from the Navigator onto a chart and adjust the settings.

Download the PDF guide

Tags: Alerts · Trading Sessions · MT4 Indicator · MQL4 Source Code

MetaTrader 4 & 5 indicators · PolyMaria