Watch how to download trading robots for free
Find us on Telegram!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Scripts

SessionEdgeTester - does a time-of-day rule beat spread and swap? - script for MetaTrader 5

PROSPRA IQ ENTERPRISES (PTY) LTD
PROSPRA IQ ENTERPRISES (PTY) LTD
  • Founder, MQL5 developer and strategy tester at  PROSPRA IQ ENTERPRISES (PTY) LTD
  • South Africa
  • 335
MQL5 developer and strategy tester, South Africa (Prospra IQ Enterprises). I build Expert Advisors, indicators, trade managers and prop-firm risk guards for MetaTrader 5 and 4, and convert MT4 code to MT5.
Views:
92
Rating:
(1)
Published:
gold_hours_750.png (65.21 KB)
set_inputs.png (93.02 KB)
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

Does "buy at 18:00 New York, sell 9 hours later" really make money on your broker after costs? SessionEdgeTester answers that in about 20 seconds from your terminal's own H1 history. It places no trades.Gold: 9-hour hold from every entry hour

What it does

  • Buys (or sells) on the chosen weekdays at a fixed entry hour and exits a fixed number of hours later.
  • Each trade pays the larger of 1.5x the live spread and the spread recorded on the entry bar, plus optional commission, plus the live swap for every server midnight crossed (triple on the rollover day).
  • The entry time can be written in server, New York or London time. Daylight saving is handled, so the rule stays on the same clock hour all year, on GMT brokers and on New York-close (GMT+2/+3) brokers.
  • Optional stop-loss in %, checked on H1 highs/lows.

The report

  • All trades, the first 60% vs the last 40% of history (an honest out-of-sample check) and a PASS / WATCH / FAIL verdict.
  • Result before swap, by weekday and by year.
  • Baseline: the same hold started at every other hour. If most hours do as well, your "edge" is the market's drift, not your timing.

Example (Deriv XAUUSD, 2011-2026, buy 18:00 New York, hold 9 h, Mon-Thu, 2,489 trades): +2.74 bp per trade after costs, t 2.86; last 40% +5.49 bp, t 3.57; 0 of the 23 other entry hours did as well. The first 60% was flat (+0.07 bp), so the effect is recent, and the report shows you that too.

Inputs

Sym - symbol ("" = chart symbol)

GoLong - true = buy, false = sell

Clock - server, New York or London time

EntryHour, HoldHours, Weekdays (0=Sun..6=Sat)

StopPct - stop-loss in %, 0 = none

ServerClock - fixed offset (now), NY+7 (New York-close brokers) or GMT

SpreadMult, ExtraCostPct (commission in %), From, ISShare, OutFile

Output: Experts tab and MQL5\Files\SessionEdgeTester.txt

Research tool. Past results do not guarantee future results.

BotWatchdog - phone alerts when your EAs silently stop working BotWatchdog - phone alerts when your EAs silently stop working

Push notifications when the connection drops, algo trading is switched off, an EA leaves its chart, the account changes, a position has no stop, equity or margin hit a limit - plus a daily heartbeat.

SpreadClock - your broker's spread by hour and weekday from real ticks SpreadClock - your broker's spread by hour and weekday from real ticks

Reads real tick history and reports average, median and 95th-percentile spread for every server hour and weekday, plus the cost in % of price.

AlertKit, one alert per event and bar, no alert spam AlertKit, one alert per event and bar, no alert spam

A small include class that stops indicator alerts from firing on every tick. One alert per event and bar, silent about history on start, popup, push, email or sound, and an optional log of every decision. Comes with a working range break indicator as an example

Rolling VWAP Deviation Regime Filter Rolling VWAP Deviation Regime Filter

A regime-classification oscillator that measures how far, and how persistently, price deviates from a rolling volume-weighted VWAP in standard-deviation units, separating trending conditions from ranging ones.