Persistence and Anti-Persistence
PersistentAnti Forex expert advisor exploits the idea of trend persistence. It is believed that the Forex market charts may switch between persistent and
Applying the Concept
There are many ways to detect current (or, more precisely, past) persistence or
The presented expert advisor uses a simple, albeit naïve, method to assess the
The most interesting part is that this expert advisor trades contrary to the detected mode. It will use a buy trade following a bearish bar and a sell trade following a bullish bar in a persistent mode. At the same time, it will issue a sell order following a bearish bar and a buy order following a bullish bar in an
Trading Algorithm
The expert advisor is very simple and so is its algorithm of actions:
- On new bar opening, go through previous N bars.
- For each bar check if the preceding bar was bullish or bearish. Then compare it to the bar in the current iteration.
- If both are bullish or both are bearish, record one point for the persistent mode. If bars' directions differ, record a point for the
anti-persistent mode. - Close previous position if a position in opposite direction should be opened or if neither persistence nor
anti-persistence has been detected. - If Reverse is turned on (default) and ratio of persistent bars exceeds the given value, sell after a bullish bar or buy after a bearish one. If the
anti-persistent bars prevail, sell after a bearish bar or buy after a bullish one. - If Reverse is turned off and ratio of persistent bars exceeds the given value, buy after a bullish bar or sell after a bearish one. If the
anti-persistent bars prevail, buy after a bearish bar or sell after a bullish one.
This is it.
Backtest Results
The backtest of the PersistentAnti expert advisor was performed on the 50-month period of the EUR/USD W1 chart. A fixed position volume of 0.1 standard lot has been used. Net profit was $1,996 on $10,000 starting account balance with the maximum relative drawdown at 9.19%. This drawdown period lasted for more than a year, which is quite long. You must be prepared to face long-term losing periods if you plan trading with this EA.
Input Parameters
- N (default = 10) — the number of bars to look back for
(anti-)persistence detection. - Ratio (default = 0.66) — the ratio of
(anti-)persistent bars to consider opening a new position or resuming with the current one. - Reverse (default = true) — if true, trades contrary to the detected market persistence mode, otherwise trades in accordance with it.
- Lots (default = 0.1) — the number of standard Forex lots to open positions for. Ignored if MM = true.
- Slippage (default = 100) — the acceptable price slippage in pips.
- MM (default = false) — if true, fixed fractional position sizing will be used.
- MaxPositionSize (default = 5) — the maximum position size in standard lots when MM = true.
- OrderComment (default = "PersistentAnti") — the commentary for positions opened by this EA.
- Magic (default = 2013041816277982) — the order magic number to filter positions opened by this EA. Used only in MT4.
MiniFAQ
What stop-loss and take-profit levels are used by this EA?
It does not use any stop-loss or take-profit, but its backtest on EUR/USD @ W1 showed an average losing trade of 112 pips and an average winning trade of 153 pips.
How often does this EA trade?
On weekly EUR/USD chart (the optimal, though not over-optimized, setting) this EA will trade about 10 times a year on average.
What is the difference between the versions for MT4 and for MT5?
MT5 version will mess up with other EA's positions on the same currency pair. MT4 will use Magic number to avoid that.
My backtest resulted in loss. I have switched the Reverse parameter but it did not help. What is the matter?
If you are trading on lower timeframes, the EA is probably taking too many trades and the spread losses are much bigger than any profit it could possibly provide in reverse or direct mode.
This EA is ECN-safe.You can freely use this expert advisor with ECN (market execution) brokers as it either does not apply any stop-loss and take-profit levels in its trading orders or sends only pending orders.
Download (ver. 1.01, 2022-04-14)
Download PersistentAnti expert advisor for MT4 Download zipped PersistentAnti expert advisor for MT4 Download PersistentAnti expert advisor for MT5 Download zipped PersistentAnti expert advisor for MT5Discussion
Warning! Before you ask basic questions regarding installation of the expert advisors, please, read this MT4 Expert Advisors Tutorial to get the elementary knowledge on handling them.
Do you have your own trading results or any other remarks regarding this expert advisor?
Discuss PersistentAnti with other traders and MQL programmers on the experts forums.
Changelog
1.01 - 2022-04-14
- Improved the clarity of input parameters' descriptions and error messages.
1.00 - 2013-05-10
- First release of the PersistentAnti expert advisor on EarnForex.com.