Top Menu

Feedburner

Right-Side Top Menu

Backtesting Reversible Expert Advisor Based on Trend Persistence

May 7, 2013

Reading about such an interesting concept as Hurst exponent did not go without leaving a trace in my trader’s mind. Is it really so that we cannot use any information about the recent chart’s tendency to keep repeating previous bars or to keep reversing them? Being a man of practice, I have decided to build a working expert advisor and test it on some FX pairs.

Of course, I did not use Hurst exponent itself for the entry/exit signals but I rather used a very simple approach. The EA counts the bars that follow previous bars’ direction and those that do not follow. If first win — the current price changes are persistent, if second — the price movement is not persistent. Once we know whether we have persistence or anti-persistence at the current bar, we may choose trade direction just by looking at the preceding bar. If we keep the trade open for as long as the current persistence mode resumes and close it when we want to reverse or simply cannot detect persistence or anti-persistence, without using SL or TP, we get a completely reversible EA.

When I coded this EA, I have decided not to optimize it at all. Just used some out-of-the-head “logical” values for look-back period (number of bars to calculate persistence on) and ratio of persistent or anti-persistent bars to consider it a trading opportunity. I have decided to go with 10 for period and 0.66 (at least two thirds) for ratio. It means that there has to be at least either 7 persistent bars or 7 anti-persistent in 10 bars checked to enter a new trade. Testing this expert advisor on EUR/USD @ W1 chart resulted in a considerable loss for a period of about 4 years. Not a problem — just reverse the entry/exit conditions and we have profit!

Backtest and Timeframes

Weekly

The released EA is called PersistentAnti and you can read a lot of detail about it on its main page. Here, I will try to shed some more light on its backtests and why do I recommend using it on EUR/USD weekly chart.

Here are original results without reversing the trading orders’ directions:

PersistentAnti - Backtesting Chart on EUR/USD @ W1 from 2009-01-01 to 2013-04-16

And here is the result of using exactly the same settings but with a reverse on:

PersistentAnti - Backtesting Chart on EUR/USD @ W1 from 2009-01-01 to 2013-04-16 with Reverse

The difference is obvious. Yes, there were only 33 trades during the period and the profit is quite low, but it seems like plausible trading idea.

Daily

Now, why do not we go to daily timeframe for even more trades and, presumably, more profit? First, let us do it with the reverse turned on as it had resulted in better outcome for weekly chart:

PersistentAnti - Backtesting Chart on EUR/USD @ D1 from 2009-01-01 to 2013-04-16 with Reverse

Obviously, it does not work on daily chart as well as it did on weekly. Perhaps switching the entry directions would help it. Here are the EUR/USD @ D1 results for this EA without reverse:

PersistentAnti - Backtesting Chart on EUR/USD @ D1 from 2009-01-01 to 2013-04-16

Now, we see some profit here. That is 243 trades and profit comparable to that received on weekly timeframe with reverse. The drawbacks — huge drawdown and the overall shape of the balance curve.

4-Hour

What if we try going down to H4 timeframe? Here is the resulting profit chart for no-reverse 4-hourly EUR/USD backtest:

PersistentAnti - Backtesting Chart on EUR/USD @ H4 from 2009-01-01 to 2013-04-16

Now we have 1,428 trades but some very serious loss. Will such a big loss mean an equally high profit when we invert the EA’s trade directions? Behold:

PersistentAnti - Backtesting Chart on EUR/USD @ H4 from 2009-01-01 to 2013-04-16 with Reverse

It is a loss! Not as big as before, but still a loss. Why? Because of a spread. With more than thousand deals, we have to pay our broker handsomely in form of spread. With 2 pip spread on EUR/USD, 1,428 trades transform into $2,856 loss (considering 0.1 standard lot positions), which we have to overcome to reach the breakeven point. Since this expert advisor’s edge is not too sharp, it cannot tolerate such losses solely due to the spread.

I decided not to test it on even lower timeframes as, obviously, there will be even more trades and even bigger spread-related loss with or without reverse. A lesson here? Stick to higher timeframes if you do not want to be in loss due to the Bid/Ask difference provided by your Forex broker.

Other Currency Pairs

Why EUR/USD? Because it yielded the best results on W1 chart. It was 20% gain vs. 10% drawdown for EUR/USD, while other pairs that I have tried showed the following results:

  • USD/JPY — 9% profit and 12% drawdown with reverse.
  • EUR/JPY — 4% vs. 15%, reverse.
  • GBP/JPY — 10% vs. 10%, reverse.
  • GBP/USD — 10% vs. 8%, no reverse.
  • AUD/USD — 15% vs. 4%, reverse.
  • USD/CAD — 10% vs. 3%, reverse.
  • USD/CHF — 8% vs. 12%, no reverse.
  • NZD/USD — -3% vs. 11%, reverse.

Three Versions

You can download the MT5 or MT4 version, or read more info about this trend persistence expert advisor. PersistentAnti is also available for cTrader. Stay tuned for the story of coding this expert advisor for cAlgo/cTrader.

If you have any questions or some interesting thoughts regarding PersistentAnti expert advisor, please feel free to post them using the form below.

2 Responses to “Backtesting Reversible Expert Advisor Based on Trend Persistence”

  1. BigPiping

    What about spread?

    Reply

    admin Reply:

    It is variable. Was about 1.5-2.5 for EUR/USD backtests.

    Reply

Leave a Reply

required
required (will not be published)
optional

Follow EarnForex Blog on Facebook