Performance By Hour Report
Most traders already suspect they trade better at some hours than others - London open behaves differently from the dead patch before the Asian session wakes up - but checking that suspicion by hand means scrolling the account history tab and doing mental arithmetic on whatever is visible on screen. This script does the grouping properly, once, and prints all 24 hours in one table. The first trap is what counts as a trade. Balance and credit operations sit in the same history alongside real trades - a deposit or a withdrawal is not a market trade at all. A script that sums profit over the whole history without filtering by deal type first will fold a deposit straight into an hour's gross profit and report numbers that do not reconcile with the account statement. This script checks the trade type before a history entry is counted anywhere, on both platforms. The second trap is the profit factor. It is gross profit divided by the size of gross loss, and an hour that has only ever produced winners has a gross loss of exactly zero. Dividing by that either throws a runtime error or, depending on how the naive version is written, silently prints zero or a huge meaningless number. This script checks for a zero denominator first and prints "inf" when every trade in that hour won, and "n/a" when the hour has no result to divide at all. The third decision is about hours with no trades. It would be easy to only print the hours that have data and skip the rest, and several published versions of this idea do exactly that. The problem is that a table with gaps looks identical to a table that was never given the full history to begin with - there is no way to tell "checked, found nothing" from "did not check". This script always prints all 24 rows. An hour with zero trades shows an em-dash in every numeric column, so an empty hour is visibly different from a bug. Notes and limitations - The hour used for grouping is the broker's server time, not the trader's local time zone and not GMT. If your broker runs on a different offset to your own clock, shift the hours in your head before drawing conclusions, or check the server time against a known reference first. - Grouping is by the hour a trade opened, not the hour it closed. A trade opened at 22:50 and closed after midnight is still counted in the 22:00 bucket, which is deliberate - the entry decision is what a trader is usually trying to evaluate. - Only closed market trades are counted. Pending orders that were cancelled without filling, and orders still open at the time the script is run, are not part of this report. - Net profit per trade is the sum of profit, swap and commission, the same net-of-costs figure used across this catalogue. A trade with a net result of exactly zero is counted toward that hour's trade total but affects neither the win count nor either gross figure. - The account history in the terminal can be pruned or limited by the broker and by the terminal's own history depth setting. This script reports on whatever history is currently loaded locally - it does not request a longer history from the server. - This is a read-only report. It never sends, modifies or closes an order.
Script · MT5 · v1.0 · Free
About Performance By Hour Report
Performance By Hour Report is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 2 settings, such as Write csv and Csv delimiter. MQL source code included.
Files in the download: PerformanceByHour.ex5, PerformanceByHour.mq5, PerformanceByHour.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Write csv | false | Also write the table to a CSV file |
| Csv delimiter | , | CSV field delimiter |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Trading Sessions · Alerts · MT5 Script · MQL5 Source Code