1. Introduction

Most Bollinger‑Band mean‑reversion strategies suffer from frequent counter‑trend entries. This Trend‑Filtered BB‑Stoch Swing Strategy solves that issue by applying an EMA200 filter. Entries trigger only when confirmed by Stochastic Oscillator overbought / oversold crossovers. This article gives a brief overview of the strategy and provides the full MT5 Expert Advisor source code implementation.

2. Full Trading Rules

Core Indicators

  • Bollinger Bands: Period 20, Deviation 2.0
  • EMA: Period 200
  • Stochastic Oscillator: 5, 3, 3
  • ATR: Period 14

Basic Rules

  • Timeframe: All timeframes
  • Assets: Precious metals, forex, energy, and others

Entry Rules

Long entry

  1. Price is above EMA 200
  2. Bar touches the lower Bollinger Band
  3. Stochastic Oscillator produces a bullish crossover after entering the oversold zone

Long Setup Example

Short entry

  1. Price is below EMA 200
  2. Bar touches the upper Bollinger Band
  3. Stochastic Oscillator produces a bearish crossover after entering the overbought zone

Short Setup Example

Exit Rules

Long Exit

  • SL: swing low − 1.5 × ATR
  • TP: 2 times the stop‑loss distance

Short Exit

  • SL: swing high + 1.5 × ATR
  • TP: 2 times the stop‑loss distance

3.Parameter Settings

Parameter Default Value Description
EMA200_Period 200 EMA200 trend‑filter moving‑average period
BB_Period 20 Bollinger Bands calculation period
BB_Deviation 2.0 Standard deviation multiplier for Bollinger Bands
Stoch_K 5 Stochastic Oscillator %K period
Stoch_D 3 Stochastic Oscillator %D period
Stoch_Slowing 3 Stochastic Oscillator slowing parameter
Stoch_Overbought 80.0 Stochastic Oscillator overbought threshold
Stoch_Oversold 20.0 Stochastic Oscillator oversold threshold
ATR_Period 14 ATR period for dynamic stop‑loss calculation
ATR_Multiplier_SL 1.5 ATR multiplier for stop‑loss; SL offset = signal‑bar extreme ± (ATR × multiplier)
TP_Ratio 2.0 Risk‑reward ratio for take‑profit; TP distance = stop‑loss distance × this ratio
LotSize 0.1 Fixed trading lot size
MagicNumber 123456 EA magic number used to identify orders created by this EA

4.EA Source Code / Download

Click to download

5. Limitations & Disclaimer

No backtest / forward‑test results provided. Users must verify robustness via personal backtest and demo forward‑testing before live usage.

Not financial advice. Forex trading involves substantial risk.