Prop Firm EA: How to Code Daily Drawdown and Max Loss Rules

By the Victoryalgo team · · 7 min read

Prop firm accounts come with strict loss rules. If you break one, the firm may close the account. When you trade by hand, it is easy to miss a limit on a busy day.

An Expert Advisor (EA) can check these limits for you. This guide explains the common rule types and how an EA can follow them.

Before you start: No EA can promise to pass a challenge. Check that your firm allows EAs, and the type of EA you plan to use. Firm rules can change at any time, so always read the current rules before you trade.

What Daily Loss and Max Drawdown Usually Mean

Prop firm rules usually include two main loss limits:

  • Daily loss limit: the most the account may lose in one trading day.
  • Maximum drawdown (max loss): the most the account may fall in total.

The details differ at each firm. Some set the max loss level once, from the starting balance. Others move it up as the account grows, often called a trailing drawdown.

Balance-Based and Equity-Based Rules

  • Balance only counts closed trades.
  • Equity is the balance plus the floating profit or loss of open trades.

With a balance-based rule, only closed results count. With an equity-based rule, an open trade that is deep in loss can break the rule, even if it later recovers. Some firms use a mix, such as the higher of balance or equity at the start of the day.

Here is a simple example. It only shows the maths. Your firm's numbers may be different. Imagine a 100,000 account with a 5% daily loss rule based on the start-of-day balance. If the day starts at 100,000, equity must not fall below 95,000 that day.

When Does the Day Reset?

Firms reset the trading day at different times. The reset is often based on a set time zone or the broker's server time, not your local time.

This matters if you trade from the UAE or Canada, because your local midnight is not the firm's reset time. Daylight saving changes can also move the reset hour in your local time.

The EA needs the exact reset time. At that moment, it saves the starting balance or equity for the new day. That number is then used for the daily limit. A good EA lets you set the reset time as an input.

How an EA Can Enforce the Rules

An EA cannot change the firm's rules. But it can watch the account and act before a limit is reached.

1. Check Equity Before Each Trade

Before it opens a trade, the EA reads the current equity. In MQL5, this is done with AccountInfoDouble(ACCOUNT_EQUITY). It compares equity with the daily limit level and the max loss level.

The EA can also work out what the new trade would lose if the stop loss is hit. If that would cross a limit, the EA skips the trade.

2. Stop New Trades Near a Limit

You can add a safety buffer. The EA stops opening new trades once a set part of the daily limit is used. You choose the buffer size.

3. Close Trades at a Set Equity Level

This is a hard stop. If equity falls to a level you choose, the EA closes all positions, deletes pending orders and pauses until the next reset.

Set this level with room above the firm's limit. Gaps and slippage can make the final price worse than your level.

4. Size Lots by Risk Percent

Instead of a fixed lot, the EA can size each trade by risk. You set a risk percent, such as 1% of balance (only an example). The EA uses the stop loss distance and the symbol's tick value to work out the lot size, then rounds it to the broker's lot step and limits.

News, Weekend and Trade Count Rules

Loss limits are not the only rules. Firms often have other conditions too.

  • News rules: some firms limit trading close to high-impact news. The EA can block new trades for a set number of minutes before and after news. It can read news times from the MT5 economic calendar or from a list you enter. Calendar data may not be available in the Strategy Tester, so test this part on demo.
  • Weekend rules: some firms do not allow trades to stay open over the weekend. The EA can close all trades at a set time on Friday, in server time, and block new trades until the market opens again.
  • Max trades per day: the EA can count trades and stop at your limit. The counter resets at the firm's reset time.
  • Max open trades: the EA can limit how many positions are open at once.
  • Trading style rules: some firms do not allow certain styles. Your EA's logic must follow these rules as well.

Why Your Developer Needs the Exact Rule Text

Small changes in wording mean different code. "5% of the starting balance" is not the same as "5% of the higher of balance or equity at the start of the day". A developer cannot guess which one your firm uses.

Send your developer:

  1. The full rule text from your firm, copied or as screenshots, with the date you saved it.
  2. Your account size and platform (MT4 or MT5).
  3. The daily reset time and its time zone.
  4. Whether the limits include commission and swap.
  5. Your news, weekend and trade count rules.
  6. Your own trading rules, written clearly. Our guide How to Turn Your Trading Strategy Into an MT5 EA shows how.

When you contact Victoryalgo about a prop firm EA, please include this list. If your firm's rules change later, the EA settings or code may need an update too.

Test the Rules Before You Trade

Do not wait for a real account to find out if the safety rules work. Test them on purpose.

  • Backtest: set a very small daily limit in the inputs and check that the EA really stops. See How to Backtest an EA in the MT5 Strategy Tester.
  • Demo: check that the daily reset happens at the right time and that the news and weekend filters work.
  • Logs: ask for clear messages, such as "Daily limit reached, trading paused", so you can see what the EA did and why.

A bot follows your rules, but results depend on your strategy and the market. You can lose money, and you can still break a firm's rule. Always test on demo first.

Important Limits to Remember

  • The EA only works while MT5 is open and connected. If the terminal is closed, it cannot protect the account. A VPS that stays on all the time can help.
  • The firm measures your account with its own data. Small timing or price differences are possible.
  • Risk code is a safety layer. It reduces the chance of a mistake, but it cannot remove market risk.

MT4, MT5 and Other Platforms

These rules can be coded through MT5 EA development or MT4 EA development, depending on what your firm offers. See MT4 vs MT5: Which Is Better for Your Expert Advisor? For a bot outside MetaTrader, read Python vs MQL5: Which Is Better for Your Trading Bot?

Next Step

Have your firm's rules and your strategy ready? Send us your strategy on WhatsApp for a free consultation. The Victoryalgo team will read both and explain how the limits can be coded.

Victoryalgo is a software development company, not registered with SEBI or any financial regulator. This guide is general education about software, not investment advice. Forex and CFD trading is high risk. Indian residents may trade forex only through RBI-authorised channels.

Frequently Asked Questions

Can an EA make sure I pass a prop firm challenge?

No. An EA can follow the loss rules you give it, but no EA can promise to pass a challenge. Results depend on your strategy and the market.

What is the difference between balance-based and equity-based drawdown?

Balance-based rules count only closed trades. Equity-based rules also count the floating profit or loss of open trades, so they can be broken while a trade is still open.

Do all prop firms allow EAs?

No. Rules differ from firm to firm and can change at any time. Check your firm's current rules before you use any EA.

What should I send a developer for a prop firm EA?

Send the exact rule text from your firm, your account size, your platform and the daily reset time with its time zone. Also send your own trading rules, written clearly.

More Guides

Want your strategy coded?

Send your rules on WhatsApp. Free consultation, clear quote.

WhatsApp Your Strategy

Risk & Regulatory Notice

  • We are NOT registered with SEBI or any financial regulator. We do not give investment advice, tips or signals, recommend brokers, manage money or trade for you.
  • Software only: we code the rules you give us. Nothing on this page is investment advice.
  • A bot follows your rules. It can't promise profit, and past or backtest results don't show future results.
  • Trading forex, gold, indices and CFDs is high risk. You can lose money, so always test on a demo account first.

Victoryalgo · Software development company · Based in India, working globally

Regulatory status, risk disclosure & policies
Chat with us