Specifiche
I want to create an intraday EA designed to trade RSI pullbacks in the direction of the dominant trend during sufficient volatility, scales out profits, and automatically stands aside when market conditions stop supporting its edge.
It should have the following features and are based on the following indicators:
Trade FX on M15
Enter based on RSI, EMA and ATR
Scale out profits using a multi-TP structure
Trade only during active trading periods
Automatically stop trading when market conditions deteriorate
Resume when conditions normalize
1. Market & Timeframe
-
Instrument: FX majors / liquid crosses
-
Timeframe: M15
-
Style: Intraday trend-following pullbacks
-
Holding time: Minutes to a few hours
2. Indicators
Trend Filter – EMA
-
Fast EMA: 50 EMA
-
Slow EMA: 200 EMA
Trend rules
-
Bullish bias: 50 EMA > 200 EMA and price above 50 EMA
-
Bearish bias: 50 EMA < 200 EMA and price below 50 EMA
-
No trade if EMAs are flat or crossing frequently
Pullback Trigger – RSI
-
RSI period: 14 (configurable)
-
RSI pullback zones:
-
Uptrend: RSI pulls back into 40–50
-
Downtrend: RSI pulls back into 50–60
-
Entry trigger (configurable)
-
RSI returns back in trend direction:
-
Buy: RSI crosses upward through 50
-
Sell: RSI crosses downward through 50
-
Volatility Filter – ATR
-
ATR period: 14
-
ATR timeframe: M15
Trade only if:
-
Minimum ATR threshold
-
Example: ATR ≥ X pips (pair-specific)
-
-
Relative ATR
-
ATR > ATR(50) × 0.8 (market not dead)
-
No volatility → no edge → EA stands aside.
3. Entry Conditions (All Must Align)
BUY Setup
-
Trading session is active ✅
-
ATR filter passes ✅
-
50 EMA > 200 EMA ✅
-
Price above 50 EMA ✅
-
RSI pulled back to 40–50 zone
-
RSI crosses back above 50
-
No open trades in same direction (optional rule)
SELL Setup
Same logic, inverted.
4. Stop Loss Logic
Use ATR-based stops, not fixed pips.
Options:
-
SL = 1.2 × ATR
-
Or SL beyond recent swing high/low, capped by ATR
5. Multi-TP Scaling Structure
Position Allocation
-
TP1: 40% of position
-
TP2: 30%
-
TP3: 30%
Targets
-
TP1 = 0.8 × ATR
-
TP2 = 1.5 × ATR
-
TP3 = 2.5 × ATR or EMA trail
Trade Management
-
After TP1 hit → move SL to breakeven
-
After TP2 hit → trail stop using:
-
20 EMA
-
or ATR trailing stop
-
6. Time-of-Day Filter
Trade only during high-liquidity windows.
E.g. FX sessions: (configurable)
-
London Open: 07:00–10:00 GMT
-
London–NY overlap: 12:00–16:00 GMT
Rules:
-
No new trades outside allowed windows
-
Existing trades can finish naturally
7. Market Deterioration Detection (Auto Stand-Aside)
Conditions to STOP Trading
Any 2 of the following occur:
-
ATR drops below minimum threshold
-
EMA distance shrinks below X pips (market compressing)
-
RSI chops between 45–55 for N candles
-
3 consecutive losses (configurable)
-
Spread widens beyond normal (due to news / rollover)
When triggered:
-
EA enters “Paused Mode”, close all existing trades if unprofitable (set to be configurable)
-
No new trades allowed
8. Resume Logic (Automatic Recovery)
EA resumes only when:
-
ATR rises above threshold again
-
EMA slope increases (trend re-establishes)
-
RSI starts clean swings again
9. Risk Management
-
Risk per trade: 0.5% (configurable)
-
Max trades per session: 2–3 (per FX pair)
-
Max daily loss: hard stop (−2%, configurable)
Configurable Parameters:
Core Parameters-
Timeframe: M15
-
EMA Fast / Slow: 50 / 200
-
RSI Period: 14
-
ATR Period: 14
-
Risk per trade: 0.5%–1%
-
Max trades per session: 2–3
-
Sessions: London + London–NY overlap
FX Pair-Specific Parameters to be configurable, but with the values below as default RSI Pullback Zones
-
Buy: 40
-
Sell: 60
ATR (M15)
-
Minimum ATR: 0.00055 (5.5 pips)
-
Low-vol pause threshold: < 0.00045
Stops & Targets
-
SL: 1.2 × ATR
-
TP1: 0.8 × ATR
-
TP2: 1.6 × ATR
-
TP3: 2.6 × ATR
I have attached a pseudocode below for reference, which will need proper cleaning and fine tuning.