The EA follows a step-by-step signal pipeline. Each step filters the signal further, increasing quality. You choose how many filters to apply.
3-Bar Pattern
Candle formation
→
SMT Divergence
3-symbol comparison
→
LTF Confirmation
Lower timeframe
→
HTF Filter
Higher timeframe
→
BB Filter
Bollinger angle
→
TRADE
Entry executed
How the 3-Candle Pattern Works
Bearish Example:
Candle 1 (Initial): The reference candle - we measure from here.
Candle 2 (Pending): High breaks above Candle 1's high, but close comes back below it. This is the "fake breakout" - the trap.
Candle 3 (Confirmation): Close breaks below Candle 1 or Candle 2's low. This confirms the reversal.
Bullish Example: Mirror image - Candle 2 dips below Candle 1's low but recovers, Candle 3 confirms by closing above.
What is SMT Divergence?
The EA compares 3 correlated symbols (e.g., EURUSD, GBPUSD, AUDUSD). When one symbol makes a new high/low but the others don't follow, that's a
divergence - a sign that the move is weakening and likely to reverse.
Basic EA identification and trade permission settings.
Magic Number Default: 123456
A unique ID for this EA's trades. If you run multiple EAs on the same account, give each one a different Magic Number so they don't interfere with each other.
Trade Comment Default: SMT_Div_v3
A label attached to every trade. Helps you identify which EA opened a trade when reviewing your history.
Allow Long Trades Default: true
Enable or disable buy trades. Turn off if you only want to test short (sell) signals.
Allow Short Trades Default: true
Enable or disable sell trades. Turn off if you only want to test long (buy) signals.
Slippage in Points Default: 10
Maximum allowed price slippage when opening a trade. If the price moves more than this many points between your order and execution, the trade is rejected.
Max Spread in Points Default: 50 Optional
If the current spread exceeds this value, no new trades will open. Set to 0 to disable spread filtering. Useful to avoid trading during high-spread periods (news, low liquidity).
SMT divergence requires 3 correlated symbols. The EA automatically pairs symbols for you (e.g., if you run it on EURUSD, it automatically uses GBPUSD and AUDUSD). You can override this with custom tickers.
Use Symbol B / Use Symbol C Default: true / true
Enable or disable the 2nd and 3rd comparison symbols. Both should normally be ON for proper SMT detection.
Custom Symbol B / Custom Symbol C Default: empty
Only used when "Use Custom Tickers" is enabled. Type the exact broker symbol name (e.g., GBPUSD, NAS100).
Use Custom Tickers Default: false
When OFF, the EA auto-selects correlated pairs. When ON, it uses whatever you type in Custom Symbol B/C fields.
Bars Count Default: 1000
How many historical bars to analyze. Higher = more signals found in history but slower loading. 1000 is a good balance. For backtesting long periods, increase this.
Auto-Paired Symbols (examples)
| Your Chart | Symbol B | Symbol C |
| EURUSD | GBPUSD | AUDUSD |
| XAUUSD | XAGUSD | XPTUSD |
| NAS100 | US500 | US30 |
| BTCUSD | BTCUSD | BTCUSD |
Control how the divergence detection engine behaves.
Show SSMT Divergence Default: true
Master switch for SMT divergence detection. Must be ON for the EA to generate any signals. Only turn off if you want to test patterns without divergence.
Show Invalid SSMT Divergence Default: false
When OFF, if a divergence evolves (moves to a more extreme bar), the old one is removed. When ON, both old and new divergences are kept. Recommended: OFF for cleaner signals.
Show SSMT Convergence Default: false
When OFF, if all 3 symbols eventually break the same level (convergence), the divergence signal is removed. When ON, it stays visible even after convergence.
This is the most important section. You choose which conditions must be met before a trade is taken. Conditions stack on top of each other - each one adds an extra filter for higher quality signals.
Use Condition 2 Default: true Required Base
3-Bar Pattern + SMT Divergence. This is the minimum requirement. A valid candle pattern must appear together with an SMT divergence signal.
Use Condition 3 Default: false
+ Lower Timeframe Divergence. Adds confirmation from a smaller timeframe. Example: if your chart is H1, it checks M5 for additional divergence in the same direction.
Use Condition 4 Default: false
+ Higher Timeframe Divergence. Adds a filter from a larger timeframe. Example: if your chart is M15, it checks H1 for divergence alignment. Ensures you're trading with the bigger picture.
Use Bollinger Band Filter Default: false
+ BB Angle & Touch Filter. Checks the slope of Bollinger Bands and whether price has touched the bands. Filters out signals that go against the trend momentum.
Combination Examples
C2 only = Pattern + Divergence → Most signals, least filtered
C2 + BB Filter = Pattern + Divergence + Bollinger confirmation → Good balance
C3 + BB Filter = Pattern + Divergence + LTF confirmation + Bollinger → High quality
C4 only = Pattern + Divergence + HTF alignment → Fewer but aligned signals
C3 + C4 = Both LTF and HTF must confirm → Strictest filtering
Important
The EA picks the
highest active condition as the signal source. If BB Filter is ON, it will use Condition 5 logic. If C4 is ON (but not BB), it uses Condition 4, and so on. They are hierarchical, not additive.
The base trading condition. A 3-bar candle pattern must appear together with an SMT divergence.
Max Confirmation Bars Default: 1
How many bars after the pending candle (Candle 2) are allowed for the confirmation (Candle 3). 1 means Candle 3 must be the very next bar. 2 allows one extra bar gap. Keep low (1-2) for tighter signals.
Check Divergence on Any Bar Default: false
OFF: Divergence must appear specifically on the pending bar (Candle 2). Stricter.
ON: Divergence can appear on any bar within the pattern range (Candle 1, 2, or 3). More lenient, catches more signals.
Pattern Type Default: Strict 3-Bar Only
Which candle pattern to use for signal detection.
| Option | Description |
Strict 3-Bar Only | Classic 3-bar reversal: Candle 2 breaks out but closes back, Candle 3 confirms. Tightest definition. |
Looser Pivot Only | Candle 2 breaks out AND close stays beyond the level (deeper penetration). Candle 3 must confirm while all intermediate bars respect the pattern. More relaxed entry. |
Both Patterns | Accept signals from either pattern type. Maximum signal count. |
Adds a confirmation layer: the signal must also have SMT divergence on a lower timeframe within the same time window as the pattern.
Lower Timeframe Default: M5 (5 Minutes) Key Setting
The timeframe to check for additional divergence. Should be smaller than your chart timeframe. Example: if your chart is H1, use M5 or M15 here.
Max Confirmation Bars Default: 1
Same as Condition 2 - how many bars gap is allowed between pending and confirmation candle.
Pattern Type Default: Strict 3-Bar Only
Same as Condition 2 - which candle pattern to detect.
How does it work?
When a Condition 2 signal appears on your chart (e.g., H1), the EA zooms into the lower timeframe (e.g., M5) and checks: "Was there also an SMT divergence on M5 during the same time window as this H1 pattern?" If yes, the signal is confirmed. If not, it's rejected.
Filters signals by checking if a higher timeframe also shows divergence in the same direction. Ensures you're aligned with the bigger picture.
Higher Timeframe Default: H1 Key Setting
The larger timeframe to check. Should be bigger than your chart. Example: if chart is M15, use H1 or H4 here.
HTF Lookback Bars Default: 10
How many higher-timeframe candles to scan backwards for divergence. 10 means it checks the last 10 H1 bars (if HTF is H1). Increase for wider search window.
Required HTF Divergence Hits Default: 1
Minimum number of HTF bars that must show divergence. 1 = at least one bar. Increase for stricter confirmation.
Double Divergence Mode Default: Accept any
How to handle situations where the HTF shows both bullish AND bearish divergence.
| Option | What it does |
Accept any | Count all divergences that match your signal direction, ignore opposing ones. |
Latest only | Only consider the most recent HTF divergence. If the latest is opposite direction, signal is rejected. |
Skip if conflicting | If both bull and bear divergences exist on HTF, reject the signal entirely (conflicting information). |
Base Condition (Seed) Default: Condition 2
Which condition provides the initial signal that gets filtered by HTF:
Condition 2: Pattern + CTF Divergence (then filtered by HTF)
Condition 3: Pattern + CTF Div + LTF Div (then filtered by HTF) - strictest
LTF for C3 Seed Default: M5
Only used when Base Condition = "Condition 3". Sets the lower timeframe for the C3 check within C4.
The most advanced filter. It checks the angle (slope) of the Bollinger Bands middle line and whether price has touched the filter bands. This helps confirm that the trend momentum supports your signal direction.
Long Angle Threshold Default: -10.0
If the BB middle line angle is below this value (steep downward slope), bearish signals get strong confirmation but bullish signals are rejected. More negative = stricter filtering.
Short Angle Threshold Default: 10.0
If the BB middle line angle is above this value (steep upward slope), bullish signals get strong confirmation but bearish signals are rejected. More positive = stricter filtering.
Angle Lookback Bars Default: 10
How many bars back to measure the BB middle line slope. Smaller = more responsive to recent changes. Larger = smoother, more stable angle.
Filter Touch Lookback Default: 3
When the angle is in the "neutral zone" (between thresholds), the EA checks if price recently touched the BB filter band. This setting controls how many bars back to check for the touch.
Seed Type Default: Condition 2
Which condition provides the base signal before BB filtering is applied.
| Seed | Signal Pipeline |
Condition 2 | Pattern + Divergence → BB Filter |
Condition 3 | Pattern + Div + LTF Div → BB Filter |
Condition 4 | Pattern + Div + HTF Filter → BB Filter |
BB Period / Deviation / Shift / Applied Price
Standard Bollinger Bands parameters. Period 20, Deviation 2.0 is the classic setting. Applied Price determines which price type (Close, Open, etc.) is used for the BB calculation.
BB Filter Type Default: Filter "50"
Determines which band level the price must touch for "neutral zone" confirmation.
| Type | Touch Level |
Filter "50" | Middle Band only (the SMA line) |
Filter "25_75" | 50% between Middle and Upper/Lower bands (quartile lines) |
Filter "100_0" | Upper and Lower bands themselves |
Custom | Use the Upper/Lower Filter % settings below |
Use Upper/Lower Filter & Filter % Default: true, 50%
Only active when Filter Type = "Custom". The percentage defines where the filter line sits between the middle band and the outer band. 0% = at the middle, 100% = at the outer band.
How the BB Filter Decides
Strong Signal: BB angle clearly confirms direction (angle > threshold). Signal passes automatically.
Filtered Signal: BB angle is neutral, but price touched the filter band. Signal passes with "touch confirmation".
Rejected: BB angle opposes direction, OR angle is neutral with no touch. Signal is blocked.
Once a signal is confirmed, the EA needs to decide how to enter the trade. You have 4 options.
Entry Mode Default: Distance Auto Key Setting
Choose how the EA opens trades after signal confirmation.
| Mode | How it works | Best for |
Market Only |
Opens immediately at market price when Candle 3 confirms. Fast entry, no waiting. |
Quick execution, live trading |
Limit Only |
Places a limit order at Candle 2's extreme (low for buy, high for sell). Waits for price to come back to better entry. |
Better R:R ratio, patient strategy |
Distance Auto |
Measures the distance from Candle 2 extreme to Candle 3 close. If distance < threshold → Market order. If distance ≥ threshold → Limit order. |
Best of both worlds (recommended) |
Split |
Opens BOTH a market order AND a limit order, each with a portion of the lot size. Test both strategies simultaneously. |
Testing, comparison |
Distance Threshold (Pips) Default: 15.0
Only for Distance Auto mode. If the distance between Candle 2 extreme and Candle 3 close is less than this value, a market order is used. If more, a limit order is placed at Candle 2. This prevents entering trades where price has already moved too far from the ideal entry.
SL Buffer Beyond Pattern (Pips) Default: 2.0
Extra breathing room added to the stoploss. The SL is placed beyond the pattern's extreme (highest high or lowest low of candles 1-3), plus this buffer. Example: pattern low is 1.1000, buffer is 2 pips → SL at 1.0998.
Pending Limit Order Expiration (Hours) Default: 24
How long a limit order stays active before being automatically cancelled. Only applies to limit orders (not market orders).
Split Mode: % as Market / % as Limit Default: 50% / 50%
Only for Split mode. Controls what percentage of the lot goes to market entry vs limit entry. Example: 70%/30% means 70% is entered at market immediately and 30% waits as a limit order.
Distance Auto Example (Bearish)
Candle 2 high = 1.1050 (the peak/extreme)
Candle 3 close = 1.1040
Distance = 10 pips < 15 pip threshold
→ Market order at 1.1040
If distance was 20 pips instead:
→ Sell Limit at 1.1050 (Candle 2 high)
Controls how much you risk per trade and how many trades can be open at once.
Lot Calculation Type Default: Risk Percentage
How the EA determines position size.
| Type | How lot is calculated |
Fixed Lot | Always uses the same lot size regardless of SL distance. Simple but doesn't account for risk. |
Risk Percentage | Calculates lot size so that if SL is hit, you lose exactly X% of your equity. Recommended for backtesting. |
1R per Trade | Same formula as Risk Percentage. Each trade risks exactly 1R (one unit of risk). |
Fixed Lot Size Default: 0.1
Used when Lot Type = "Fixed Lot". Ignored otherwise.
Risk % per Trade Default: 1.0 Key Setting
What percentage of your account equity to risk on each trade. 1% means if your equity is $10,000, you risk $100 per trade. For backtesting cumulative R, keep this at 1%.
Maximum / Minimum Lot Size Default: 10.0 / 0.01
Safety limits. The calculated lot will never exceed Maximum or go below Minimum, regardless of risk calculation.
Max Open Trades Default: 3
Maximum number of simultaneously open positions. No new trades if this limit is reached.
Max Trades Per Day Default: 10
Maximum number of trades opened in a single day (includes currently open + closed today).
One Trade Per Signal Bar Default: true
When ON, the EA won't open a second trade if one was already opened from the same signal bar. Prevents duplicate entries on the same pattern.
The stoploss is automatically placed beyond the pattern extreme (highest high or lowest low of the 3 candles) plus the buffer. These settings control what happens AFTER entry.
Use Trailing Stop Default: true
Enable or disable the trailing stoploss feature.
Trailing Activation (R) Default: 4.0
The trailing stop activates when profit reaches this R multiple. Example: if your initial risk (1R) is 20 pips, trailing activates when profit reaches 80 pips (4R).
Trail to Secure (R) Default: 2.0
When trailing activates, the stoploss moves to lock in this R profit. Example: activation at 4R, trail to 2R means when price reaches +4R, your SL moves to +2R, securing 2R profit minimum.
Use Breakeven Default: true
Enable or disable the breakeven feature (moves SL to entry price once a certain profit is reached).
Breakeven Activation (R) Default: 2.0
Move SL to breakeven when profit reaches this R. Example: 2R means once you're up 2 times your initial risk, SL moves to entry + offset.
Breakeven Offset (Pips) Default: 5
Instead of moving SL exactly to entry price, add this small offset in your favor. This covers the spread and ensures a tiny profit even if price reverses to your entry.
Trailing Stop Example
Entry: 1.1000 (Buy), SL: 1.0980 (20 pip risk = 1R)
1. Price reaches 1.1040 (2R) → Breakeven activates, SL moves to 1.1005 (+5 pip offset)
2. Price reaches 1.1080 (4R) → Trailing activates, SL moves to 1.1040 (2R secured)
3. Price reaches 1.1140 (7R) → SL stays at 1.1040 (trailing only moves once to trail level)
4. Price reverses → Hits SL at 1.1040 → You keep +2R profit
All targets are based on R multiples (ratio of reward to risk). 1R = your stoploss distance. If SL is 20 pips, then 2R target = 40 pips profit.
Target Type Default: Fixed R Multiple
How the take profit level is calculated.
| Type | Description |
Fixed R Multiple | TP is placed at a fixed R distance. If Fixed R Target = 5, TP = entry + 5R. |
Fibonacci Extensions | Uses Fibonacci extension levels (1.618, 2.618, 4.236) as partial TP targets. |
Standard Deviation | Uses statistical deviation from the pattern's range for TP placement. |
Fixed R Target Default: 5.0
The R multiple for the main take profit. Example: 5.0 means your target is 5 times your risk. If risking 20 pips, target is 100 pips.
Use Partial Take Profit Default: true
When ON, the EA closes portions of the position at different R levels instead of waiting for a single TP. Great for locking in profits progressively.
TP1 Level / Close % Default: 1.618R / 30%
First partial close. When profit reaches 1.618R, close 30% of the position. Based on Fibonacci extension. Locks in early profits.
TP2 Level / Close % Default: 2.618R / 30%
Second partial close. When profit reaches 2.618R, close another 30%. Position is now 40% of original size.
TP3 Level / Close % Default: 4.236R / 40%
Final close. Close the remaining 40% at 4.236R. The trade is now fully closed.
Partial TP Example (Buy trade, 1R = 20 pips)
Entry: 1.1000, SL: 1.0980
TP1 at 1.618R (1.1032): Close 30% of position → Lock in +1.618R on 30%
TP2 at 2.618R (1.1052): Close 30% of position → Lock in +2.618R on 30%
TP3 at 4.236R (1.1085): Close remaining 40% → Lock in +4.236R on 40%
Average R captured: ~2.9R (weighted by percentages)
Restrict trading to specific hours and days of the week.
Use Time Filter Default: false
When OFF, the EA trades 24/5 (all market hours). When ON, it only opens new trades within the specified time window.
Start Hour / Start Minute Default: 8:00
The earliest time new trades can be opened (broker server time).
End Hour / End Minute Default: 20:00
The latest time new trades can be opened. Existing trades are NOT closed - only new entry is blocked.
Trade Monday - Friday Default: all true
Toggle specific days on/off. For example, disable Friday to avoid holding positions over the weekend.
Show Info Panel Default: true
Shows a live information panel on the chart with current status: active conditions, open trades, spread, etc. Turn off for cleaner chart.
Debug Mode Default: false
When ON, the EA prints detailed messages to the Experts tab for every signal detection, entry decision, and trade action. Useful for verifying signals are correct. Turn OFF for production/backtesting to avoid log clutter.
This EA is designed for thorough backtesting. Here's how to get the best results.
Step 1: Open Strategy Tester
In MetaTrader 5, go to
View → Strategy Tester (or press Ctrl+R).
Step 2: Configure the Tester
Expert: SMTDivergenceEA_v3
Symbol: Your target pair (e.g., EURUSD)
Period: Your target timeframe (e.g., M15, H1)
Model: "Every tick based on real ticks" (most accurate) or "Every tick" (faster)
Date range: At least 1-2 years for meaningful results
Deposit: 10,000 (standard for R-based testing)
Step 3: Configure EA Settings for Clean R Testing
Set
Lot Type = Risk Percentage and
Risk % = 1.0. This means every trade risks exactly 1% (1R). The final P/L in the report directly shows your cumulative R performance. Commission and swap are included automatically.
Step 4: Test Different Combinations
Run multiple backtests with different condition combinations to find what works best:
Test 1: C2 only (baseline)
Test 2: C2 + BB Filter
Test 3: C3 (with LTF confirmation)
Test 4: C3 + BB Filter
Test 5: C4 (with HTF filter)
Test 6: Compare entry modes (Market vs Limit vs Auto)
Multi-Symbol Data Required
Before backtesting, make sure you have downloaded history data for ALL 3 symbols. In MT5:
View → Symbols, find each symbol, and click "Download History". Without this data, the EA cannot detect divergences and will produce no signals.
Reading the Results
The
OnTester function reports:
Total Trades: How many trades were taken
Win Rate: Percentage of profitable trades
Net P/L: Final profit/loss including commissions and swap
With 1% risk per trade on a $10,000 account:
- Net P/L of $500 = gained 5R cumulative
- Net P/L of -$200 = lost 2R cumulative