PersistentAnti Forex Expert Advisor uses the idea of trend persistence. The Forex market charts could switch between persistent or anti-persistent modes. On that matter, the established trend will likely continue in a persistent mode. On the other hand, an anti-persistent mode is one in which a positive change will be most likely followed by another negative, and vice versa. This property can be very helpful to traders when detected. A good strategy for trading is to follow the trend in a persistent mode while catching a reversal of that trend in an anti-persistent manner.
There are several ways to determine current or past persistence or anti-persistence in the market. These include Z-Score, Hurst exponent, and Z-Score. They all have significant drawbacks, unfortunately.
This expert advisor uses a simple but naive method to evaluate short-term persistence. It compares the number of bars that have followed the same direction as a previous bar with the number that didn't during a short period. The chart is considered to be in persistent mode if the percentage of persistent bars exceeds a certain threshold. The chart is believed to have an anti-persistent state if the percentage of persistent bars exceeds that threshold. The threshold is reached if neither the number of persistent bars nor the number of anti-persistent bars exceeds this threshold. In such cases, the EA regards the current mode as unclear. Therefore, it abstains from entering into new positions.
The expert advisor operates in the opposite direction to the detected mode. It will place a buy order following a bearish or persistent bar and a sell order following a bullish or persistent bar. It will also issue a sell order after a bearish or bullish bar and a buy order after a bullish or persistent bar. Although this behavior seems strange, it is due to backtesting without over-optimization. The expert advisor opens a position at the beginning of a bar and closes it at the start of the next bar (or the bar immediately after it). The strategy can be reversed without any stop-loss and take-profit levels. You can try it out and reverse it -- there is an input parameter. You can always reverse a reversible EA if backtests show significant losses.
Input Parameters (from the developer)
- 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.
PersistentAnti Expert Advisor backtesting results
The demo test of the PersistentAnti Expert Advisor on the MetaTrader 4 platform for a period of one year (2020) showed ~ 4.9% profit with ~ 3.4% maximum drawdown. EA concluded 337 trades, of which 53.12% were profitable. The volume of used positions was set at 0.1 standard lots. The test used the default settings on the EUR/USD H4 chart.
How to trade with PersistentAnti Expert Advisor
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.
How to download and install an expert advisor
In order to install an expert advisor on your MT4 platform, you need to follow these steps:
- Click on the “Download Indicator” button located at the bottom of the screen.
- Save the file to your computer.
- Extract and move the files into the MT4>Experts folder of the MetaTrader4 software file directory.
- Restart your Metatrader platform.
- Find and activate “PersistentAnti” Expert Advisor in the Navigator window.
Note: This Expert Advisor was developed by a third party. AtoZ Markets does not carry any copyrights over this trading tool.