Drawdown Limiter for funded challenges and to protect your balance

Drawdown Limiter for funded challenges and to protect your balance

22 March 2023, 07:41
Haidar, Lionel Haj Ali


You are in the right place if you were searching for Drawdown control, Drawdown limiter, Balance protection, or Daily Drawdown Limit related to Prop Firm, FTMO, My Forex Fund, or Funded account trading, or if you want to protect your trading account.

Are you tired of watching your trading account balance dwindle down to zero after a few bad trades? Do you struggle to meet your daily drawdown targets imposed by funding organizations like FTMO and My Forex Funds? Look no further than Draw Down Limiter, the expert advisor that protects your account from catastrophic losses and helps you meet your funding requirements.

I am Lio, I am an EA automated trader, and I developed this utility to help me respect this rule, and I am proposing it here to help you too. Draw Down Limiter is the ultimate risk management tool that ensures your trading account stays afloat during volatile market conditions. Its algorithms detect potential drawdowns and automatically limit your losses, preventing your account from being wiped out. It helps you meet your daily drawdown targets, increasing your chances of successfully securing funding from top trading firms like FTMO, My Forex Fund, and others.

With Draw Down Limiter, you can trade with confidence, knowing that your account is protected from the unpredictable nature of the markets. So, whether you're a beginner or an experienced trader, add Draw Down Limiter to your arsenal and take your trading to the next level.

This EA is ideal for copy trading or EA trading with a prop firm.

Need help or have questions? I am Lio, don't hesitate to reach out!  We are always available to respond, help, and improve. Our support channel is always here for you.

Where to download Draw Down Limiter

Draw Down limiter is available for MT4 and MT5, you can find the EA under:

If you are looking for an additional free EA to help you stop your Algo Trading when drawdown is reached, check the attached "Algo Trading Disabler" EA, it is free, just load it on your charts. For more information check the following video to know how to use it:  https://youtu.be/ZU44k8Iaud4

This EA is not uploaded to MQL5 market as it prohibit DLL import. Please make sure you enable DLL import in MT4 and MT5 when using this EA.

Draw Down Limiter Functionalities

The expert advisor’s essential function is to monitor all the activities on the account if it was a manual or automated trade by another expert advisor. You need to add it to a chart, and it will take control. It monitors the Global Account Drawdown (GDD) by comparing the initial account size and current equity. It calculates the Maximum Daily Loss (DDD)= results of closed positions of this day + the result of open positions. It will check and set controls on the number of open trades (OTRD). It will track the current positions open and closed in the range (ATRD). The EA will display your daily profit/loss when the trade opens. Once the draw-down percentage is reached, it closes all open positions and orders. Any new order will be instantly closed. At the end of the day or mentioned range, the threshold is set back to zero, and a new day begins.   An advanced mode of this EA, if you are an expert advisor developer, is to use to complete your current expert advisor. The Drawdown Limiter EA can pass instructions to prevent your EA from sending orders, and this will help you not to pay commissions for trades executed after the drawdown limit is reached. Please take a look at the advanced section below.

It's "Traffic Lights" feature will keep you informed about the four KPI mentioned above in a simple graphical manner. The EA comments can be hidden and customizable to match your preferred colors and fonts. 

Figure 1: DrawDown Limiter loaded on the chart

The Settings

The EA setting are quire simple and divided into different logic group.

Figure 2: DrawDown Limiter Inputs

