- 1 1. What Drawdown Control Means in MQL5
- 2 2. How to Implement Drawdown Control
- 3 3. The Mechanism and Core Purpose of Drawdown Control
- 4 4. Differences Between Drawdown Control and Other Risk Management Methods
- 5 5. Common Mistakes and Key Precautions
- 6 6. Practical Use Cases and Operational Design
- 7 7. Frequently Asked Questions (FAQ)
- 7.1 7.1 Is Drawdown Control Required?
- 7.2 7.2 Should Drawdown Be Judged by Balance or Equity?
- 7.3 7.3 What Drawdown Setting Is Recommended?
- 7.4 7.4 Is Lot Management Alone Not Enough?
- 7.5 7.5 Does Drawdown Control Reduce Profit?
- 7.6 7.6 Can the Same Logic Be Used in MT4?
- 7.7 7.7 How Is It Different from a Stop Loss?
- 7.8 7.8 Does Drawdown Control Alone Make an EA Safe?
1. What Drawdown Control Means in MQL5
1.1 Definition
Conclusion:
Drawdown control is a risk management method that monitors the decline in account equity and limits or stops trading when losses exceed a defined level.
Definition:
Drawdown is a metric that shows how far account value has fallen from its previous peak.
In MQL5, drawdown control is mainly used for the following purposes.
- Prevent a sharp decline in capital, including account failure
- Stop an Expert Advisor (EA) from continuing to trade out of control
- Keep risk within a defined range
In automated trading, there is a structural risk because human judgment is not involved. Even after a series of losses, the system may continue trading mechanically. For this reason, drawdown control works as the final line of defense.
Drawdown control is also different from a simple stop loss.
A stop loss controls losses for each individual order, while drawdown control is risk management for the entire account or portfolio.
1.2 Types of Drawdown
Conclusion:
There are three main types of drawdown: Balance, Equity, and Max. In real trading, equity-based drawdown is the most important.
The nature of drawdown changes depending on what is used for the calculation.
Balance Drawdown
- Uses only realized profit and loss
- Does not include open positions
- Tends to underestimate actual risk
Equity Drawdown
- Includes floating profit and loss
- Reflects the current real condition of the account
- Essential for live trading
Max Drawdown
- The largest historical decline
- Used in backtesting and performance evaluation
- A benchmark for measuring strategy risk
A common beginner mistake is judging drawdown based on Balance.
Because this ignores floating loss, the account can look safer than it really is.
As a result, traders may miss losses caused by spread widening or slippage, which can lead to an unexpected decline in capital.
1.3 Why It Matters in MQL5
Conclusion:
Drawdown control is one of the most important logic layers that affects the survival rate of an EA.
Automated trading in MQL5 has the following characteristics.
- Runs 24 hours a day, often on a VPS
- Does not involve emotion
- Can be vulnerable to changes in market conditions, such as trend and volatility changes
This structure creates the following problems.
Risk Expansion During Losing Streaks
- The EA keeps entering trades even when the logic no longer fits the market
- If lot size stays fixed, losses accumulate
Changes in Market Conditions
- Trend to range transitions
- Spread widening
- Execution delays and other execution problems
Because of these factors, large drawdowns can occur within a short period.
More importantly, drawdown is not just a loss. It is a factor that quickly makes recovery harder.
- 10% loss -> about 11% gain needed to recover
- 50% loss -> 100% gain needed to recover
For this reason, preventing drawdowns above a certain level is directly connected to long-term capital growth.
In practice, the roles are as follows.
- Entry conditions -> generate profit
- Stop loss -> limits individual losses
- Drawdown control -> prevents account failure
In other words, drawdown control is not logic for winning.
It is logic for staying in the game.
2. How to Implement Drawdown Control
2.1 Basic Logic
Conclusion:
Drawdown control can be implemented with a simple structure: calculate the decline rate from the difference between current Equity and the previous maximum Equity, then restrict trading when the threshold is exceeded.
The implementation has three core parts.
- Get the current account value, or Equity
- Record the previous maximum account value, or Max Equity
- Calculate the decline rate, or drawdown, and make a decision
Once you understand this structure, you can apply it to almost any EA.

