RSI ADX ATR Strategy EA in MQL5: Prop-Firm-Safe Rules
RSI tells the EA when momentum has shifted. ADX tells it whether the move has enough strength. ATR tells it how much room the trade needs. Together, they make a cleaner robot than RSI alone.
The Problem With RSI Alone
RSI is useful, but RSI by itself is incomplete. A simple robot that buys below 30 and sells above 70 has no idea whether the market is ranging, trending, quiet, violent or sitting inside a news candle.
That is why RSI strategies often backtest well on selected periods and then fail live. The missing pieces are trend strength and volatility. ADX answers the trend-strength question. ATR answers the volatility question.
The result is a more complete Expert Advisor: RSI provides the trigger, ADX filters weak setups and ATR sizes the stop and target around current market movement.
Strategy Blueprint
| Layer | Indicator | Rule |
|---|---|---|
| Entry | RSI 14 | Buy when RSI crosses above 30; sell when RSI crosses below 70. |
| Trend strength | ADX 14 | Only trade when ADX is above 20 or 25. |
| Direction filter | +DI and -DI | Buy only when +DI is stronger; sell only when -DI is stronger. |
| Stop loss | ATR 14 | Set SL at 1.5x to 2.0x ATR. |
| Take profit | ATR or R multiple | Use 1.5R to 2R target, or trail after 1R. |
Buy and Sell Rules
Buy Setup
- RSI crosses above 30 from below.
- ADX is above the minimum strength threshold.
- +DI is above -DI, confirming bullish pressure.
- Spread is below the allowed maximum.
- No high-impact news blackout is active.
- Daily loss and daily trade limits are not breached.
Sell Setup
- RSI crosses below 70 from above.
- ADX is above the minimum strength threshold.
- -DI is above +DI, confirming bearish pressure.
- Spread is below the allowed maximum.
- No high-impact news blackout is active.
- The EA has not exceeded its max trades for the day.
Why ATR Stops Are Better Than Fixed Pips
A fixed 50-pip stop does not mean the same thing in every market. On a quiet EURUSD session, it may be wide. On XAUUSD during a news week, it may be tiny. ATR solves this by measuring current average movement and adapting the stop distance.
A practical starting point is 1.5x ATR for normal trades and 2.0x ATR for gold or volatile indices. If the stop becomes too large for your risk limit, the EA should reduce lot size or skip the trade. It should not force the same lot size into a wider stop.
This is especially important for prop firms. The lot size must adapt to the stop. Otherwise, a wider ATR period can accidentally increase account risk.
MQL5 Implementation Notes
In MQL5, RSI, ADX and ATR are normally created as indicator handles in OnInit. The EA then reads fresh values with CopyBuffer. This matters because creating handles inside OnTick is inefficient and can make the robot unstable during live trading.
- Create `iRSI`, `iADX` and `iATR` handles once in `OnInit`.
- Check that every handle is valid before allowing the EA to trade.
- Use closed-bar values for signals, not the still-forming candle.
- Release handles in `OnDeinit` with `IndicatorRelease`.
- Use `CTrade` for order execution and set magic number before trading.
Prop-Firm-Safe Risk Controls
A prop-firm version of this EA should be designed around failure prevention. The strategy has to survive normal losing streaks without breaching the daily drawdown rule.
- Risk only 0.25% to 1% per trade.
- Stop trading when daily loss reaches a private limit below the firm's limit.
- Limit entries to 3 to 5 trades per day.
- Block trades during high-impact news.
- Block trades when spread exceeds the configured maximum.
- Do not add martingale, grid averaging or unlimited recovery.
Backtest Checklist
- Test multiple symbols: XAUUSD, EURUSD, GBPUSD and one volatile cross.
- Test M15, M30 and H1 separately instead of mixing everything at first.
- Compare ADX 20, 25 and 30 to see the trade-count impact.
- Compare ATR 1.5x, 2.0x and 2.5x stops.
- Use realistic commission and spread.
- Measure worst day and worst week, not only net profit.
- Forward test before using live or funded capital.
Frequently Asked Questions
How do RSI, ADX and ATR work together?
RSI gives the entry trigger, ADX filters for strength and ATR sets a volatility-based stop. The three indicators answer different questions, so the EA is less blind than RSI alone.
What ADX value should an EA use?
Start with ADX 20 or 25. ADX 20 allows more trades. ADX 25 is stricter and usually better when you want fewer low-quality signals.
Why use ATR stop loss instead of fixed pips?
ATR adjusts the stop to current market volatility. Fixed pips can be too tight on gold or too wide in quiet forex sessions.
Is RSI ADX ATR good for prop firms?
It can be, if the EA includes conservative risk per trade, daily loss stop, news filter, max trades and no martingale.
Can this be automated in MQL5?
Yes. MQL5 has built-in RSI, ADX and ATR indicators. A clean EA creates handles in OnInit, reads closed-bar values with CopyBuffer and uses CTrade for execution.
Build This RSI ADX ATR EA
You can generate a simple version with the free MT5 EA Builder, or ask AlgoSpecial to build a custom version with multi-timeframe logic, news blackout, prop-firm limits and full source code.