Below you will find a details explanation on how to use each input.

    • Define your reset range
      • Drawdown Reset Cycle: You can even choose a cycle on the opening of the daily bar or a specific range. If the latter is chosen, you must define your start time range.  The specific range will be compared last known server time visible in the Market Watch window.
      • Specific Range hour (0-23): Start hour of the range.
      • Specific Range minute (0-59): Start minute of the range.
      • Skip Weekends: Some of you are trading crypto on weekends, so this option is for DrawDown limiter to keep track on weekends too
    • Account Overall Drawdown
      • Initial Account size: Set your initial account balance to monitor its overall drawdown
      • Max Account DD %: This percentage will help update the GDD light and alert you how far you are from your limits

    • Daily Drawdown
      • Drawdown Calculation Options:  You can choose to calculate the drawdown (1) from the initial deposit amount that you set, usually FTMO imposes this rule, (2)from the equity which is a rule from My Forex Funds, (3) from the balance at the start of the day, (4) from the maximum value of equity or Balance at the start of the day, or if you wish to set the drawdown in (4) money value. The EA will monitor and reset the base from which it calculates the drawdown on each new range and use it as a reference.
      • Initial Deposit: If you choose to calculate the drawdown from the initial deposit or set it in money value, specify the initial deposit amount here.
      • Max Daily DD %: The maximum daily drawdown percentage. Once set, the money value is calculated from Initial Deposit, Account Balance, Or Account Equity. Usually, the daily drawdown is 5% in most Prop Firms. I recommend having some margin and configuring it to 4.5%. Assuming you are starting from a 10000$ balance, once the EA detects 450$ loss, it will trigger the security option and delete/close any new trade.
      • Include Swap and Commission: Include Swap and Commission in your Draw Down calculation. Some of the Prop Firms require this.
      • Stop overtrading  - I encourage you to learn self-discipline and not let the Draw Down limiter prevent you from overtrading. This skill is a must if you need to evolve as a trader. 
        • Max Number of range positions: Set the maximum number of trades allowed. Trades are closed positions or open positions. Partial take profit linked to one position is considered as one position. An order is not considered a position before it is triggered.
        • Max Number of open positions: Set the maximum number of currently open positions. An order is not considered a positions before it is triggered.
      • Actions Settings:
        • Send Notifications for each actions : Enable sending push notifications on each action took by DrawDown limiter
        • Close extra trades on next tick: This option will allow to close any extra trade on next tick when drawdown is reached instead of waiting for frequency timer.
        • NFA BROKERS - FIFO rule: You can enable or disable FIFO compatibility, and when enabled you have two modes, don't hesitate to check the blog mentioned above for more details
        • Close Open position if DD reached in Security Zone: This enable security zone at the end of the day to help, check the FTMO blog above for more details
        • End of Range Security Zone in minutes: The size of security zone in minutes
        • Terminal Action When DD or Max Trades reached: This will allow to automatically close the terminal with DD or max trades  threshold is reached, or keep it open to manage current running positions
        • Traffic Light Position: Chose default position, top left, top right, bottom right, and bottom left
        • Traffic Light Style: set your traffic light horizontally or vertically
        • Vertical and Horizontal Traffic Light Shift: use those parameters to manually shift borders 

        • This will allow you to set the Details Font, colors so DrawDown Limiter match your charts and your style
        • GV to use in other EA: This is the name of the Global Variable created by the EA. If you are an mql developer, you can check this Global Variable in your code to prevent opening any new position if the draw-down threshold is reached
        • Check Frequency in Milliseconds: The frequency to check open trades in milliseconds.

        • Magic number: It keeps track of the trades closed by the EA.
        • Trade comment: Comment included in the order executed by the EA

      How to read the "Traffic Lights"

      The "Traffic Lights" is added in order to quickly and visually get the information on the current drawdown level or on the number of trades threshold. It includes four squares.

      1. GDD%: Represents the global account drawdown from an initial balance.
      2. DDD%: Represents the Daily Draw Down.
      3. OTRD: Represents the current open positions.
      4. ATRD: Represents all the positions (open and closed) inside the range.

      GDD% is calculated from the initial account balance vs the current equity. Its color varies based on the drawdown configured for the account. DDD% is calculated as the percentage of the "Current range floating profit or loss" from "DrawDown maximum amount". Drawdown lights have four colors:

      • Green: the current range is in profit
      • Orange: the current range drawdown is less than 50%
      • Orange Red: when drawdown is between 50% and 75%
      • Red: when the drawdown is beyond 75%

      ATRD is the sum of "Total range positions", while OTRD is the number of consecutive open positions. The trades threshold lights have three colors:

      • Green: Less than 50% of trades threshold
      • Orange:  current trades number is between 50% and 75% of the maximum allowed
      • Red: when the threshold is beyond 75%

      Figure 3: DrawDown Limiter Traffic Lights

        How to use the advanced mode

        This EA needs to run on a chart on your account where other EA are running. Once the drawdown threshold is reached, it will create a Temp Global Variable with the name you defined in the inputs: “ GV to use in other EA”, for example GV_isDD. Check https://www.mql5.com/en/docs/globals for more information about global variables. In your EA you can check if this variable exists, and if it is the case you don’t take a trade. At the end of the range/day, "DrawDown Limiter" will remove the Global Variable allowing your EA to take trades again

           //If daily DD reached
        Print("Max Daily DrawDown Active. No more trades will be opened!");
        } else
          …Your logic to open a trade...

        How to test Draw Down Limiter

        An example for you to test this EA, is to run in the strategy tester of MT5, it automatically creates random sell trades to allow you to test the essential features. Unfortunately, you cannot run two EA in strategy tester to test the advanced functionalities. 

        If you need to have a limited version to test by your own feel free to contact us or reach us via the support group of this EA.

        /!\ FOR MT4 USERS BE AWARE /!\

        MT4 do have couple of limitation when it comes to the use of such utility.

        1. The first one is that you cannot do the same test in the strategy tester as for MT5, this is a limitation in MT4 where the OnTimer() function is not implemented in the tester.
        2. MT4 does not implement a unique position ID or trade open time in milliseconds. Therefore the partial closed positions are detected by combining uniqueness using open time, open price, symbol, type of the operation, and magic number. If you execute 2 similar trades with the same information they will be counted as unique position.
        3. The second point which is THE MOST IMPORTANT, in MT4 the order history is read from your terminal history tab, so make sure you have selected the right time frame. This is due to the limitation of OrdersHistoryTotal() function in MT4, you can find the reference under: https://docs.mql4.com/trading/ordershistorytotal. However in MT5 this limitation do not exist as we can load the history based on a start and end date directly in the EA what ever the history selected in the terminal. This is available via the HistorySelect() function in MT5, you can find the reference under https://www.mql5.com/en/docs/trading/historyselect.

        To illustrate this limitation for you, you can find below the screen shots, where the order history selected today's closed trades and you can see in the first image that the DrawDown limiter is calculating perfectly the numbers.

        Figure 4: MT4 "DrawDown Limiter" with the right history selected in the terminal

        While in the image below, I changed the history in the terminal back to a past day, and you can see that the DrawDown limiter lost the history, and the calculation is back to 0.

        Figure 5: MT4 "DrawDown Limiter" not calculating correctly the as wrong history is selected in the terminal

        Drawdown Limiter Architecture

        I am adding this section to explain what DrawDown limiter what it can't do. What you need to understand that you have 4 different parties in a trading journey. The user or EA that is putting and managing the orders. To do so they do it via MetaTrader Terminal. The terminal role is to rely the message such as creating new orders, modifying the stop loss, or closing orders to the MetaTrader server. The server is responsible of the execution of those orders. Drawdown limiter interacts with the terminal. It reads the history and current positions that the Terminal fetch from the server. DrawDown Limiter can then analyze the data and take actions. Drawdown limiter cannot interact with the Server neither to anticipate the user or EA commands.

        So in the list that Drawdown will not be able to do are: 

        • Force the user or EA to respect a certain risk while opening the trades.
        • Force the user or EA to set a stoploss for each new position
        • Prevent the user or EA to create new trades after drawdown is reached
        • Prevent the opening of a position with a certain risk rule on certain currency
        • Handle any mechanism for account password modification or inputs modifications vs a password
        DrawDown Limiter will only act after the User/EA or Metatrader server and never before.

        Figure 6: "DrawDown Limiter" communication flow

        Share it with friends: