Countertrend EA

countertrend forex robot

This is the review of my counter trend EA. As the title suggests, it trades against the trend on H4 timeframe using support/resistance lines and changes in volatility. These are key points in trading. I’m using a higher timeframe in order to filter the noise. On lower timeframes, support and resistance levels are not so accurate, in fact are not accurate at all because of the noise (spikes, long shadow candles). This EA doesn’t trade very often, it only trades when some conditions are being met on H4. But when it trades, it makes consistent profits.


The strategy

It goes long when:
1. The previous H4 candle opens bellow lower Bollinger band and closes above it
2. The previous H4 candle closes above the last high
3. Some volatility conditions are met.

It goes short when:
1. The previous H4 candle opens above upper Bollinger band and closes bellow it2. The previous H4 candle closes bellow the last low
3. Some volatility conditions are met.

It exists the market when the volatility gets lower and lower or when an opposite signal occurs.

Take Profit and Stop Loss levels

It opens positions at the end of the current candle, but it closes them whenever necessary, it doesn’t wait for the current candle to close in order to exit the trade. Take profit and stop loss are also broker side thus protecting the account if the VPS shuts down or if the internet connection is lost.

Take profit:  between 15 and 300 pips
Stop loss: between 4 and 250  pips

Stop loss and take profit values are dynamic and they modify according to changes in the market although this robot has broker side stop loss and take profit values.

Backtests and statistics

13 years backtests:

Countertrend EA backtests

Counter trend EA backtests

Total number of trades: 423
Won pips: 15,702
Maximum drawdown: 784 pips
Maximum drawdown length: 344 days (more than 1 year)
Average pips per year: 1027
Won trades: 56%
Lost trades: 44%
Maximum consecutive wins: 10
Maximum consecutive losses: 6
Average consecutive wins: 2
Average consecutive losses: 2
Average profit trade: 137 pips
Average loss trade: 93 pips

All years are profitable except 2004:

Countertrend EA yearly profits

Countertrend EA yearly profits


Robustness analysis

This forex robot doesn’t trade often because it trades on a higher timeframe (H4). During 13 years it traded 423 times so I’m not in such a hurry to say that backtests should be considered statistically valid, but:

1. Long and short trades and almost equally distributed and so does profits

2. It employs a very old and robust strategy which is very popular among traders (trading near support and resistance lines on higher timeframes)

3. It survives just fine to some extreme Walk Forward tests.

4. It passes my personal robustness formula:

Real Profit Ratio (RPR) = ((WFER * Total profit in pips) / number of years to backtest) / MCWCS


WFER = Walk Forward Efficiency Ratio

MCWCS = Monte Carlo Worst Case Scenario (MC analysis is performed having the best selected parameters as a starting base)

If RPR<0.5, the EA should be discarded.
If RPR>0.5 AND RPR<0.6 – modest performance
if RPR>0.6 AND RPR<0.8 – good performance
if RPR>0.8 – an excellent EA!

In this case, RPR is 0.55– modest performance.

According to my formula it shows modest performance but it raises the quality of my portfolio by much therefore I’m keeping it. When my other robust EAs are in drawdown, this EA tends to win much. When they are winning, this EA does not trade at all, which is fine by me. This is an example of how a portfolio is much more profitable than a standalone EA.

You may wonder why am I using this weird formula. I’m using it because it respects the following:

– money is made in the future, not in the past, so in order to see how this EA should behave in the future, I’m performing a WFR analysis first. Total profit of pips made in the backtests are multiplied with Walk Forward Efficiency Ratio which is usually less than 1 because in real life we expect less pips than in backtests.

– MCWCS (Monte Carlo Worst Case Scenario) shows us the worst case scenario we can expect.

– My formula is nothing more than the number of pips we can expect in real life / maximum drawdown in pips shown by MCWCS.


The drawdown length is quite high, backtests show a maximum drawdown length of more than one year and nobody has the patience to wait that much. But the drawdown length is a common expert adviser problem. More than 95% of them have a prolonged drawdown period and the answer is very simple: market changes, it can’t trend all the time. So during the swing periods the EA merely survives.

How to use it

The proper choice is to build a multiple strategy portfolio. My portfolio  shown only 3 months of drawdown even if standalone EAs have much longer drawdown periods!