Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

Metatrader 5 Script | SessionEdgeTester - does a time-of-day rule beat spread and swap? | MetaTrader Tool

RobotFX curates the best open-source MetaTrader code to inspire your trading automation.

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.Image for SessionEdgeTester - does a time-of-day rule beat spread and swap?

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

Classic MACD strategy made fully automatic – the MACD Expert Advisor for MT4 handles it all. Check it out.

  • 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.

Complement community code with advanced automation from RobotFX.

78980

Best MetaTrader Indicators + Profitable Expert Advisors