Skip to content
FXNook HubBeta

Alex / Time Based Entry EA for MT4

MetaTrader 4Expert AdvisorMITCompiled · build 2425
AlexFirst version.build 2425v1.05 hours ago1 version
  • FXN_TimeEntry.mq4First version.16 KB
  • FXN_TimeEntry.ex4Compiled by the Lab with MetaEditor build 242534 KB
README

Overview

Free time-based entry EA: opens one trade a day at a set server time, fixed direction or by previous candle or EMA, with stop, target and close time.

FXN Time Entry is a free, open-source Expert Advisor for MetaTrader 4 and MetaTrader 5 that opens one trade a day at a time you choose. It is built for time-of-day ideas such as the London or New York open: you set the time, the direction rule, the stop and target, and the close time.

How it works

  • At the entry time (server time) the EA opens one market trade; if the spread is too wide or no tick arrives, it retries during the entry window.
  • Direction rules: always buy, always sell, with the previous candle, against it, or by the last close vs an EMA, all on the signal timeframe.
  • A flat previous candle (or a close equal to the EMA) means no trade that day.
  • Stop and target: fixed points, or ATR multiples of the signal timeframe. A target of 0 means no take profit.
  • Close time: the trade is closed at the set time. If the close time is earlier than the entry time, it is the next day.
  • One trade per day, also after a restart, and none while the previous trade is still open.
  • Lot size: risk mode sizes the lot from the stop distance, tick value and tick size so a stop-out costs the set % of balance, rounded down to the lot step. Below the minimum lot the trade is skipped with a message.

Inputs

InputDefaultWhat it does
Entry hour / minute / window8 / 0 / 5Entry time (server) and minutes a late entry is allowed
Direction rulePrevious candleBuy, sell, previous candle, opposite candle or EMA
Signal timeframeH1Timeframe for the candle, EMA and ATR
EMA period50Used by the EMA rule
Stop/target modeATRFixed points or ATR multiples
Stop / target (points)300 / 600Used in points mode (target 0 = none)
ATR period / stop / target14 / 1.5 / 2.0ATR mode: stop and target as ATR multiples (target 0 = none)
Use close time / hour / minutetrue / 20 / 0Close the trade at this time
Monday ... FridaytrueDays the EA may trade
Lot mode / Fixed lot / Risk %Risk / 0.10 / 1.0Fixed lot, or a lot sized so a stop-out costs this % of balance
Magic number510501Marks this EA's trades; it only manages its own
Max spread / slippage (points)30 / 10Entry spread filter (0 = off) and allowed deviation
Order commentFXN Time EntryComment on the orders

How to use it

  1. Copy FXN_TimeEntry.mq4 to MQL4/Experts (MT4) or FXN_TimeEntry.mq5 to MQL5/Experts (MT5) via File > Open Data Folder, then refresh the Navigator.
  2. Attach it to a chart and allow algo trading (toolbar button and the EA's own setting).
  3. Any chart timeframe works. Find the broker server offset and test one session open at a time, such as London with the previous H1 candle rule.
  4. Test in the Strategy Tester and on a demo account before any live use.

Good to know

  • All times are broker server time. Check daylight saving changes, which shift sessions by an hour twice a year.
  • Spreads widen around rollover and some opens; the spread filter delays entry within the window.
  • A close time on the weekend executes at the first tick after the reopen.
  • In the MT4 Strategy Tester, download history for the signal timeframe too, or set it to the chart timeframe.
  • A time of day has no edge on its own; this is a tool to test and run your idea.

Trading carries risk. Test on a demo account first; past results do not predict future results.

At a glance

What it is
A free Expert Advisor for MetaTrader 4, written in MQL4.
What it does
Free time-based entry EA: opens one trade a day at a set server time, fixed direction or by previous candle or EMA, with stop, target and close time.
Shared by
Alex
Licence
MIT
Version
1.0 (1 Dec 2026)
Settings
33 inputs
Lab check
Compiled with MetaEditor build 2425 for MT4 on 1 Dec 2026: 0 errors, 0 warnings.
Price
Free to download

Settings read from the code

InputTypeDefaultNote
InpHdrEntrystring=== Entry (server time) ======== Entry (server time) =====
InpEntryHourint8Entry hour (0-23, server time)
InpEntryMinuteint0Entry minute (0-59)
InpEntryWindowMinint5Minutes after the entry time in which a late entry is still allowed
InpDirectionENUM_FXN_DIRFXN_DIR_CANDLEDirection rule
InpSignalTfENUM_TIMEFRAMESPERIOD_H1Timeframe for the previous candle, the EMA and the ATR
InpEmaPeriodint50EMA period (direction rule = EMA)
InpHdrStopAndTargetstring=== Stop and target ======== Stop and target =====
InpDistModeENUM_FXN_DISTFXN_DIST_ATRStop and target in fixed points or ATR multiples
InpStopPointsint300Stop loss in points (fixed points mode)
InpTargetPointsint600Take profit in points (fixed points mode, 0 = none)
InpAtrPeriodint14ATR period (ATR mode)
InpStopAtrdouble1.5Stop loss = ATR x this (ATR mode)
InpTargetAtrdouble2.0Take profit = ATR x this (ATR mode, 0 = none)
InpHdrExitstring=== Exit ======== Exit =====
InpUseCloseTimebooltrueClose the trade at a set time
InpCloseHourint20Close hour, server time (earlier than the entry time = next day)
InpCloseMinuteint0Close minute (0-59)
InpHdrTradingDaysstring=== Trading days ======== Trading days =====
InpMondaybooltrueTrade on Monday
InpTuesdaybooltrueTrade on Tuesday
InpWednesdaybooltrueTrade on Wednesday
InpThursdaybooltrueTrade on Thursday
InpFridaybooltrueTrade on Friday
InpHdrPositionSizestring=== Position size ======== Position size =====
InpLotModeENUM_FXN_LOTSFXN_LOTS_RISKLot sizing mode
InpFixedLotdouble0.10Fixed lot (used when mode = Fixed lot)
InpRiskPercentdouble1.0Risk per trade in % of balance (used when mode = Risk %)
InpHdrExecutionstring=== Execution ======== Execution =====
InpMagicint510501Magic number (the EA only manages its own trades)
InpMaxSpreadPointsint30Max spread in points at entry (0 = no limit)
InpSlippagePointsint10Max slippage (deviation) in points
InpCommentstringFXN Time EntryOrder comment

How to use it

  1. Download the compiled file (or the source and compile it in MetaEditor).
  2. Put it in MetaTrader: File → Open Data Folder → MQL4 → Experts, then refresh the Navigator.
  3. Test it on a demo account before any real money.
  4. Want changes? Open a copy in your Lab and ask for them in plain words.