Break Even and Trailing Stop EA MT5
- Utilitys
- Udeme Anietie Okon
- Version: 1.1
- Aktivierungen: 10
This EA ("Break-Even and Trailing Stop EA") is designed to manage open trades automatically, by:
-
Moving the stop loss (SL) to break-even when certain conditions are met.
-
Applying a trailing stop after break-even is reached, to secure more gains.
It does NOT open new trades — it only manages existing trades.
You can choose different symbols to apply Break Even and Trailing Stop separately.
For the MT4 Version,click this link: https://www.mql5.com/en/market/product/83525
📋 HOW IT WORKS INTERNALLYStep 1: Inputs / Settings
When you load the EA, it asks you to configure:
Input | Purpose |
---|---|
BE_SYMBOLS | Comma-separated list (like "EURUSD,GBPUSD" ) — these are the symbols where Break Even will happen. |
ENABLE_BREAK_EVEN | Turn Break Even ON/OFF. |
USE_PIPS_TRIGGER | Should BE trigger based on fixed pips, or a percentage of TP? |
BE_TRIGGER_PIPS | How many positive pips to reach before BE is activated (if using pips trigger). |
BE_TRIGGER_PERCENT | How much % of TP must be achieved before BE (if using percent trigger). |
BE_BUFFER | After moving to break even, add this many extra pips for safety. |
Input | Purpose |
---|---|
TRAIL_SYMBOLS | Symbols to apply trailing stop to (can be different from BE symbols). |
ENABLE_TRAILING_STOP | Turn Trailing Stop ON/OFF. |
USE_PIPS_TRAILING | Should trailing be based on fixed pips, or % of TP? |
TRAILING_START_PIPS | How many positive pips before trailing starts (if using pips trigger). |
TRAILING_STOP_PIPS | How big the trailing stop distance should be (if using pips). |
TRAILING_STOP_PERCENT | If using %, how much TP to reach before starting trailing stop. |
TRAILING_STOP_DISTANCE_PERCENT | Distance of trailing stop, based on TP %. |
TRAILING_STEP | Minimum number of pips the price must move before SL adjusts again. |
Step 2: On Every Tick (Price change)
Every time the price changes (tick event), the EA will:
-
First, try to apply Break Even (if enabled).
-
Second, apply Trailing Stop (if enabled).
However, If both break even and trailing stop are enabled for the same symbol:
✅ Break Even has priority.
✅ Only after Break Even conditions are satisfied will Trailing Stop work.
Inside the MoveToBreakEven() function:
-
Scan all open positions.
-
For each position:
-
Check if its symbol is listed inside BE_SYMBOLS .
-
Check if Break Even is enabled.
-
If current gains is enough (either reaching fixed pips or % of TP), then:
-
Move the Stop Loss (SL) to entry price + small buffer.
-
Only moves if the current SL is not already better than entry price.
-
-
🔵 Example:
You bought EURUSD at 1.1000.
You set BE_TRIGGER_PIPS = 20 .
When price reaches 1.1020, the EA will:
-
Move your SL from 1.0970 (original) → 1.1002 (Entry + 2 pips buffer).
Inside the ApplyTrailingStop() function:
-
Scan all open positions.
-
For each position:
-
Check if its symbol is listed inside TRAIL_SYMBOLS .
-
Check if Trailing Stop is enabled.
-
If Break Even was already achieved (SL at or beyond Entry), and:
-
Price has moved enough (fixed pips or % of TP),
-
Then trail the stop loss to protect more gains.
-
-
Only move SL if the price moved enough beyond the last SL ( TRAILING_STEP distance).
-
🔵 Example:
After Break Even is hit:
-
EURUSD moves from 1.1002 → 1.1030.
-
EA moves SL from 1.1002 → 1.1010 (20 pips trailing distance, depending on settings).
-
Every time price moves another 5 pips ( TRAILING_STEP ), SL will move again.
-
Pip Size Handling:
Automatically adjusts based on broker (3 digits, 5 digits, etc.) using SYMBOL_POINT . -
Precision Control:
Proper double handling to avoid rounding issues. -
Safe Checks:
-
Separate Lists:
You can:-
Apply Break Even only to certain symbols.
-
Apply Trailing Stop to other symbols.
-
Or apply both to the same symbols.
-
- Where BE and trailing stop are enabled for the same pair, trailing stop only starts after Break Even is handled. So no conflicts — it’s safe and logical.
- Each Position is checked separately.
The EA handles multiple trades at the same time without mixing them up.
Let’s say you configure:
BE_SYMBOLS = "EURUSD,GBPUSD"
TRAIL_SYMBOLS = "EURUSD,USDJPY"
ENABLE_BREAK_EVEN = true
ENABLE_TRAILING_STOP = true
-
EURUSD trades: BE first at +20 pips → then Trailing Stop after.
-
GBPUSD trades: Only BE.
-
USDJPY trades: Only Trailing Stop (because no BE was configured for USDJPY).
This gives you full flexibility! 🔥
📊 SUMMARY TABLE
Feature | Supported? | Details |
---|---|---|
Break Even before Trailing | ✅ | BE is always checked first. |
Use Pips or percentage(%) | ✅ | You choose based on inputs. |
Separate Symbols for BE and Trailing | ✅ | Full control. |
Adjust for broker decimal digits | ✅ | Automatically. |
Trade opening | ❌ | Only manages existing trades. |
Works on all brokers | ✅ | ECN, Standard, 5/3 digit, etc. |
This EA is simple to use but powerful — you can now relax and focus on trade entries, while the EA handles:
-
Risk Management
-
Protection of Gains
-
Locking in Wins Automatically
✅ Professional-grade SL management.
✅ Flexible, customizable, and safe.