Home / Expert Advisors / MA Cross

MA Cross

Enters when a fast exponential average crosses a slow one inside its own entry window, and leaves at the first candle that closes against the position, or at the ATR stop or target. Test it on a demo account first.

DRF_MA_Cross_EA · version 1.00 · Trend following

Risk. Trading carries a high level of risk and you can lose more than you expected. No result is promised. Read the Risk Disclosure.

Test it on a demo account first. When everything works as you expect, use it on a real account.

Used by the author on XAUUSD (gold). It works on any symbol.

The problem it addresses

A moving-average cross is the most common trend rule, yet there is no agreed way to exit it. A simple, written exit rule makes it easy to judge and to compare with other rules.

What it does

Enters when the fast exponential average (8) crosses the slow one (21), inside its own entry window (8 to 18 server time by default).

It leaves at the first closed candle that goes against the position, or at the ATR stop (1.6) or target (2.4). Because the first opposite candle closes the trade, most trades are short.

It opens and closes its own trades, one position at a time, with the magic number 26110004.

Who it is for: Traders who want a very simple trend rule with a clear exit, and who will test it on a demo account first.

Symbols and timeframes: Written to run on any symbol that allows trading; stops and lots adapt through the ATR. It reads closed bars of the chart's timeframe.

Real accounts: on a demo account it trades at once; on any other account it sends no order until you tick the input "I confirm this is a real account I want to trade". Test the EA on a demo account first. When everything works as you expect, use it on a real account.

The idea behind it

The simplest trend follower of the programme, and the benchmark that the other rules are compared with.

History

Version 1.00 is the first public version, built from the specification of the earlier Gold MA Cross tool on the shared DRF strategy base, with ATR distances and a risk-based lot. Mechanics were checked on a demo account and in the Strategy Tester. This page makes no claim about results.

Indicators used

What is included

What is not included

How it works

  1. On every new closed candle it checks whether the fast average has crossed the slow one.
  2. A cross inside the entry window is an entry signal. The general trading hours, the spread, the news and the daily loss must also allow it.
  3. It works out the lot from your risk percent and the stop distance and sends the order with a stop and a target.
  4. On every new closed candle the exit runs before the entry: if the candle closed against the position, the position is closed.

What you need

How to install and test it

  1. Download the ZIP below and unzip it. It holds the Expert Advisor file (.ex5), a settings preset (.set) with an empty DRF Key, and INSTALL.txt with these steps.
  2. In MetaTrader 5 choose File > Open Data Folder, open MQL5 > Experts, and copy the .ex5 file there. Back in MetaTrader, right-click Expert Advisors in the Navigator and choose Refresh.
  3. Tools > Options > Expert Advisors: tick "Allow algorithmic trading" and "Allow WebRequest for listed URL", then add https://sync.donaldsonrf.com to the list. Nothing else is needed. Press OK.
  4. Press the Algo Trading button in the top toolbar so it turns green.
  5. Drag the Expert Advisor from the Navigator onto a chart. On the Common tab tick "Allow Algo Trading". On the Inputs tab type your DRF Key in the first input (optionally load the .set preset first).
  6. Within about a minute the chart panel shows the state of your licence. If it says PAUSED, the panel tells you why. Test the EA on a demo account first. When everything works as you expect, use it on a real account.
  7. The first time, attach it to a chart of a DEMO account. Orders are sent without any extra tick on a demo account.
  8. Watch the panel on the chart. It shows the licence state, the account type, how many positions this EA has open and why it is not trading, if it is not.
  9. When everything works as you expect on the demo account, you can use it on a real account: on the Inputs tab, tick "I confirm this is a real account I want to trade". Without the tick the EA sends no order on a real account.

The key: every DRF Expert Advisor needs a DRF Key, with a 7-day free trial. Every plan, and the trial, unlocks the whole Expert Advisor.

Safety behaviour

What can go wrong

The panel says PAUSED: no DRF Key entered.
Type your DRF Key in the first input (Inputs tab). The key looks like DRF-XXXXX-XXXXX-XXXXX.
The panel says the key could not be checked.
Check that https://sync.donaldsonrf.com is in Tools > Options > Expert Advisors > "Allow WebRequest for listed URL", that the terminal is online and that the key has not expired. Error 4014 in the Experts log means the address is missing from the list.
The panel says "REAL account: orders are blocked".
This is the safety lock. On any account that is not a demo, tick "I confirm this is a real account I want to trade" on the Inputs tab, after you have tested the EA on a demo account.
The EA does not trade and I do not know why.
Read the status line on the panel. The usual reasons are: outside the trading hours, important news close by, a wide spread, a position already open, the daily loss stop reached, or no setup yet. The rules only act on closed candles, so a setup can take hours or days to appear.
The panel says the chart is refused.
The reason is written on the panel and in the Experts log. Common causes: trading is disabled for the symbol, the symbol has too little history for the indicators (open the chart, scroll back or press Home to load history), a period input is nonsense, or two timeframes do not make sense together.
The panel says the magic number is outside the registered block.
Set "Magic number" back to its default or to a number between 26110001 and 26119999.
It says the smallest lot would risk too much.
The account is too small for the stop distance on this symbol, or the risk percent is too low for the smallest lot. Lower the stop distance, choose another symbol, or raise the risk percent only if you accept that risk.
I do not see any panel or object on the chart.
Press the Algo Trading button so it turns green, tick "Allow Algo Trading" on the Common tab, and look for the smiling face in the top right corner of the chart. Check the Experts tab of the Toolbox for messages.
The Strategy Tester behaves differently from a live chart.
The tester has no economic calendar, so the news filter is not applied there; the EA writes one line in the log to say so. Use the Tester build only in the tester, and do not read a tester run as a promise of any result.

Manual: every setting in plain language

Allow https://sync.donaldsonrf.com in MetaTrader's WebRequest list and enter your DRF Key in the first input.

DRF Key

DRF Key (default: empty)
Your DRF Key (it looks like DRF-XXXXX-XXXXX-XXXXX). Leave it empty and the EA stays paused and says so on the chart. A paused or lapsed key stops NEW orders only.

Strategy

Fast average period (default: 8)
The number of candles of the fast exponential average.
Slow average period (default: 21)
The number of candles of the slow exponential average. A trade is considered when the fast one crosses the slow one.
Entry window starts at (hour, 0 to 23, server time) (default: 8)
First hour in which this EA may open a trade, in your broker's server time. This window is separate from the general trading hours in the Filters group; both must allow the trade.
Entry window ends at (hour, 0 to 23, server time) (default: 18)
The hour at which the entry window ends, in server time.
Close at the first candle that closes against the position (default: on)
When on, the position is closed at the first closed candle that goes against it, even before the stop or the target. This makes most trades short.

Risk

Risk per trade (percent of the balance) (default: 1.0)
How much of the account balance one trade may lose if its stop is hit. The lot size is worked out from this and from the stop distance. If even the smallest lot would risk more than 1.5 times this wish, the EA does not trade and says so on the chart.
Stop distance (ATR multiples) (default: 1.6)
How far the stop loss is placed from the entry, measured in ATR (the average size of a recent candle on this symbol), so it adapts to the symbol and to the market of the day.
Target distance (ATR multiples) (default: 2.4)
How far the take profit is placed from the entry, in ATR multiples.
ATR period (default: 14)
The number of candles the ATR averages. 14 is the usual choice.

Filters

Wait while the spread is wider than this many times its usual size (0 = off) (default: 4.0)
New trades wait while the spread is unusually wide. "Usual" is the symbol's own typical spread, so there is no fixed number to adjust per symbol. 0 switches the check off.
Pause new trades around high-importance news for the symbol's currencies (default: on)
No new trade shortly before and after important news for the currencies of the symbol (it uses the MetaTrader economic calendar). The Strategy Tester has no calendar, so in the tester this filter is not applied and the EA says so.
News: stay out this many minutes before (default: 20)
Minutes before an important news event during which no new trade is opened.
News: stay out this many minutes after (default: 20)
Minutes after an important news event during which no new trade is opened.
Open new trades only inside the hours below (server time) (default: on)
When on, new trades open only between the two hours below. Trades already open are not closed by this.
Trading hours start at (hour, 0 to 23, server time) (default: 7)
First hour of the trading window, in your broker's server time (not your local time).
Trading hours end at (hour, 0 to 23, server time) (default: 21)
The hour at which the trading window ends, in your broker's server time.
Stop opening new trades after a daily loss of this many percent (0 = off) (default: 0.0)
If the losses of today reach this percentage of the balance, no new trade is opened until the next server day. 0 switches it off (the default).
Most positions open at the same time (this EA, this symbol) (default: 1)
How many positions this EA may keep open on this symbol at once. The default is 1.

Account

I confirm this is a real account I want to trade (default: off)
Safety lock. On a demo account the EA trades without it. On any other account the EA does NOT send orders until you tick this box; the chart says "REAL account: orders are blocked". Tick it only after you have tested on a demo account and everything works as you expect.
Magic number (unique for each EA; change it only to run two copies on one symbol) (default: 26110004)
The number written on every order of this EA; the EA recognises its own positions by it. Keep the default unless you run two copies on one symbol. It must stay inside the block 26110001 to 26119999, otherwise the EA refuses to trade and says so on the chart.

Download

DRF_MA_Cross_EA_v1-00.zip (80 KB) ↓

The file runs only with a valid DRF Key.

Brokers and hosting I use

I recommend only what I use. I have been a client of IC Markets, IC Trading, FTMO and IONOS for many years.

These are affiliate links. If you open an account or buy through them I may be paid a commission, at no extra cost to you. Read the Affiliate Disclosure and the full page. Trading carries a high level of risk; check that a company is authorised in your country before you use it.

Frequently Asked Questions

There are two time windows. Which one counts?
Both. The entry window (Strategy group) says when this EA may enter; the trading hours (Filters group) are the general hours for new trades. A trade needs both to allow it.
Why are most trades short?
The position is closed at the first candle that closes against it. You can switch that exit off, and then only the stop and the target end the trade.
How is it different from the Pure Trend Runner?
Same 8 and 21 cross. The MA Cross adds the early exit on an opposite candle and an entry window, and does not need rising volatility. Running both on one symbol doubles the same bet.
Does it trade on a real account straight away?
No. On a real account it sends no order until you tick the confirmation input.
Will it make a profit?
No result is promised. Read the Risk Disclosure.
Do I need a key to run it?
Yes. Every DRF Expert Advisor needs a DRF Key, with a 7-day free trial. See the DRF Key page.
Does it promise a result?
No. Read the Risk Disclosure. Test on a demo account first; when everything works as you expect, use it on a real account.
Running into a technical issue or something that doesn't work right on this page? Please let us know straight away via our Contact page — that's how we find out what's broken and get it fixed.