Voir comment télécharger gratuitement des robots de trading
Retrouvez-nous sur Telegram !
Rejoignez notre page de fans
Un script intéressant ?
Poster un lien vers celui-ci -
laisser les autres l'évaluer
Vous avez aimé le script ? Essayez-le dans le terminal MetaTrader 5
Experts

Breakeven and R-Trail Manager — break-even at +1R and R-multiple trailing for any trade - expert pour MetaTrader 5

Shipra Gupta
Shipra Gupta
Je suis Shipra Gupta, trader et développeuse de stratégies quantitatives avec une solide formation en mathématiques, économie et systèmes de trading algorithmique. Au fil des années, j’ai travaillé activement sur les marchés du forex, de l’or, des indices, des matières premières et des
Vues:
104
Publié:
MQL5 Freelance Besoin d'un robot ou d'un indicateur basé sur ce code ? Commandez-le sur Freelance Aller sur Freelance


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. 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


  1. 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.
  2. When the reference price reaches +BE R, the stop moves to entry ± Lock R.
  3. When it reaches +Trail start R, the stop trails Trail R behind the reference price.
  4. 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.

Author: Shipra Gupta (SGupta30) · the author's gold and Bitcoin EAs include break-even and R-based exits built in.


ATR Trailing Stop Line (Chandelier Exit) ATR Trailing Stop Line (Chandelier Exit)

ATR Trailing Stop Line (Chandelier Exit): a volatility-based trailing stop that hangs below the highest high in an up-trend and rises above the lowest low in a down-trend, with trend-flip arrows, an on-chart status label and optional alerts.

Kaufman Adaptive Moving Average (KAMA) Ribbon Kaufman Adaptive Moving Average (KAMA) Ribbon

A ribbon of Kaufman Adaptive Moving Averages with growing Efficiency Ratio periods, drawn in a monochrome gradient, with an on-chart label showing whether the ribbon is bullish, bearish or mixed.

MTF Trend Dashboard — trend, position and volatility on six timeframes at a glance MTF Trend Dashboard — trend, position and volatility on six timeframes at a glance

One on-chart table for M15, H1, H4, D1, W1 and MN1: EMA slope, price vs EMA, Donchian position, ATR percentile and a combined UP / DOWN / RANGE regime. Completed bars only. Any symbol.

Range Filter Buy and Sell Range Filter Buy and Sell

A faithful MetaTrader 5 port of the TradingView "Range Filter Buy and Sell 5min" (DonovanWall / guikroth / tvenn): range filter line, target bands, Buy/Sell arrows and bar colors, no repainting, alerts (popup, sound, push, e-mail) and a signal statistics panel.