Timed Order Expert Advisor

What is Timed Order EA?

Timed Order is a simple MetaTrader/cTrader expert advisor that lets you execute a trade at a specific time. The EA can be used to schedule a trade during the weekend to be executed when the market opens. It can also be used to set up a trade that will be executed when you are away from the platform. It is important to understand that Timed Order is not a fully automatic trading robot — you have to set the date and time of the trade, set an appropriate stop-loss and take-profit, define maximum deviation parameters, and so on. However, its highly customizable settings allow creation of nearly any kind of a trading order. This EA supports risk-based position sizing in addition to the usual fixed position size. It is available for the following trading platforms: MT4, MT5, and cTrader.

Operation

Timed Order opens a single trade at the time specified by the trader. The time can be given either as the server time or as the local time. The Timed Order EA supports the following trade types:

  • Buy
  • Sell
  • Buy Limit
  • Buy Stop
  • Sell Limit
  • Sell Stop
  • Buy Stop Limit (MT5 only)
  • Sell Stop Limit (MT5 only)

You can set up a stop-loss and a take-profit for the order you are planning to open. There are four types of SL/TP supported by the expert advisor:

  • Price level — the specific price. If you are setting this for a market order (Buy/Sell), the order may fail if the price moves beyond the SL/TP set as a price level.
  • Distance — SL/TP as distance in points. Simple and more or less guaranteed.
  • ATR — a multiple of the ATR indicator's value. You control the multiplier, the ATR period, and the ATR timeframe.
  • Spreads — a multiple of the currency pair's spread at the time of execution.

The EA supports setting the Entry level. For pending orders, it is obligatory. For market orders, it can be used together with the MaxDifference input parameter to avoid order execution at an unfavorable rate.

The expiration parameter can be set up for pending orders for the order to expire at the set time.

You can also control how many attempts the platform will go with to execute the order should it encounter some error.

Another useful option is to set the maximum allowed spread to avoid executing the trade when spreads are too wide.

A position sizing function can be enabled to calculate the trade size based on your risk tolerance and stop-loss. Alternatively, you can set a fixed position size.

You can configure the alerts to be triggered separately in case of a failure and in case of a success.

Example trades

MetaTrader

Here is how the EA looks when you attach it to a chart in MetaTrader 5. This instance was set up to open a Buy order with a fixed stop-loss level and ATR-based take-profit:

A Timed Order set up in MetaTrader 5 platform

cTrader

And here is an example trade setup for cTrader. The scheduled trade will be a Sell with a fixed-distance stop-loss and take-profit:

A Timed Order set up in cTrader platform

No backtesting

Due to the nature of the Time Order EA, there are no backtesting results for it.

Input parameters

Trading

  • OrderTime — the date and time when the order should be created. In cTrader, there are five separate parameters instead: year, month, day, hour, and minute.
  • OrderType (default = Buy) — one of the following: Buy, Sell, Buy Limit, Buy Stop, Sell Limit, Sell Stop, Buy Stop Limit, Sell Stop Limit.
  • Entry (default = 0) — the entry price for pending orders; the desired price for market orders.
  • StopPrice (default = 0) — the stop price for Stop Limit orders. Only in MT5.
  • SLType (default = Price level) — one of the following: price level, distance, ATR, spreads.
  • StopLoss (default = 0) — the stop-loss value based on the chosen type. For the price level — the specific price. For the distance — the number of points. For the ATR — the multiplier. For the spreads — the multiplier as well.
  • TPType (default = Price level) — one of the following: price level, distance, ATR, spreads.
  • TakeProfit (default = 0) — the take-profit value based on the chosen type. For the price level — the specific price. For the distance — the number of points. For the ATR — the multiplier. For the spreads — the multiplier as well.
  • TimeType (default = Server) — the type of time you set via OrderTime. It can be either your platform's local time or the server's time.

