Auto Close Trades by Time and Magic Number MT5
- ユーティリティ
- バージョン: 1.0
- アクティベーション: 5
Auto Close Trades by Time and Magic Number closes the trades of the magic numbers you choose at the times you set: open positions, in profit or in loss, and pending orders. One line per close, for example 05:00=105.
It opens no trades and gives no signals. Put it on any spare chart and it watches the whole account, next to your Expert Advisors, your trade copier or your manual trading.
One line per close
Write the close times in a single input, separated by semicolons:
- 05:00=105 — at 05:00 it closes everything with magic number 105.
- 14:30=106,107 — several magic numbers in one line.
- Fri 21:50=* — every trade of the account, on Fridays only, before the weekend.
- Mon-Thu 23:00=0 — magic number 0 = the trades you opened by hand.
From one line to as many as you need: 24 lines can close 24 copies of an EA, each one at the end of its own hour.
Typical uses
- An EA that trades one session and has to be flat when the session ends.
- The same EA on several charts, each copy with its own magic number and its own closing time.
- Flat before the weekend, before the daily rollover or before the market closes.
- Pending orders that must not stay alive after a certain time.
Closes that get done
If the broker rejects a close (requote, off quotes, market closed), the EA tries again until nothing is left, for up to 60 minutes, and writes every close in the Experts tab with the ticket, symbol, lots, magic number and profit. Each time runs once a day. If the terminal was off or disconnected at the time, the close still runs when it comes back within the minutes you set. A close missed by more than that is skipped, so nothing is closed hours later by surprise.
The schedule on the chart
The chart shows the clock in use, each close line, the next time it will run and how many positions and orders it would close right now. A warning appears if Algo Trading is off, because then nothing can be closed.
Inputs
- Close times, e.g. 05:00=105; Fri 21:50=* — the close lines: [days] HH:MM = magic numbers, or * for all. Days as Mon-Fri, Mon,Wed,Fri or Sat-Mon; without days, every day.
- What to close — positions and pending orders, positions only, or pending orders only.
- Clock for the close times — the broker's server time (the time of the chart and Market Watch) or this computer's clock.
- Only these symbols, e.g. XAUUSD,EURUSD (empty=all) — limits the closes to some symbols.
- Still close if the time was missed by up to N minutes — how late a missed close may still run (5 by default).
- Max slippage in points — the deviation accepted when closing at market.
- Show the schedule on the chart — the status text on the chart.
Good to know
- Each EA you want to close at its own time needs its own magic number. Most EAs have a magic number input.
- On a netting account there is one position per symbol, so two EAs on the same symbol share it. To close them at different times, use a hedging account.
- Algo Trading must be on and the terminal must be running at the close times. A VPS is the usual choice.
- The Strategy Tester runs one Expert Advisor at a time, so there it cannot close the trades of another EA. To show how it works, in the tester it opens a minimum position for each close line and closes it at its time.
FAQ
Does it open trades? No. Only in the Strategy Tester, as a demonstration.
Which time does it use? The broker's server time by default, the same time you see on the chart and in Market Watch. You can switch to this computer's clock.
Does it close trades opened by hand? Yes, with magic number 0, or every trade with *.
What happens when the clocks change? The server time of many brokers moves one hour with daylight saving time. If your close times are tied to a session, check them after the change.
Which symbols? Any symbol of your broker: forex, gold, indices, crypto, stocks.
auto close, close all trades, close by time, close by magic number, time exit, scheduled close, close all trades at a time, close positions, delete pending orders, Friday close, session close, trade manager, utility, MT5
