Voir comment télécharger gratuitement des robots de trading
Retrouvez-nous sur Facebook !
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

Supertrend EA Gold Breakeven - expert pour MetaTrader 5

Cristhian Alexander Gaibor Cuasquer
Cristhian Alexander Gaibor Cuasquer
4.7 (41)
Trader et membre de MQL5 depuis 2017.
Vues:
24
Publié:
MQL5 Freelance Besoin d'un robot ou d'un indicateur basé sur ce code ? Commandez-le sur Freelance Aller sur Freelance

A Supertrend flip on Gold (XAUUSD) counts only when the candle closes beyond the band. At every new candle this EA rebuilds the Supertrend on closed bars, ATR 10 and multiplier 3.0 by default, and opens one position when the last closed candle changed the trend: a buy on a flip up, a sell on a flip down. The lot is calculated from the stop distance, so the trade risks the percent of balance or equity you set.

The stop goes at the Supertrend line plus a buffer, or at a fixed distance in points. The target is a multiple of that stop distance, 2.0 by default. When price moves 1.0 times the stop distance in favour, the stop moves to the entry price plus an offset. An opposite flip closes the position.

Supertrend follows trends and flips back and forth in a range, so sideways markets bring losing streaks. If the calculated lot is below the broker minimum, the minimum lot is used and the risk is higher than your percent. Test in the Strategy Tester first.

Supertrend EA Gold Breakeven on a XAUUSD M15 chart in MetaTrader 5: buy on the closed flip, stop below the Supertrend line, stop moved to breakeven and target at 2.0 times the stop

Settings

  • ATR period and ATR multiplier: defaults 10 and 3.0. The bands are the candle midpoint, (high + low) / 2, plus and minus ATR times the multiplier.
  • Closed bars used to build the Supertrend: default 300. The calculation starts that many bars back and runs up to the last closed candle.
  • Allowed direction: buy and sell, buy only or sell only.
  • Close the position on the opposite flip: on by default.
  • Lot mode: fixed lot, risk percent of balance (default) or risk percent of equity. Fixed lot 0.01, Risk percent per trade 1.0. The lot is rounded down to the volume step and kept between the minimum and maximum volume of the symbol.
  • Stop loss mode: at the Supertrend line (default) or fixed distance. Extra distance beyond the Supertrend line: 50 points. Fixed stop loss: 500 points, used only in fixed mode. The stop is never placed closer than the broker stops level plus the current spread.
  • Take profit as a multiple of the stop distance: default 2.0, 0 means no take profit.
  • Move the stop to breakeven: on. Breakeven starts at this multiple of the stop distance: 1.0. Breakeven offset beyond the entry price: 20 points.
  • Maximum spread to open: in points, 0 means no limit. Above the limit the signal is skipped.
  • Time filter: off by default. Start and end hour in server time, new positions open only inside the window.
  • Magic number, order comment, max slippage in points and show status on chart.

What it needs

Any symbol and any timeframe, on hedging or netting accounts. All distances are in points of the symbol, so check the values for your broker digits. It keeps one position at a time for its symbol and magic number, and a flip that arrives while a position is still open does not add a second one. Before every order it checks the free margin with OrderCalcMargin and skips the order if it is not enough. Decisions are taken once per candle on closed bars, the breakeven is checked on every tick. The status is a plain text comment on the chart. The EA does not draw the line: to see it, add Supertrend Gold Signals with the same ATR period and multiplier, it uses the same formula. This first version passed the automatic validation of the MQL5 Code Base. The defaults are a starting point, not an optimised set.

Make it yours

Run your own backtests on XAUUSD, XAGUSD, EURUSD, GBPUSD, US30 and NAS100, on M15, H1 and H4, and compare multipliers 2.0, 3.0 and 4.0. The code is split in small functions you can lift into your own EA: XP_Supertrend returns the trend of the last two closed bars and the line, XP_Lot sizes the position from a price distance, XP_MarginOk checks the margin and XP_Breakeven moves the stop. XP_TryOpen is the place to plug a session or news filter, a higher timeframe trend check, Smart Money Concepts levels or support and resistance before the order is sent.

About this code

Open source. Use it as it is, adapt it, build your own version on top of it.

New versions and new tools are announced first on my MQL5 channel: https://www.mql5.com/en/channels/xander

Questions, suggestions and your own backtests are welcome in the Xander Lab group: https://www.mql5.com/en/messages/02eec85e4364dd01

More tools on my profile: https://www.mql5.com/en/users/09151993a

Provided as is, use at your own risk.

Related

Changelog

  • v1.0 - 2026-11-14 - Initial release
Daily Pivot Points – Classic, Fibonacci and Camarilla Daily Pivot Points – Classic, Fibonacci and Camarilla

Daily pivot point with three resistance levels and three support levels, using Classic, Fibonacci or Camarilla formulas.

CreyesHistoryCSV - Closed trades to CSV with summary CreyesHistoryCSV - Closed trades to CSV with summary

Script that exports the closed trades of your account to a CSV file and prints a short summary: trades, win rate, net result and profit factor.

Accelerator Oscillator (AC) Accelerator Oscillator (AC)

The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.

MACD Signals MACD Signals

Indicator edition for new platform.