Breakeven and R-Trail Manager — break-even at +1R and R-multiple trailing for any trade
Info
The Breakeven and R-Trail Manager — break-even at +1R and R-multiple trailing for any trade is a Expert Advisor for MetaTrader 5 that why manage in r r is the initial stop distance of a trade. Settings in R mean the same thing on gold at $1,800 and at $4,500, on Bitcoin and on EURUSD.
Usage
This tool is typically used for automated trading on major forex pairs and gold.
Platform
This Expert Advisor works exclusively on MetaTrader 5 (both build 600+ and newer versions).
Setup
Place the downloaded file in MQL5/Experts folder via File ? Open Data Folder in MetaTrader 5.
How to Install and Use Breakeven and R-Trail Manager — break-even at +1R and R-multiple trailing for any trade
1. Installation: Open the "File" menu, select "Open Data Folder," navigate to MQL/Experts, paste your file, and restart the terminal.
2. Activation: Drag the EA from the Navigator onto a chart, ensure "Allow live trading" is checked in the Common tab, and verify the AutoTrading button is green.
3. Optimization: Right-click your chart, choose "Expert List," click "Properties" to adjust inputs, and save your preferred setup as a set file for future use.
4. Maintenance: Regularly check the "Experts" tab in the terminal window to monitor trade logs and potential execution errors.
Frequently Asked Questions
Q: Why is my EA not opening trades? A: Check the "AutoTrading" button, ensure "Allow live trading" is enabled, and verify your broker allows automated trading on your account type.
Q: Can I run multiple EAs on one chart? A: No, each chart can only host one active EA; however, you can open multiple charts for different currency pairs to run several EAs.
Q: What does the "smiley face" icon mean? A: A smiley face in the top-right corner of the chart indicates the EA is successfully running; a frowny face means it is disabled.
What this tool does
Why manage in R R is the initial stop distance of a trade.
Typical Use Case
This Expert Advisor excels in automated trading and technical analysis on MetaTrader 5.
Compatible Platform & Setup
This Expert Advisor works on MetaTrader 5. Place the file in the MQL5/Experts folder and restart the terminal.
Description & Settings
Related: Supertrend EA for Gold: Automated Trading with Breakeven - another powerful expert for MetaTrader 5 traders.
Why manage in R
Also recommended: Trailing Stop Breakeven Manager for MT5 - similar expert with strong performance on MetaTrader 5.
R is the initial stop distance of a trade. Settings in R mean the same thing on gold at $1,800 and at $4,500, on Bitcoin and on EURUSD. You set the rule once and it scales with every trade.
Effect of break-even
In the author's Bitcoin breakout tests, moving the stop to break-even at +1R was the most effective single change. The win rate rose from about 20% to about 50%, and the longest losing streak fell from 16–21 trades to 8–9. Many would-be losers became small scratch trades, and the big winners were not touched.
Logic
When the manager first sees a position with a stop, it stores R = |open − SL| in a terminal global variable keyed by the ticket. The value survives terminal restarts and later stop changes.
When the reference price reaches
+BE R
, the stop moves to entry ±
Lock R
.
When it reaches
+Trail start R
, the stop trails
Trail R
behind the reference price.
The stop only ever moves in the trade's favour.
The reference price is the
close of the last completed bar
of the chosen timeframe (default H1), which is how most backtests evaluate exits. It can also use the live bid/ask.
double gainR=(is_buy?px-open:open-px)/R; if(gainR>=InpBE_R) // break-even + lock new_sl=is_buy?MathMax(sl,open+InpLock_R*R):MathMin(sl,open-InpLock_R*R); if(InpTrailStartR>0 && gainR>=InpTrailStartR) // R trail new_sl=is_buy?MathMax(new_sl,px-InpTrail_R*R):MathMin(new_sl,px+InpTrail_R*R);
Inputs
Input
Default
Description
Magic filter
−1
−1 all trades, 0 manual only, or one magic number
Only chart symbol
true
Restrict to the chart symbol
Break-even trigger
1.0 R
Distance that triggers break-even
Locked profit
0.1 R
Profit locked at break-even
Trail start
2.0 R
0 = no trailing
Trail distance
2.0 R
Distance behind price
Closed bars only
true
Evaluate once per bar
Bar timeframe
H1
Timeframe for the closed-bar check
Safety
Positions without a stop are ignored, because R cannot be defined.
Stops level and freeze level are checked before every change, prices are rounded to the tick size, and unchanged stops are never sent (no error 10025).
Global variables of closed positions are cleaned every 30 seconds.
You may also like: Supertrend Scalper with Breakeven Win Rate Panel - excellent alternative for expert users on MetaTrader 5.
Source Code
#property copyright "RobotFX"
#property link "https://robotfx.org"
#property version "1.00"
#property description "This code is educational. Feel free to use, modify and upgrade as you wish. Visit ROBOTFX.ORG for professional trading tools"
#include <Trade\Trade.mqh>
bool TH_TradeAllowed(const string symbol,string &why)
{
why="";
if(!TerminalInfoInteger(TERMINAL_CONNECTED))
{ why="terminal not connected"; return(false); }
.......
⚠ Limitations & Risk Warning
- This tool is provided for educational and testing purposes only.
- Past performance does not guarantee future results.
- Trading involves substantial risk of loss. Use on a demo account first.
- Results may vary depending on market conditions, broker, and settings.
- We recommend thorough backtesting and forward testing before using with real funds.