Python notebook: spread histogram by hour from an MT5 export
Posted: Wed Oct 21, 2026 1:32 pm
A quick analysis that answers "when is my broker cheap?" with your own data.
Data collection: a simple MT5 script writes time, bid, ask to CSV every second (or on every tick) for two weeks.
Notebook outline:
Adjust the server timezone (many brokers run on GMT+2/+3). Getting this wrong shifts everything by two or three hours and leads to wrong conclusions.
What to look for:
- The hours where the median is lowest.
- The hours where the 99th percentile spikes, often more important than the median.
- Differences between Monday and the rest of the week.
If anyone runs this, post the chart (without broker name if you prefer). Comparing shapes across brokers is interesting.
Data collection: a simple MT5 script writes time, bid, ask to CSV every second (or on every tick) for two weeks.
Notebook outline:
Code: Select all
import pandas as pd
df = pd.read_csv('ticks.csv', names=['time','bid','ask'], parse_dates=['time'])
df['spread'] = (df.ask - df.bid) / 0.0001 # EURUSD pips
df['hour'] = df.time.dt.tz_localize('Etc/GMT-2').dt.tz_convert('Europe/London').dt.hour
summary = df.groupby('hour').spread.describe(percentiles=[.5,.9,.99])
summary[['50%','90%','99%']].plot(kind='bar')
What to look for:
- The hours where the median is lowest.
- The hours where the 99th percentile spikes, often more important than the median.
- Differences between Monday and the rest of the week.
If anyone runs this, post the chart (without broker name if you prefer). Comparing shapes across brokers is interesting.