ADX Expert Advisor Documentation
This Expert Advisor (EA) employs an ADX-based trading strategy to make calculated entry and exit decisions. Alongside this core strategy, it incorporates optional advanced features, including a Moving Average filter on a higher timeframe, grid recovery, hedge, martingale strategies, position sizing based on profit, and day and time filters. These features offer flexibility and adaptability in diverse market conditions.
We divide our input sections into two parts. The first part is indicator related settings which you can find at the bottom side of the EA inputs. All other settings are common for every EA we make. We call it additional features. You can find the detailed documentation of these settings in this link
1. ADX 1 SETTINGS
ADX Input Parameters
- ADX1_TEXT_1 - Divider text for visual clarity in input section. (Not important for EA calculation)
- ADX1_TEXT - Text label for ADX 1 settings. (Not important for EA calculation)
- ADX1_TEXT_2 - Divider text for visual clarity in input section. (Not important for EA calcul
- ation)
- ADX1_TIMEFRAME - Selects the timeframe for ADX calculation. Default: PERIOD_CURRENT.
- ADX1_PERIOD - Defines the period for the ADX indicator. Default: 8.
- ADX1_PRICE_TYPE - Chooses the price type for ADX calculation. Default: PRICE_CLOSE.
- ADX1_LEVEL - Sets the ADX threshold level. Default: 20.
Entry Strategy Options
- ENTRY_STRATEGY1 - Buys when ADX crosses above the level; sells when it crosses below.
- ENTRY_STRATEGY2 - Buys when ADX crosses below the level; sells when it crosses above.
- ENTRY_STRATEGY3 - Buys when PDI crosses above MDI; sells when MDI crosses above PDI.
Exit Strategy Options
- EXIT_STRATEGY1 - Exits when ADX crosses above the specified level.
- EXIT_STRATEGY2 - Exits when ADX crosses below the specified level.
- EXIT_STRATEGY3 - Exits when PDI crosses above MDI.
- EXIT_STRATEGY4 - Disables automatic exits.
Note: At a time only entry or exit strategy can be active. Also, we should disable an exit strategy when we are using grid, hedge and martingale strategy along with the base strategy, otherwise it would mess up those loss recovery strategies.
2. Additional Features
Moving Average (MA) Filter on Higher Timeframe
The MA filter enables trades that align with the broader trend based on a higher timeframe moving average:
- Uptrend Condition - Allows buy trades when the close price is above the moving average.
- Downtrend Condition - Allows sell trades when the close price is below the moving average.
Loss Recovery Strategies
There are couple of loss recovery strategies popular in the market. Grid, Hedge and Martingale is most popular among them. In this EA, we have these strategies inbuilt. But only one loss recovery strategy can be active at a time. EA will not load, if we enable more than one loss recovery strategies. There is one important point regarding these strategies, we can not set stoploss if you enable Grid or Hedge strategy. It will close trades earlier and will compromise the purpose of these strategies. All of these strategies are by default disabled.
Grid Recovery Strategy
In a losing position, the EA places additional trades in a grid pattern, averaging down the entry price to capitalize on retracements.
Hedge Strategy
To balance exposure during a losing position, the EA opens opposing trades (hedges), allowing profit potential in countertrend movements.
Martingale Strategy
Increases lot size after a loss on each subsequent signal, aiming for overall profitability.
Position Sizing Based on Profit
This feature adjusts the position size dynamically based on cumulative profit, aiming to optimize gains in favourable conditions. As profit accumulates, the EA increases the position size, allowing for scaled growth and larger potential returns.
Day Filter
Specifies trading days to avoid trading during specific days of the week, aligning with your strategy’s optimal market conditions. You can disable the entire day filter.
Time Filter
Limits trading to specific times, preventing trades during low-liquidity periods or other non-ideal market conditions. You can disable entire time filter.
This ADX-based EA, with versatile entry and exit strategies and advanced risk management features, is a comprehensive tool designed to adapt to various market conditions while offering robust control over trading operations. Use each feature thoughtfully to align with your trading objectives and risk management strategy.
3 .Backtests and Optimized Set files
The EA can be back tested with various different strategies with the help of different combinations of these options
- Stop-Loss and Take-Profit
- Single or Multiple Entry (Multiple entries is not suitable for Grid)
- Entry Option
- Exit Option (Not suitable for Grid, Hedge and Martingale) (Enable/Disable)
- Time Filter (Enable/Disable)
- Day Filter (Enable/Disable)
- Breakeven (Enable/Disable)
- Trailing Stop-Loss (Enable/Disable)
- Daily, Weekly and Monthly Profit
- Grid (Enable/Disable) with no stoploss
- Hedge (Enable/Disable) with no stoploss
- Martingale (Enable/Disable) with no stoploss
- Higher timeframe Moving Average Trend Filter (Enable/Disable)
We have optimized our EA based on these different combinations in different timeframes (5Minute to 4 Hours). These optimizations are mainly performed on EURUSD, USDCHF, AUDUSD, GBPUSD, USDCAD, NZDUSD AND XAUUSD. We have run these optimizations on 4-10 years of data. You can find the optimized set files and results below.
Note: We have run the optimizations on every period calculation for faster results. In this approach calculation are perform on every candle loading. You can backtest on everytick mode, but backtest would be much slower. Optimization results may be different in different brokers. It depends on the mt5 data cache and specific broker data. Ideally mt5 has 99.99 tick quality data. For mt4 you need to purchase 99.99 quality data from specific providers. Each individual has their own preference of their settings and symbols. In case you need more optimized data you can always optimize yourself.
You can follow this video to learn how to optimize the EA.
Symbol: EURUSD(GRID)
Period: M30 (2014.01.01 - 2024.09.04)
Symbol: | USDCAD(GRID) | |||||||||||
Period: | M30 (2014.01.01 - 2024.04.09) |
Symbol: | XAUUSD(MARTINGALE) | |||||||||||
Period: | H1 (2014.01.01 - 2024.04.09) |