- Strategy
- When EMA 50 is above EMA 200 and price is above EMA 200, it buys a stochastic %K cross above %D from the oversold zone; in a downtrend it sells the mirror cross from overbought.
- Risk model
- 1% of balance per trade (configurable), ATR-based stop-loss on every order, one position at a time
What it does
Stochastic Pullback EA joins an existing trend after a pullback. Two EMAs decide the trend direction, and the stochastic oscillator times the entry when a dip in an uptrend (or a rally in a downtrend) starts to turn.
How it works
The stochastic uses %K 14, %D 3, slowing 3, calculated on the low/high range. On every new bar the EA reads the last two closed bars:
- Uptrend: EMA 50 above EMA 200 and the last close above EMA 200.
- Downtrend: EMA 50 below EMA 200 and the last close below EMA 200.
- Buy: in an uptrend, %K was at or below %D on the older bar and above %D on the last bar, and either line was at or below 20 on the older bar.
- Sell: in a downtrend, %K was at or above %D and then crossed below it, with either line at or above 80 on the older bar.
- Stop-loss: 1.5 × ATR(14) from the entry price. Take-profit: 1.5 × the stop distance.
Signals against the trend are logged and skipped, so the log shows how often the filter blocks a trade. The moving averages lesson covers how the 50/200 pair is commonly used.
How to use it
Use it on instruments that trend for weeks at a time. On H1 the 200 EMA covers roughly eight trading days; on H4 it covers several weeks, which gives a steadier trend read. If you want fewer but deeper pullbacks, lower the oversold level to 10 and raise the overbought level to 90. Combine it with the Risk Reward Calculator to compare target settings.
Settings
| Input | Default | What it changes |
|---|---|---|
| Stochastic %K / %D / slowing | 14 / 3 / 3 | Oscillator shape |
| Oversold / Overbought | 20 / 80 | Zones a cross must start from |
| Fast / Slow trend EMA | 50 / 200 | Trend filter |
| ATR period / Stop-loss (x ATR) | 14 / 1.5 | Stop size |
| Reward:risk target | 1.5 | Take-profit, 0 disables it |
| Risk per trade / Fixed lots | 1.0% / 0 | Position sizing |
| Max spread (points) | 30 | Spread filter |
| Trading start / end hour | 7 / 20 | Server-time window |
| Break-even / Trailing | on / off | Stop management |
Limitations
The EMA filter lags, so the EA keeps buying pullbacks for a while after a trend has actually ended. In sideways markets the EMAs cross back and forth and the stochastic gives many crosses that go nowhere. The stochastic can stay in the oversold zone during sharp selloffs, producing early entries.
Before you run it live
Backtest it in the Strategy Tester on several years and symbols, including periods with no clear trend, then trade it on a demo account. Make sure the trading window is set in your broker's server time and that the spread limit suits the symbol. Keep risk per trade small. Past behavior does not guarantee future results.

