Backtesting Reversible Expert Advisor Based on Trend Persistence

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.

Contents

  • 1 Backtest and Timeframes

    • 1.1 Weekly
    • 1.2 Daily
    • 1.3 4-Hour
  • 2 Other Currency Pairs
  • 3 Three Versions

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:

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

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:

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:

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:

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:

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 PersistentAnti 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, please feel free to post them using the form below.

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    − nine = one