2.2 Implementation Flow You Can Copy
Conclusion:
If you implement the following steps as they are, basic drawdown control will work.
Steps
- Get the current Equity
- Update the maximum Equity
- Calculate the drawdown rate
- Trigger control when the threshold is exceeded
Minimal Implementation Example
double max_equity = 0.0;
bool trading_enabled = true;
void CheckDrawdown()
{
double current_equity = AccountInfoDouble(ACCOUNT_EQUITY);
// Initialize or update
if(current_equity > max_equity)
max_equity = current_equity;
// Drawdown rate
double drawdown = (max_equity - current_equity) / max_equity;
// Stop if it exceeds 20%
if(drawdown >= 0.20)
trading_enabled = false;
}
Example Usage in OnTick
void OnTick()
{
CheckDrawdown();
if(!trading_enabled)
return;
// Normal entry logic
}
With this structure, you can stop new orders when drawdown occurs.
2.3 Important Implementation Points
Conclusion:
Beginners most often fail in two areas: state management and division by zero.
Initializing Maximum Equity
- It is zero immediately after the EA starts
- It must be updated correctly on the first tick
Countermeasure:
if(max_equity == 0.0)
max_equity = current_equity;
Preventing Division by Zero
if(max_equity <= 0)
return;
VPS Restart Problem
- max_equity is reset
- Accurate DD management becomes impossible
Countermeasures:
- Use GlobalVariable
- Save to a file with FileWrite
2.4 Variations of Control Methods
Conclusion:
Drawdown control is more practical when it uses staged control, not only a full stop.
1. Full Stop, Simple Version
- Stop everything at 20% DD
- Suitable for beginners
- Prioritizes safety
2. Staged Control, Recommended
- DD 10% -> cut lot size in half
- DD 20% -> stop new entries
- DD 30% -> close all positions
3. Time-Limited Stop
- DD reached -> stop for 24 hours
- Wait for market conditions to recover
4. Symbol-Based Management
- Stop only EURUSD
- Continue trading other currency pairs
2.5 Common Mistakes
Conclusion:
The implementation itself is simple, but a design that ignores live operation will not work well.
Mistake 1: Judging by Balance
- Floating losses are ignored
- DD activation is delayed
Mistake 2: Setting the Threshold Too Low
- The EA stops too quickly
- Trading opportunities are lost
Mistake 3: Heavy Processing on Every OnTick
- Unnecessary calculations increase
- Performance declines
Improvement:
- Check once per second or only on a new bar
2.6 Why This Implementation Works
Conclusion:
This logic reduces the probability of account failure because it automatically lowers risk when the EA is losing.
The following conditions occur constantly in the market.
- Spread widening
- Slippage
- Execution delay
When these factors overlap, losses can exceed expectations.
Drawdown control responds by:
- Reducing the number of trades
- Forcibly cutting off risk
This is its main role.
3. The Mechanism and Core Purpose of Drawdown Control
3.1 Why Drawdown Control Improves Survival Rate
Conclusion:
Drawdown control is a mechanism that greatly lowers the probability of reaching account failure or forced liquidation by automatically cutting risk during losing streaks.
An automated trading EA continues to enter trades even when its logic is no longer suitable for the market.
For example, a trend-following EA can lose repeatedly in a range market, while a mean-reversion EA can suffer expanding losses when a strong trend appears.
The issue at that point is the chain of losses.
- Each individual loss is small
- But consecutive losses quickly reduce equity
- If lot size stays fixed, the damage accumulates
Drawdown control applies a brake to this chain by:
- Stopping entries after a defined loss level
- Forcibly reducing the number of trades
The key point is that this is not logic for winning, but logic for stopping a situation where the EA keeps losing.
3.2 Relationship Between Expected Value and Drawdown
Conclusion:
Expected value, such as win rate times profit minus loss, is not enough. The size of the drawdown is a critical metric that determines whether a strategy can survive live trading.
Many beginners tend to think as follows.
- High PF, or Profit Factor, means an excellent EA
- High win rate means safe
In reality:
- A strategy with high PF but large DD can still be dangerous
- Losses may occur that are difficult or impossible to recover from
Examples:
- DD 10% -> about 11% needed to recover
- DD 30% -> about 43% needed to recover
- DD 50% -> 100% needed to recover
Because of this nonlinear relationship, recovery becomes harder as drawdown becomes deeper.
Drawdown control is used to:
- Keep DD shallow
- Keep losses within a recoverable range
In other words, it is a mechanism for lowering the probability of failure while preserving expected value.
3.3 Relationship with Market Structure
Conclusion:
Drawdown occurs when trading logic no longer matches the market, so it cannot be completely avoided.
The market is always changing.
- Trend -> range
- Low volatility -> high volatility
- Spread widening during news events
These changes create the following effects.
Impact of Spread
- Trading costs increase
- Small profits disappear
Slippage
- Orders are executed at unexpected prices
- Losses increase
Execution Problems
- Order rejection
- Unfavorable entries caused by delay
An EA cannot fully control these factors.
Therefore, drawdown must be managed on the assumption that it will occur.
Drawdown control is a post-event risk response to this unavoidable risk.
3.4 Role in EA Design
Conclusion:
Drawdown control is a money management layer that sits above entry logic.
EA design can be divided into three broad layers.
- Signal, or entry conditions
- Order control, including order conditions, lot size, SL, and TP
- Money management, including drawdown control
Beginners often focus on the first layer, but in real trading the third layer is the most important.
Reasons:
- Signals change depending on market conditions
- Money management can be applied to every strategy
- It directly controls the risk of account failure
It is especially necessary for the following strategies.
- Averaging down
- Grid trading
- High-frequency trading
These strategies can hold large temporary drawdowns, so long-term operation is difficult without control.
In short:
- Good entries create profit
- Good money management keeps the account alive
Drawdown control belongs to the second point.
4. Differences Between Drawdown Control and Other Risk Management Methods
4.1 Roles and Features of Each Method
Conclusion:
Drawdown control is a mechanism for limiting losses across the entire account, and its role differs from lot management and stop loss. It is not enough by itself and should be used together with other controls.
The roles of major risk management methods are as follows.
| Method | Target | Main Role | Feature | Weakness |
|---|---|---|---|---|
| Drawdown control | Entire account | Prevent account failure | Final defense line | Reduces profit opportunities |
| Fixed lot size | Each trade | Stabilization | Easy to implement | Weak against market changes |
| Risk percentage management | Each trade | Even out losses | Highly versatile | Weak during losing streaks |
| Stop Loss (SL) | Each position | Control individual losses | Essential function | Cannot prevent total DD |
| Equity Protection | Entire account | Forced stop | High safety | Can activate too late |
The important points are:
- Stop loss -> controls one loss
- Lot management -> controls risk per trade
- Drawdown control -> controls the accumulation of consecutive losses
In other words, drawdown control is risk management against time-based risk, especially losing streaks.
4.2 Difference Between Drawdown Control and Lot Management
Conclusion:
Lot management is pre-trade risk control, while drawdown control is post-result risk control.
Lot Management, or Position Sizing
- Determines risk at entry
- Example: risk 1% of capital
- Helps stabilize expected value
Drawdown Control
- Monitors losses as a result
- Forcibly stops trading after a defined loss
- Helps avoid account failure
A common misunderstanding is:
“If I risk 1%, it is safe.”
This is incomplete.
Reasons:
- 10 consecutive losses -> about 10% loss
- 20 consecutive losses -> about 20% loss
Lot management alone cannot stop equity decline caused by consecutive losses.
Therefore, the roles are:
- Lot management -> basic strategy
- Drawdown control -> safety mechanism
4.3 Difference Between Drawdown Control and Stop Loss
Conclusion:
A stop loss controls a single loss, while drawdown control manages cumulative losses.
Stop Loss (SL)
- Set for each trade
- Fixes the upper limit of loss
- Depends on execution conditions
Drawdown Control
- Monitors total losses across multiple trades
- Decides whether to stop the entire EA
For example:
- With SL -> one loss is limited
- But with consecutive losses -> capital keeps declining
Drawdown control is what addresses this problem.
Also, due to slippage or spread widening, a stop loss may be executed at a worse price than expected.
For that reason, stop loss alone is not enough.
4.4 Difference Between Drawdown Control and Equity Protection
Conclusion:
Equity protection is a final stop, while drawdown control is mid-course control.
Equity Protection
- Closes all positions and stops trading at a defined loss level
- Example: force shutdown when capital falls by 50%
- Acts like an emergency brake
Drawdown Control
- Allows staged control
- Example:
- 10% -> reduce lot size
- 20% -> stop new entries
- 30% -> close all positions
In other words:
- Equity protection -> final defense line
- Drawdown control -> daily risk management
Both should be used together.
4.5 Best Practical Combination
Conclusion:
The most realistic setup is the three-part combination of lot management, stop loss, and drawdown control.
Recommended setup:
- Lot management, or risk per trade
- Stop Loss (SL)
- Drawdown control, or DD control
For a stronger setup, add:
- Spread filter
- Order condition and execution checks
- Slippage control
With this structure, you can cover:
- Individual losses
- Cumulative losses
- Market condition risk
in a comprehensive way.
4.6 Common Mistakes
Conclusion:
If drawdown control is used by itself, performance can actually become worse.
Mistake 1: Depending Only on Drawdown Control
- Lot size remains too large
- The EA only stops after DD is reached
-> It may already be too late
Mistake 2: Extreme Thresholds
- 5% -> stops too quickly
- 50% -> too late
Mistake 3: Poor Combination Design
- No SL
- No execution consideration
-> unexpected losses
The countermeasure is to:
- Manage risk in multiple layers
- Avoid depending on a single method
This is important for practical operation.
5. Common Mistakes and Key Precautions
5.1 Design Errors in Drawdown Judgment
Conclusion:
The most common mistake is using the wrong drawdown basis or update logic. This can cause the control to fail or trigger too aggressively.
Typical mistakes include:
- Judging based on Balance
- Updating maximum Equity at the wrong time
- Letting the denominator in the DD calculation change incorrectly
Common Incorrect Example
double drawdown = (balance - equity) / balance;
This approach is incorrect. The reasons are:
- balance only includes realized profit and loss
- It does not reflect floating loss
As a result, the account can appear safer than the real risk level.
Correct Way to Think
- Always calculate based on Equity
- Calculate by comparing against maximum Equity
5.2 Mistakes in Managing Maximum Equity
Conclusion:
If maximum Equity is managed incorrectly, drawdown will not be calculated correctly and the control becomes meaningless.
Typical problems:
- max_equity is reset when the EA restarts
- The update condition is wrong
- Values are mixed across multiple currency pairs
Common Mistake
max_equity = current_equity;
If you overwrite it every time, drawdown will always be zero.
Countermeasure
if(current_equity > max_equity)
max_equity = current_equity;
In live operation, you should also handle VPS restarts by using methods such as:
- Saving with GlobalVariable
- Saving to a file with FileWrite
5.3 Mistakes in Threshold Settings
Conclusion:
A drawdown threshold will not work well if it is too low or too high.
If It Is Too Low, Example: 5%
- Stops too quickly
- Loses trading opportunities
- Reduces PF
If It Is Too High, Example: 50%
- Activates too late
- Recovery becomes difficult
- Practically meaningless
Realistic Guidelines
- 10-15%: conservative
- 15-25%: standard
- 25% or more: high-risk strategy
The important point is to match the setting to the characteristics of the strategy.
- Scalping -> lower
- Averaging down -> higher
5.4 Execution Timing Problems
Conclusion:
Running the process on every OnTick can reduce performance and cause unnecessary checks.
Problems
- Unnecessary calculations increase
- CPU load increases in a VPS environment
- The logic becomes noisy
Improvement Methods
Method 1: Control by Time Interval
static datetime last_check = 0;
if(TimeCurrent() - last_check > 1)
{
CheckDrawdown();
last_check = TimeCurrent();
}
Method 2: Only on a New Bar
if(IsNewBar())
{
CheckDrawdown();
}
This allows you to check only when necessary.
5.5 Risks Often Missed in Live Operation
Conclusion:
Drawdown control is not a universal solution, and it cannot fully prevent losses caused by market factors.
Elements that require special attention:
Spread Widening
- During economic releases
- During rollover time
-> losses may exceed expectations
Slippage
- During high volatility
- Execution delay
-> losses expand
Order Rejection
- Lack of liquidity
- Broker restrictions
-> control may be delayed
An EA cannot fully control these factors.
For that reason, drawdown control must be combined with:
- Spread filters
- Execution checks, such as OrderCheck
5.6 Common Implementation Pattern Failures
Conclusion:
Even a simple implementation will not work as expected if the operational design is incomplete.
Failure 1: No Recovery After Stop
- Once stopped -> stopped forever
-> lost opportunities
Failure 2: Vague Recovery Conditions
- Unclear restart timing
-> unstable operation
Failure 3: Not Closing All Positions
- Floating losses are left open
-> DD continues
Improvements
- Design stop and recovery conditions as a set
- Close all positions when necessary
- Use log output to make the state visible
6. Practical Use Cases and Operational Design
6.1 Cases Where It Is Effective
Conclusion:
Drawdown control is more effective for strategies that are prone to consecutive losses, so it is especially important for logic with concentrated risk.
Averaging Down and Grid Strategies
- Floating losses tend to accumulate
- DD can expand quickly when a trend appears
-> without DD control, the probability of failure is high
High-Frequency Trading, or Scalping
- The number of trades is high
- It is sensitive to spread and slippage
-> small losses accumulate
Volatility-Dependent Strategies
- ATR-based strategies and similar approaches
- Strongly depend on market movement
-> environmental changes can create losing streaks
In these strategies, DD control works as a function that detects when the logic no longer fits the market and stops trading.
6.2 Cases Where the Effect Is Limited or Unnecessary
Conclusion:
For low-frequency strategies with strict risk management, the effect of drawdown control is limited.
Low-Frequency Trading
- Only a few entries per month
- Each individual loss is strictly controlled
Discretionary Trading as the Main Approach
- A human trader judges the situation
- Manual action is taken when DD occurs
However, as a precaution:
- If an EA is involved even partially
- If automated operation is running on a VPS
then at least basic DD control should be included.
6.3 Recommended Setting Patterns
Conclusion:
In real operation, staged control, or phase control, is better than a single threshold.
Basic Recommended Setup
- DD 10% -> cut lot size in half
- DD 20% -> stop new entries
- DD 30% -> close all positions
Implementation Concept
if(drawdown >= 0.30)
{
CloseAllPositions();
trading_enabled = false;
}
else if(drawdown >= 0.20)
{
trading_enabled = false;
}
else if(drawdown >= 0.10)
{
lot_multiplier = 0.5;
}
By controlling risk in stages, you can:
- Prevent excessive stopping
- Limit the expansion of losses
This allows for more balanced operation.
6.4 Integration with Other Logic
Conclusion:
Drawdown control is not enough by itself. It reaches a practical level only when integrated with other risk management logic.
Recommended setup:
Essential Layers
- Lot management, or risk per trade
- Stop Loss (SL)
- Drawdown control
Enhancement Layers
- Spread filter
- OrderCheck and execution confirmation
- Slippage countermeasures
Advanced Layers
- Volatility filter, such as ATR
- Session filter
With this structure, you can cover:
- Individual risk
- Cumulative risk
- Market risk
in multiple layers.
6.5 Operational Checkpoints
Conclusion:
In real operation, visualizing the operating state is more important than the logic itself.
Items to check:
- Current drawdown rate
- Maximum Equity value
- Control state, ON or OFF
Log Output Example
Print("DD: ", drawdown, " / Max Equity: ", max_equity);
Recommended Actions
- Monitor logs, such as MT5 logs
- Visualize performance with services such as Myfxbook
- Use abnormal behavior alerts
This helps you detect unexpected behavior early.
6.6 Best Practical Design
Conclusion:
The best practical design for drawdown control is not simply to stop, but to weaken risk exposure.
Reasons:
- A full stop creates large opportunity loss
- The market may recover
- Flexible control tends to be more stable
Therefore, the most realistic structure is:
- Initial phase -> adjust lot size
- Middle phase -> restrict entries
- Final phase -> stop everything
7. Frequently Asked Questions (FAQ)
7.1 Is Drawdown Control Required?
Conclusion:
For automated trading EAs, it is almost essential. If it is not implemented, losses may not stop during a losing streak, creating a risk of a large capital decline in a short period.
Especially with VPS operation or 24-hour trading, human intervention can be delayed, so at least basic DD control should be included.
7.2 Should Drawdown Be Judged by Balance or Equity?
Conclusion:
It should be judged based on Equity.
Balance only includes realized profit and loss and does not reflect floating loss. To understand actual risk correctly, use ACCOUNT_EQUITY.
7.3 What Drawdown Setting Is Recommended?
Conclusion:
In general, 15-25% is a realistic range.
However, it must be adjusted according to the strategy.
- Scalping: 10-15%
- Day trading: 15-25%
- Averaging down and grid strategies: 20-30%
Be careful with one-size-fits-all settings that do not have enough basis, because they can cause excessive stopping or excessive risk.
7.4 Is Lot Management Alone Not Enough?
Conclusion:
It is not enough. Lot management can only control the risk of a single trade.
If consecutive losses continue, cumulative losses do not stop, so it should be used together with drawdown control.
7.5 Does Drawdown Control Reduce Profit?
Conclusion:
It may reduce profit in the short term, but it improves stability over the long term.
This is because it stops trading during phases where losses are expanding, reducing fluctuation in the equity curve.
7.6 Can the Same Logic Be Used in MT4?
Conclusion:
Yes, the basic idea can be implemented in the same way.
By using functions such as AccountEquity(), you can build similar drawdown control.
7.7 How Is It Different from a Stop Loss?
Conclusion:
A stop loss controls the loss of one trade, while drawdown control controls cumulative losses across multiple trades.
Because their roles are different, both are needed.
7.8 Does Drawdown Control Alone Make an EA Safe?
Conclusion:
No. Drawdown control is a final defense, and it must be combined with the following:
- Stop Loss (SL)
- Lot management, or position sizing
- Spread filter
- Execution checks
Only by combining these controls can you reach practical risk management.