Home / Expert Advisors / Dual EMA

Dual EMA

Trades the rejection of a moving average by a candle with a long wick, with a higher-timeframe trend filter. On first attach it only sends alerts; you switch it to Trade yourself. Test it on a demo account first.

DRF_Dual_EMA_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 price that touches a key average and is pushed back shows a clear rejection, but spotting it on every chart by eye is tiring, and entering late changes the risk.

What it does

Two ways to enter on the rejection of a moving average by a candle with a long wick. A continuation entry: a pull-back rejected at the fast average (50) while the RSI is near the middle. An exhaustion entry: a rejection at the slow average (200) while the RSI is at an extreme.

An optional filter lets a trade go only in the direction of the trend on a higher timeframe (1 hour by default, 50-period average).

Stop and target are ATR multiples (1.5 and 2.5). An optional trailing stop and an optional break-even can be switched on. After a number of losing trades in one day (2 by default) it stops opening new ones.

On first attach the mode is "Alerts only": it sends alerts and opens nothing. Set the mode to Trade to let it open trades. One position at a time, magic number 26110003.

Who it is for: Traders who like entries at a key average with a higher-timeframe filter, and who will first watch the alerts and then test on a demo account.

Symbols and timeframes: Written to run on any symbol that allows trading; stops and lots adapt through the ATR. The rules read the timeframe you choose (30 minutes by default); the higher timeframe must be longer than that one, otherwise the chart is refused.

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

Trade the rejection of a key average, with the trend of a higher timeframe.

History

Version 1.00 is the first public version, built from the specification of the earlier Gold Dual EMA tool on the shared DRF strategy base. It is NOT behaviour-identical to that earlier tool: its cash money rules are now 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 on the chosen timeframe it looks for a candle whose wick is long compared with its body and that was rejected at the fast (continuation) or slow (exhaustion) average.
  2. The RSI must be in the band for that entry type, the market must not be too quiet, and the higher-timeframe trend must agree if the filter is on.
  3. In "Alerts only" mode it sends an alert. In "Trade" mode, if the filters allow it, it sends the order with a stop and a target.
  4. If the trailing stop or the break-even are on, they move the stop of an open trade. After the set number of losing trades in a day it stops opening new ones until the next day.

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

What to do on a signal (default: Alerts only)
"Alerts only" (the default on first attach) sends an alert and opens nothing. "Trade" opens the trade. Switch to Trade only after you have watched the alerts on a demo account.
Timeframe the rules read (default: 30 minutes)
The candle size on which the rules are evaluated.
Use the continuation entry (pull-back rejected at the fast average) (default: on)
Switch on the entry that follows the trend: a pull-back rejected at the fast average by a candle with a long wick, while the RSI is near the middle.
Fast average (continuation) (default: 50)
The period of the average used by the continuation entry (default 50).
Use the exhaustion entry (rejection at the slow average) (default: on)
Switch on the entry against an overstretched move: a rejection at the slow average by a candle with a long wick, while the RSI is at an extreme.
Slow average (exhaustion) (default: 200)
The period of the average used by the exhaustion entry (default 200).
The wick must be at least this many times the body (default: 2.0)
How long the rejection wick of the candle must be compared with its body for the rejection to count.
RSI period (default: 14)
The number of candles of the RSI indicator.
Continuation: RSI at least (default: 48.0)
Lower end of the RSI band in which the continuation entry is allowed.
Continuation: RSI at most (default: 52.0)
Upper end of the RSI band in which the continuation entry is allowed.
Exhaustion buy: RSI at or below (default: 30.0)
A rejection at the slow average counts as a buy setup only when the RSI is at or below this value.
Exhaustion sell: RSI at or above (default: 70.0)
A rejection at the slow average counts as a sell setup only when the RSI is at or above this value.
Skip quiet markets: the ATR must be at least this fraction of its 100-bar average (0 = off) (default: 0.8)
No trade while the market is unusually quiet: the current ATR must be at least this fraction of its average over the last 100 candles. 0 switches the check off.
Only trade with the higher-timeframe trend (default: on)
When on, a trade must agree with the direction of the trend on the higher timeframe below.
Higher timeframe (must be longer than the one above) (default: 1 hour)
The larger candle size used for the trend filter. It must be longer than the timeframe the rules read, otherwise the chart is refused.
Higher-timeframe average period (default: 50)
The period of the exponential average on the higher timeframe. The last closed candle of the higher timeframe is compared with it.

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.5)
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.5)
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.
Trailing stop (default: off)
Off by default. When on, the stop follows the best price once the trade is in profit.
Trailing stop starts when the profit reaches (ATR multiples) (default: 1.5)
The profit, in ATR multiples, at which the trailing stop begins.
Trailing stop follows the best price at this distance (ATR multiples) (default: 1.0)
How far behind the best price the trailing stop is kept, in ATR multiples.
Break-even (default: off)
When on, the stop is moved to the entry price once the trade is in profit by the amount below.
Break-even: move the stop to the entry when the profit reaches (ATR multiples) (default: 1.0)
The profit, in ATR multiples, at which the stop is moved to the entry.
Stop opening new trades after this many losing trades in a day (0 = off) (default: 2)
After this number of losing trades in one day, no new trade is opened until the next day. 0 switches it off.

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: 8)
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: 18)
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: 26110003)
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_Dual_EMA_EA_v1-00.zip (90 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

Why does it only send alerts?
On first attach the mode is "Alerts only", so you can watch what it would do. Set "What to do on a signal" to Trade to let it open trades.
Does it trade on a real account straight away, once the mode is Trade?
No. On a real account it sends no order until you also tick the confirmation input.
Which entry is which?
The continuation entry follows the trend after a pull-back to the 50 average. The exhaustion entry trades against an overstretched move at the 200 average. You can switch each off.
The chart is refused. Why?
The higher timeframe must be longer than the timeframe the rules read, and there must be enough history. The panel gives the reason.
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.