Mirage Trading System | Buy Trading Indicator for MetaTrader 5
This functionality is available in the trading system
Main Manual : Mirage Trading System - Trading Systems - 5 February 2026 - Traders' Blogs
Trailing Stop Loss (TSL) User Guide
Table of Contents
- What is Trailing Stop Loss?
- Two TSL Methods
- Input Configuration Guide
- How TSL Works — Signal Lifecycle
- Activation R:R Parameter — When Does TSL Start?
- Real-World Examples
- Frequently Asked Questions (FAQ)
- Usage Tips
1. What is Trailing Stop Loss?
Regular Stop Loss (SL) stays fixed in one place. You set SL at 1990.00, and it stays there forever — even if price has risen to 2030.00.
Trailing Stop Loss (TSL) is different. It automatically moves in your favor when price advances. As price moves up, TSL moves up with it. When price stalls or reverses, TSL holds the best position it reached.
Result: you protect your profits without needing to watch the chart.
Easy to Understand Analogy
Think of TSL as a friend walking behind you at a fixed distance. As you move forward, they move forward too — but they never step backward. If you suddenly turn and run backward, they stand still and block you.
What Problem Does TSL Solve?
| Situation | Without TSL | With TSL |
|---|---|---|
| Price rises strongly then reverses suddenly | Order hits old SL — loses full risk | TSL has moved — exits with profit |
| Price touches TP1, then falls below Entry | Remaining profit is given back | TSL protects profit behind TP1 |
| Price runs far beyond all preset TPs | Must watch and exit manually | TSL auto-trails and exits on reversal |
2. Two TSL Methods
The system provides two ways to calculate TSL position. Both follow the advance-only, never-retreat rule — but they calculate differently.
Method 1: Donchian TSL (Default — Recommended)
Donchian TSL places the trailing line at the actual market high or low in the last N candles.
- BUY order: TSL = Lowest Low in last N candles
- SELL order: TSL = Highest High in last N candles
When price rises (BUY order), the lowest low of the last N candles also gradually increases — because old candles (with lower lows) drop out of the N-candle window. TSL automatically ratchets up step by step.
Advantages of Donchian TSL:
- TSL sits at actual market support/resistance, not arbitrary numbers
- Less likely to be triggered by short-term price spikes with no technical significance
- Perfect for structure-based trading
Method 2: ATR TSL
ATR TSL calculates trailing position based on average volatility at activation time.
- BUY order: TSL = Highest price reached - (ATR × Multiplier)
- SELL order: TSL = Lowest price reached + (ATR × Multiplier)
Key point: ATR is captured (frozen) at TSL activation time and does not change afterward, even if market volatility increases or decreases. This ensures consistent and predictable trailing distance.
Advantages of ATR TSL:
- Trailing distance is fixed and consistent throughout the trade
- Easy to predict exact TSL level at any price
- Suitable when you want risk control based on market volatility
Quick Comparison of Two Methods
| Criteria | Donchian TSL | ATR TSL |
|---|---|---|
| Calculation basis | Actual High/Low of N candles | Average volatility (ATR) |
| Does ATR update continuously? | N/A | No — frozen at activation |
| Best for | Structure-based trading | Volatility-based trading |
| Default? | Yes (recommended) | No |
| Main parameter | Donchian Period (default 20) | ATR Multiplier (default 2.5) |
3. Input Configuration Guide
All TSL parameters are in the "=== TRAILING STOP LOSS ===" group in the indicator's Properties panel.
How to open: Double-click the indicator on chart (or press F7) → "Inputs" tab → Scroll down to find TRAILING STOP LOSS group.
Complete Parameters Table
| MT5 Display Name | Type | Default | Explanation |
|---|---|---|---|
| Enable Trailing Stop Loss (auto-move SL) | Toggle | On (true) | Enable or disable entire TSL feature |
| TSL Method (Donchian channel or ATR) | Select | Donchian | Choose how to calculate trailing position |
| ├─ Donchian Period (5-100, 20=standard) | Integer | 20 | Number of candles to find High/Low for Donchian TSL |
| ├─ ATR Multiplier (x ATR, 2.5=standard) | Float | 2.5 | Multiplier for ATR in ATR TSL |
| Start Trailing at R:R (0=immediately) | Float | 0.0 | Minimum R:R to reach before TSL starts trailing |
Note: Parameters with ├─ only take effect when the corresponding TSL method is selected. If using Donchian TSL, ATR Multiplier is ignored and vice versa.
Parameter-by-Parameter Guide
Enable Trailing Stop Loss Disable this if you want to manage SL completely manually. When disabled, static SL lines still display but don't move.
TSL Method Choose Donchian if you trade by market structure (swings, BOS, zones). Choose ATR if you want even, predictable trailing distance.
Donchian Period (5–100) Number of candles to scan for lowest low (BUY) or highest high (SELL). Smaller Period → TSL closer to price, tighter trailing, easier to trigger early. Larger Period → TSL farther away, more room for the order to breathe.
| Period | Characteristics | Best For |
|---|---|---|
| 5–10 | Very tight trailing | Scalping, quick profit protection |
| 15–25 | Balanced (default 20) | Most situations, H1–H4 |
| 30–50 | Wider trailing | Swing trading, D1 |
| > 50 | Very wide trailing | Long-term position trading |
ATR Multiplier (when using ATR TSL) Multiplier to apply to ATR to determine trailing distance. Default 2.5 — slightly wider than initial ATR SL (typically 2.0), to avoid trailing too tightly and exiting prematurely.
Start Trailing at R:R See detailed explanation in Section 5.
4. How TSL Works — Signal Lifecycle
TSL does not activate immediately when a signal appears. It goes through 5 states over the signal's lifecycle.
5 TSL States
[INACTIVE] --> [TRACKING] --> [HIT]
|
[LOCKED]
|
[EXPIRED]
| State | Meaning | Transition Condition |
|---|---|---|
| INACTIVE | TSL registered, not yet trailing | Price hasn't touched Entry, or Activation R:R not yet reached |
| TRACKING | Actively trailing — TSL moves with price | Price touches Entry AND Activation R:R reached (if set > 0) |
| LOCKED | TSL locked at breakeven (disabled by default) | When lockOnTP1 setting is enabled |
| HIT | TSL touched — signal ends | Price reverses and hits TSL line |
| EXPIRED | Signal expired, TSL removed | Signal exceeds wait time |
Typical Lifecycle (BUY order example)
Signal candle appears
|
v
[INACTIVE] — TSL registered, static SL displaying
|
| Price touches Entry
v
[TRACKING] — TSL starts moving up
|
| Price continues rising → TSL ratchets step by step
| TSL: 1990 → 1998 → 2005 → 2012 → 2020
|
| Price reverses, falls and hits TSL line (2020)
v
[HIT] — Exit order at 2020 with profitRatchet Rule — Advance Only, Never Retreat
This is TSL's core rule. No matter how much price oscillates back and forth in between, TSL never retreats toward risk. It only moves when doing so improves your position.
BUY — TSL only ratchets UP:
Bar 1: TSL = 1990 ← initial set
Bar 5: TSL = 1995 ← increase because price rose
Bar 8: TSL = 1995 ← price fell slightly, TSL DOES NOT decrease
Bar 12: TSL = 2002 ← price rose again, TSL increases
SELL — TSL only ratchets DOWN:
Same logic but in opposite direction.
Visual Display on Chart
| State | TSL Line Color | Symbol |
|---|---|---|
| INACTIVE | Not displayed | — |
| TRACKING (BUY) | Orange — staircase | None |
| TRACKING (SELL) | Yellow — staircase | None |
| LOCKED | Lime Green | None |
| HIT | — | X mark at hit point |
Orange symbolizes movement and energy. Lime green when LOCKED signals safety — profit protected.
5. Activation R:R Parameter — When Does TSL Start?
Problem When TSL Starts Immediately
If TSL starts trailing right when you enter (Activation R:R = 0), in the early stage of the trade when price has just touched Entry and is still oscillating, TSL can be triggered by normal pullbacks — even if the signal is still valid.
How Activation R:R Works
The "Start Trailing at R:R" parameter (default 0.0) allows you to delay TSL until the trade has reached a certain profit level.
Activation R:R = 0.0 (default)
→ TSL starts IMMEDIATELY when price touches Entry
→ Best when you want maximum protection from the start
Activation R:R = 1.0
→ TSL only starts when price reaches R:R 1:1 (profit equals risk)
→ Avoids being triggered by early pullbacks
Activation R:R = 0.5
→ TSL starts when price reaches half of risk amount
→ Balances early protection with avoiding premature trigger
Example Walkthrough
BUY XAUUSD order:
Entry: 2010.00
SL: 1995.00
Risk (R) = 15.00 USD
Activation R:R = 1.0 → TSL activates when price reaches:
2010.00 + 15.00 × 1.0 = 2025.00
Before price reaches 2025.00:
→ TSL is in INACTIVE state, does not move
→ SL stays at 1995.00
When price touches 2025.00:
→ TSL switches to TRACKING
→ Starts trailing from current Donchian/ATR positionWhen Should You Use Activation R:R > 0?
| Situation | Recommended Setting |
|---|---|
| Standard strategy, want early protection | 0.0 (default) |
| Market tends to pullback after Entry | 0.5 — 1.0 |
| Want TSL to protect only real profits | 1.0 |
| Swing trading, longer-term trades | 1.0 — 2.0 |
6. Real-World Examples
Example 1: BUY Order with Donchian TSL
Scenario: BUY signal appears on XAUUSD H1. TSL Method = Donchian, Period = 20, Activation R:R = 0.0.
Initial Parameters:
Entry: 2010.00
SL: 1995.00
Risk (R) = 15.00 USD
TP1: 2025.00 (R:R 1.0)
TP2: 2040.00 (R:R 2.0)TSL Evolution by Phase:
| Bar | Close Price | Donchian Low (20 candles) | TSL Position | State |
|---|---|---|---|---|
| Entry | 2010.00 | 1995.00 | 1995.00 | TRACKING begins |
| +5 | 2018.00 | 1997.00 | 1997.00 | Trail up +2.00 |
| +10 | 2025.00 (TP1 hit) | 2001.00 | 2001.00 | Trail up +4.00 |
| +15 | 2031.00 | 2006.00 | 2006.00 | Trail up +5.00 |
| +18 | 2027.00 | 2006.00 | 2006.00 | Price falls — TSL HOLDS |
| +22 | 2038.00 (TP2 hit) | 2010.00 | 2010.00 | Trail up +4.00 |
| +25 | 2044.00 | 2015.00 | 2015.00 | Trail up +5.00 |
| +28 | 2016.00 | — | 2015.00 | Price drops sharply, hits TSL |
| HIT | 2015.00 | — | — | Exit at +5.00 USD profit |
Result: Order exits at 2015.00 — profit 5.00 USD/oz even though price didn't reach TP3/TP4. Without TSL, the static SL at 1995.00 would have been hit when price fell to 2016 (loss 5.00 USD/oz). TSL turned a losing trade into a winning one.
Example 2: SELL Order with ATR TSL
Scenario: SELL signal on XAUUSD H1. TSL Method = ATR, ATR Multiplier = 2.5, ATR at activation time = 8.00 USD. Activation R:R = 1.0.
Initial Parameters:
Entry: 2050.00
SL: 2063.00
Risk (R) = 13.00 USD
TP1: 2037.00 (R:R 1.0)
Activation level = 2050.00 - 13.00 × 1.0 = 2037.00
ATR Trailing distance = 8.00 × 2.5 = 20.00 USD (frozen here)
TSL Evolution:
| Bar | Close Price | Lowest Price Seen | TSL Position | State |
|---|---|---|---|---|
| Entry | 2050.00 | 2050.00 | — | INACTIVE (waiting for R:R 1.0) |
| +8 | 2037.00 (TP1 hit) | 2037.00 | 2037.00 + 20 = 2057.00 | TRACKING activates |
| +12 | 2030.00 | 2030.00 | 2030.00 + 20 = 2050.00 | Trail down |
| +16 | 2022.00 | 2022.00 | 2022.00 + 20 = 2042.00 | Trail down |
| +20 | 2028.00 | 2022.00 | 2042.00 | Price recovers — TSL HOLDS |
| +23 | 2043.00 | 2022.00 | 2042.00 | Price continues up, hits TSL |
| HIT | 2042.00 | — | — | Exit at -8.00 USD profit |
Result: SELL order exits at 2042.00 — profit 8.00 USD/oz (from Entry 2050.00). ATR trailing distance stayed fixed at 20 pips throughout the trade because of the freeze mechanism at activation.
7. Frequently Asked Questions (FAQ)
Q1: Does TSL completely replace the initial SL?
No. TSL supplements the initial SL, it does not replace it. When a new signal appears, the static SL is set immediately to protect in case price never touches Entry. When price enters the trade and TSL starts trailing, TSL gradually takes over the protection role. If TSL hasn't moved far enough to be better than static SL, the static SL remains the primary protection.
Q2: Does TSL automatically place a real order on MT5?
No. This is an indicator (not an EA/robot). The TSL line on the chart is a visual guide for your reference — you set the SL manually according to it. The system tracks and calculates, but does not place orders automatically. To automate, you would need a separate EA integration.
Q3: Does TSL continue trailing after all TPs are hit?
Yes. TSL continues trailing even after TP1/TP2/TP3/TP4 are all hit. This is the mechanism to catch trades that run further than anticipated. TSL only stops when hit (HIT state) or signal expires (EXPIRED state).
Q4: Is the TSL Donchian Period the same as the initial SL Donchian Period?
No. TSL uses an independent Donchian calculation, completely separate from the initial SL. You can use Period 20 for initial SL and Period 10 for TSL — or vice versa. These two parameters don't affect each other.
Q5: Why does the TSL line sometimes jump a large step unexpectedly?
With Donchian TSL, when an old candle with very low low (outlier) drops out of the N-candle window, Donchian Low jumps up. This is normal and correct behavior — TSL reflects the actual structure within the current N-candle window. If the jump feels too large, try increasing Period or switch to ATR TSL.
Q6: How does TSL LOCKED state work?
LOCKED state occurs when TSL is locked at breakeven. This feature is disabled by default. When enabled (lockOnTP1), after TP1 is hit, TSL automatically locks at Entry — ensuring the trade cannot lose. The TSL line turns lime green to signal safety state.
Q7: What happens if I disable TSL mid-trade?
If you disable "Enable Trailing Stop Loss" while a signal is TRACKING, TSL stops moving immediately. The TSL line disappears from the chart. The initial static SL is not automatically restored. Recommendation: don't disable TSL while a trade is running.
8. Usage Tips
Tip 1: Start with Donchian Period 20 and Don't Change Too Quickly
The default settings (Donchian Period 20, Activation R:R 0.0) are designed to work well on H1–H4. Observe actual behavior for at least 2–3 weeks before adjusting. Changing too quickly based on a few trades doesn't provide reliable statistics.
Tip 2: Use Activation R:R = 1.0 on Pullback-Prone Markets
XAUUSD often has strong pullbacks right after Entry. If you see TSL triggered shortly after Entry despite valid signals, try setting Activation R:R = 1.0. TSL will stay put until the trade is 1R in profit, then start protecting.
Tip 3: Use ATR TSL During High Volatility Sessions
London session (14:00–17:00 VN) and New York session (20:00–23:00 VN) often have short spikes unrelated to structure. Donchian TSL can be triggered by such spikes. During these sessions, ATR TSL with Multiplier 2.5–3.0 provides more even trailing, less false triggers.
Tip 4: Check TSL Statistics on Dashboard Regularly
The dashboard displays Wins/Losses/Net Pips specifically for TSL. If TSL Losses > Wins, consider increasing Donchian Period (TSL is too tight) or increasing Activation R:R (TSL triggers too early). If Net Pips is negative despite Wins > Losses, TSL is exiting too early — try increasing Period to give the trade more room.
Tip 5: Combine TSL with Partial Closing Strategy
TSL works best combined with a partial closing strategy:
TP1 hit: Manually close 25% position → reduce risk
TP2 hit: Close another 25% → profit secured
TP3+: Let TSL manage remainder — catch bigger moves
→ Result: never lose all profits
while capturing extended trends
Quick Summary
This documentation applies to version 1.15. Last updated: 2026-02-17. Author: Ich Khiem Nguyen — https://www.mql5.com/en/users/khiemni/seller All rights reserved.


