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

Daily loss and max loss guard - prop firm rules in one include - bibliothèque pour MetaTrader 5

Lukas Szyry
Lukas Szyry
Gold Trading Specialist | XAUUSD Expert Advisors
Je développe des Expert Advisors basés sur des règles pour l'or (XAUUSD) sur MetaTrader 5. Je me concentre sur des systèmes robustes pour la croissance du compte à long terme : pas de martingale, pas de grille, pas de moyenne à la baisse.
Vues:
120
Publié:
MQL5 Freelance Besoin d'un robot ou d'un indicateur basé sur ce code ? Commandez-le sur Freelance Aller sur Freelance

Most prop firm accounts are not lost by a bad strategy but by one bad day. The daily loss rule counts the floating loss too, and it counts from the start of the day, not from your last trade. A stop-loss on every trade does not help if three trades go wrong in the same morning.

This include does the counting for you and acts before the firm does:

  • daily limit in % of the initial balance (prop style) or of the day start
  • day start = balance, or the higher of balance and equity at the reset hour
  • max limit static (initial balance) or trailing (highest equity seen)
  • warning level: from e.g. 80 % of the daily limit no new trades until the next day
  • breach: closes all positions, deletes pending orders, blocks until the next day (daily) or until Reset() (max)
  • all values are kept in global variables of the terminal, so a restart in the middle of the day does not forget the day start or a breach
  • guard the whole account (magic -1) or only one EA
LS_EquityGuard guard;
guard.Init(5.0, 10.0);            // OnInit: 5 % daily, 10 % max, prop defaults
guard.Update();                   // OnTick and/or OnTimer
if(guard.CanOpen()) ...           // false after warning level or breach
guard.RoomMoney()                 // money left until the nearest limit
guard.Fits(riskMoney)             // would a full stop-loss still stay above both limits?
guard.StatusText()                // one line for the journal or Comment()

Set your limits a bit tighter than the rule of your firm: the price can jump between two ticks and the close happens on the next one. In the real tick test below the overshoot was between 0.07 and 10.27 USD on a 10,000 USD account.

The demo EA works as an account guard on a live or demo account: attach it to any chart, it opens no trades and checks once per second. Only in the strategy tester "Test lots" opens one buy per day without a stop-loss, so you can watch the guard work. The screenshot: XAUUSD real ticks October 2026, 10,000 USD, 0.3 lot per day - three daily stops, then the max stop, after that every test trade is skipped.

LS_EquityGuard_Demo journal, XAUUSD real ticks

Return-to-Mean Clock: How Many Bars Does Price Take to Come Back to the Moving Average Return-to-Mean Clock: How Many Bars Does Price Take to Come Back to the Moving Average

Measures how long price takes to come back to its moving average. The histogram shows the distance of the close from an EMA in ATR. Every time that distance first reaches a stretch level (1, 2 and 3 ATR by default), the indicator follows the stretch until the close is back at the average, runs further, or the wait is over. A panel shows, for each level, how often price came back, how often it ran further first, and the median and 80th-percentile number of bars the return took. One line can be pasted into a comment to compare symbols. It is a statistics tool and gives no trade signals.

Prop Firm Risk Manager - daily loss and trailing drawdown guard Prop Firm Risk Manager - daily loss and trailing drawdown guard

Account guard for prop-firm challenges. It does not open trades: it watches the whole account (manual trades and any EA) and closes everything before the firm's limits are broken. - Daily loss limit: closes all and blocks trading until the next day. - Max drawdown: static or trailing (can lock at the start balance); closes all and locks the account. - Optional profit-target lock, max lots / max positions, Friday close. - On-chart panel (equity, today's P/L, daily and drawdown room left) and push alerts. - Equity peak and lock are saved per account, so a restart does not reset the protection. Main inputs: StartBalance, DailyLossUSD, DDMode, MaxDDUSD, LockAtStart, safety buffers, TargetUSD, MaxOpenLots, MaxOpenPositions, FridayCloseOn, ResetLock. Attach to any one chart, any symbol and timeframe, with Algo Trading enabled.

Hotkeys: keyboard shortcuts for MQL5 experts and indicators, set in the inputs Hotkeys: keyboard shortcuts for MQL5 experts and indicators, set in the inputs

One include file that gives your EA or indicator keyboard shortcuts the user types into the inputs, such as Shift+B. Each press fires one action, Shift+B never fires on a plain B, and a shortcut that cannot work is refused at start with the reason.

Inside Bar Engulfing Scanner Inside Bar Engulfing Scanner

Engulfing and inside bar scanner for Gold (XAUUSD) and any symbol on MT5. Marks bullish and bearish engulfing candles and inside bars on closed bars, draws the mother bar range as a box and can alert on each pattern. Arrow buffers for iCustom. Open source code.