Clockvane Curfew
- Утилиты
-
AL MOOSAWI ABDULLAH JAFFER BAQER
To trade successfully we need to go through the proven path that others had gone and reached!
Here are 17 quotes from such successful investors:
1- Limit your size in any position so that fear does not become the prevailing instinct guiding your judgment.
Joe Vidich - Версия: 1.0
- Активации: 5
YOUR TRADING HOURS END AT 20:00. THE TRADE YOU OPEN AT 23:40 IS CLOSED WITHIN A SECOND.
Clockvane Curfew is a trading hours filter and session curfew for MetaTrader 5: you set up to two daily trading windows and the weekdays you trade, and any new trade opened outside them, by hand or by another Expert Advisor, is closed at once. Only trades opened after you attached the curfew are ever closed: positions from earlier stay exactly as they are.
Built for traders whose worst trades happen at the wrong hour: the late-night revenge entry, the Asian-session trade on a pair that only moves in London, the Friday-evening position before the weekend gap, the EA that keeps trading into rollover spreads. One promise: your account trades only in the hours you chose. The rule in one line: a trade counts as inside when its entry time (broker server time) falls in an open window on an allowed day; window 07:00-20:00 means a trade opened at 19:58 stays and one opened at 20:05 is closed.
From the Strategy Tester log (EURUSD, 1 June 2026, defaults): the demo opened a buy at 01:00 and a sell at 04:00, both outside 07:00-20:00; each was closed in the same second with the line "opened 01:00, outside your hours (07:00-20:00)" in the journal. The trades opened at 07:00, 10:00, 13:00, 16:00 and 19:00 were left alone.
Works with: manual trades, other Expert Advisors and trade copiers on the same terminal (symbol scope and magic filter decide which trades are watched), hedging and netting accounts, every symbol (forex, gold, indices, crypto), and prop-firm style rules such as no trading over the weekend or around rollover. It never opens a trade on your account and never changes a stop loss or take profit.
Try it free first: run Clockvane Curfew in the Strategy Tester with visual mode on. There it opens a small demo trade every third hour around the clock, so you can watch the 24-hour clock bar and the night trades being closed.
Which clock: everything runs on broker server time, the time shown in Market Watch. The panel prints the server time next to the clock bar, so you can convert your local hours once (for example, server time = your time + 2 hours) and type the windows in server time.
Who this is NOT for: traders who want an entry robot, and anyone who must keep positions opened at night by an EA that is not filtered out (exclude it with the magic filter or the chart symbol scope).
A worked example (default settings)
Window 07:00-20:00, Monday to Friday, no grace. Tuesday 08:15: a manual buy opens, state IN HOURS. 20:00: the pill turns from HOURS OPEN to CURFEW, the banner reads CURFEW - NEW TRADES CLOSE UNTIL 07:00. 20:05: an EA opens a sell; it is closed at once (CURFEW CUT) and the journal says why. The 08:15 buy keeps running through the night: the curfew controls new entries, not trades you opened in your hours. Saturday: the whole clock bar is dark, every new trade is closed until Monday 07:00.
In short
- Up to two trading windows per day; a window may run over midnight (22:00-02:00 belongs to the day it opens).
- Seven weekday switches: Saturday and Sunday off by default.
- Grace in seconds after a window closes, for an order sent at 19:59:58 that fills a moment late.
- Optional: remove pending orders during the curfew, so nothing fills at night behind your back.
- Only trades opened after the curfew was attached are closed; on a netting account only the added volume is cut.
- Alert-only mode: one alert per trade opened outside your hours, nothing sent.
- Panel with real trading data: a 24-hour clock bar for today, the next change with a countdown, trades closed by the curfew with their profit or loss, and every open position marked IN or OUT.
- Not a grid, no martingale, no DLLs, no web requests.
- Tester numbers (June 2026, EURUSD H1, defaults): 168 demo trades, 63 opened outside 07:00-20:00 and closed, 0 failed sends, 0 journal errors.
START HERE
Attach it to one chart, for example EURUSD H1. One copy watches every symbol of the account unless you limit it. Type your window in server time, switch off the days you do not trade, and turn on Algo Trading. To watch first, switch to ALERT ONLY with the panel button. The first setting to change is window 1: narrow it to the session you actually trade (for example 09:00-17:00 for London hours on a GMT+2 server).
How one trade is handled
Reading. On every pass the curfew reads each open position in scope and finds its last entry deal in the account history.
Inside. Entry time inside an open window on an allowed day (or within the grace after it): state IN HOURS, nothing happens.
Outside. Entry time in the curfew: the position is closed at market with the slippage you allow, state CURFEW CUT.
From earlier. A position opened before the curfew was attached is shown but never closed: its state reads OUTSIDE, BEFORE START.
Market closed. Nothing is sent while the symbol session is closed or the quote is stale; the state shows MARKET SHUT and it is tried again when trading opens.
Safety patterns inside
Before any close it checks that Algo Trading is allowed, that the symbol session is open and that the last quote is no older than 5 minutes. Right before each close the position is selected again and its symbol, magic and position id are compared with the plan, so a different position is never closed by mistake. A refused close is retried with a growing pause up to 2 minutes and a different filling type, with one alert after a set number of failures. Which trades it already handled is kept in GlobalVariables whose keys contain the chart symbol, the magic filter and the magic number, so two copies never share a key and a restart does not handle the same trade twice. Wrong time text (for example 25:00 or 7.30) stops the curfew at start with a clear message instead of guessing.
Inputs, every one explained
TRADING HOURS (SERVER TIME)
InpMode = 1. 0 alert only, 1 curfew (close trades opened outside your hours).
InpWin1From = 07:00, InpWin1To = 20:00. Window 1 in HH:MM server time; the same time twice means all day; a closing time earlier than the opening time runs over midnight.
InpWin2From, InpWin2To = empty. Optional second window, for example 13:00-17:00 for a London lunch break split; both empty = off.
InpMon to InpFri = true, InpSat = false, InpSun = false. The days you trade; on a switched-off day every new trade is closed.
InpGraceSec = 0. Seconds after a window closes in which a new trade is still accepted.
InpDeletePending = false. Remove pending orders in scope during the curfew.
EXECUTION
InpSlippagePts = 30. Allowed slippage for a curfew close, in points.
InpFailAlertAt = 3. One alert after this many failed attempts.
FILTER - WHICH TRADES ARE COUNTED
InpSymbolScope = all symbols or the chart symbol only. InpMagicFilter = any magic, only manual trades (magic 0), or only the magic number InpMagic.
ALERTS
InpAlertPopup = true. InpAlertPush = false (push to the MetaTrader app on your phone).
PANEL
ShowPanel = true. PanelX = 12, PanelY = 15, PanelFontSize = 9, MaxTableRows = 6, MaxHistoryRows = 4. The MOVE button drags the panel; on a short chart it drops its least important rows first.
STRATEGY TESTER DEMO
InpTesterDemo = true. Strategy Tester only: Monday to Friday one demo trade every third hour around the clock (01, 04, 07 ... 22) with a stop 1.5 ATR and a take profit 2 ATR away, at most 5 open, margin checked x 1.5, closed after 1 day, stopped after a 20 percent balance loss. This code never runs on a live or demo chart.
The panel
TODAY'S CLOCK (SERVER TIME): 24 hour blocks, teal for trading hours, dark for curfew, the current hour amber (open) or red (curfew), with the server time printed beside it. CURFEW PLAN: trading hours, trading days, when the curfew starts or the hours open with a countdown, trades closed by the curfew with their profit or loss, open positions and profit, pending orders, mode and grace, last action, Algo Trading, failed sends and totals. OPEN POSITIONS, NEWEST FIRST: symbol, side, lots, entry time, WINDOW (IN or OUT), profit and state, with a red edge on rows being closed. ACTION HISTORY lists every close and every curfew start and end with server time. QUICK CONTROLS: ARMED or PAUSED, the mode button and CHECK NOW. The right side of the chart stays clear.
Common questions
Does it close my open trades when the curfew starts? No. It judges a trade by its entry time. A trade opened in your hours keeps running at night; pair it with your own stop or a time-based exit if you want it closed.
Does it open trades by itself? No. On a live or demo chart it only closes trades opened outside your hours. Demo trades exist only inside the Strategy Tester.
Will it close my trades from yesterday? Never. Only trades opened after the curfew was attached can be closed.
What about daylight saving time? Windows are in server time; if your broker moves its clock, check the server time on the panel and adjust the window once.
What it cannot do
It cannot stop the broker from filling an order: the trade outside your hours is opened and then closed, so you pay its spread and commission. For no fill at all at night, also turn on InpDeletePending. It only works while it runs: keep the terminal on, for example on a VPS.
What was and was not tested
Tested in the Strategy Tester on a hedging account, 1 to 30 June 2026, 1-minute OHLC, H1, deposit 10000, leverage 100, with no journal error and no failed send. EURUSD defaults: 168 demo trades, 63 opened outside 07:00-20:00 and closed. XAUUSD alert only with windows 08:00-12:00 and 21:30-02:00 (over midnight), Wednesday off and 600 seconds grace: 155 demo trades, 114 alerts, nothing sent. On a demo chart the panel ran in alert-only mode on a Saturday beside 4 EURUSD positions from earlier and left them untouched.
Not tested at the time of writing: real closes on a live or demo broker, a netting account, retries after a broker refusal, pending order removal, chart symbol scope, magic filters, pop-up and push alerts and a terminal restart. These paths exist in the code and are described by design. Please try them on a demo account with your own broker first.
Try it in the Strategy Tester
Choose Clockvane Curfew, EURUSD or XAUUSD, H1, any recent month, visual mode, and press Start. Watch the clock bar turn dark at 20:00 and the 01:00 trade close.
If the curfew kept a night trade off your account, or you think it should treat a case differently, an honest review on the product page helps other traders decide and tells me what to improve next.