Control

  • Expires (default = 0) — the expiry time for pending orders.
  • Retries (default = 10) — how many attempts to perform before giving up?
  • MaxDifference (default = 0) — if OrderType is set to Buy or Sell and some non-zero Entry is given, the EA will only execute the order if the difference between the current price and the Entry value is less or equal to the MaxDifference value.
  • MaxSpread (default = 3) — if the spread at order time is greater than this value, the order is not placed.
  • Slippage (default = 30) — the maximum tolerable slippage in points.
  • ATR_Timeframe (default = PERIOD_CURRENT) — the timeframe for the ATR indicator. It is used only if you set either SLType or TPType to ATR.
  • ATR_Period (default = 0) — the ATR indicator's period. It is used only if you set either SLType or TPType to ATR.

Position sizing

  • CalculatePositionSize (default = false) — if true, the position size will be calculated based on the given risk and stop-loss.
  • FixedPositionSize (default = 0.01) — the fixed position size to use if CalculatePositionSize = false.
  • Risk (default = 1) — the risk tolerance in percentage of account balance/equity. Works only if CalculatePositionSize = true. This input parameter is ignored if UseMoneyInsteadOfPercentage is set to true.
  • MoneyRisk (default = 0) — the risk tolerance in account currency. Works only if CalculatePositionSize = true. Requires UseMoneyInsteadOfPercentage set to true.
  • UseMoneyInsteadOfPercentage (default = false) — if true, the position size is calculated based on risk amount given in account currency (MoneyRisk) instead of balance/equity percentage risk (Risk). Works only if CalculatePositionSize = true.
  • UseEquityInsteadOfBalance (default = false) — if true, the position size is calculated based on account equity instead of balance. Works only if CalculatePositionSize = true. Ignored if UseMoneyInsteadOfPercentage = true.
  • FixedBalance (default = 0) — if set to a non-zero value, it is used instead of account balance/equity for position size calculation. Works only if CalculatePositionSize = true.

Alerts

  • AlertsOnSuccess (default = false) — if true, the EA will issue an alert when the order is placed successfully.
  • AlertsOnFailure (default = false) — if true, the EA will issue an alert if it fails to create the order.
  • EnableNativeAlerts (default = false) — if true, the EA will use MetaTrader's native pop-up alerts.
  • EnableEmailAlerts (default = false) — if true, the EA will use MetaTrader's email alerts. Email should be properly configured in MetaTrader via Tools->Options->Email.
  • EnablePushAlerts (default = false) — if true, the EA will use MetaTrader's push notification alerts. Notifications should be properly configured in MetaTrader via Tools->Options->Notifications.

Miscellaneous

  • Magic (default = 20220913) — the magic number for orders to filter positions opened by this EA. Not present in cTrader.
  • OrderCommentary (default = "TimedOrder") — the commentary for positions opened by this EA.
  • Silent (default = false) — if true, the EA won't output any information in the chart commentary field.
  • Logging (default = true) — if true, the EA will log its messages into a log file. The file name starts with "TO-Log-<Trading_Instrument>". Not present in cTrader.

Downloads (ver. 1.00, 2022-09-23)

MetaTrader 4

MetaTrader 5

cTrader

You can open a trading account with any of the MT4 Forex brokers to freely use the expert advisor for MetaTrader 4 presented here. If you want to use an MT5 version of the EA, you would need to open an account with a broker that offers MetaTrader 5. Please see our list of cTrader Forex brokers if you would rather use the cTrader version of this expert advisor.

Discussion

Warning! Before you ask basic questions regarding installation of the expert advisors, please read this MT4 Expert Advisors Tutorial to get the elementary knowledge on handling them.

Do you have your own trading results or any other remarks regarding this expert advisor? Discuss Timed Order EA with other traders and MQL programmers on the experts forums.

Changelog

1.00 — 2022-09-23

  • First release of the Timed Order expert advisor.

© 2005–2022

EarnForex.com

Design — Mart Studio

Forex trading bears intrinsic risks of loss. You must understand that Forex trading, while potentially profitable, can make you lose your money. Never trade with the money that you cannot afford to lose! Trading with leverage can wipe your account even faster.

CFDs are leveraged products and as such loses may be more than the initial invested capital. Trading in CFDs carry a high level of risk thus may not be appropriate for all investors.