Discussing the article: "Risk Manager for Trading Robots (Part I): Risk Control Include File for Expert Advisors"
Hello, thank you for your work!
However, I would like to see the class code corresponding to the one described in the article, for example
In the article:
enum ENUM_RISK_CALC_TYPE { RISK_CALC_BALANCE_ONLY, // Calculation based on balance only RISK_CALC_EQUITY_ONLY, // Calculation based on equity only RISK_CALC_COMBINED, // Combined calculation RISK_CALC_ADAPTIVE // Adaptive calculation };
In the attached file:
enum ENUM_RISK_CALC_TYPE {
RISK_CALC_BALANCE_ONLY, // Only Balance
RISK_CALC_EQUITY_ONLY, // Only Equity
RISK_CALC_BALANCE_EQUITY, // Balance/Equity (US Prop Style)
RISK_CALC_PROP_STANDARD // Standard Prop Company Rules
};
The ‘adaptive calculation’ mentioned in the article is not reflected in the attached class code at all.
Furthermore, there is an error in the code that prevents the expert advisor from compiling:
// Trading Object
CTrade m_trade;
It should be in the public section:
Please check this.
My compilation isn’t working either; it gets stuck on line 124: 123 // Set the magic number for the trading object
I applied the risk manager to my live Martingale-based expert advisor
Here are the results of the 2025 backtest without the risk manager:
And here are the results with the risk manager’s optimal settings:
As you can see, the maximum drawdown has been halved, whilst profits have quadrupled.
One aspect I consider fundamental in algorithmic systems is to clearly distinguish between the quality of the strategy and the amount of risk taken on.
A high return on its own says relatively little if, to achieve it, the system needs to maintain a high level of leverage or endure large drawdowns.
In my case, I prefer to first assess parameters such as drawdown, maximum exposure, execution stability and the system’s behaviour under different market conditions.
I also consider it important to keep risk rules within the system’s own logic and avoid increasing exposure simply because there is a favourable run.
In the long term, I believe that controlling how much can be lost is just as important as analysing how much the algorithm can earn.
I’ve applied a risk manager to my live Martingale-based expert advisor
Here are the results of the 2025 backtest without the risk manager:
And here are the results with the best risk manager settings:
As you can see, the maximum drawdown has been halved, whilst profits have quadrupled.
The relative drawdown as a percentage of equity has decreased and is now within reasonable limits.
It used to be >50 per cent (which, in reality, guarantees a blow-out and a stop-out), but is now around 20 per cent, so it’s worth giving it a go, even if only with cents.
It’s a bit odd that the number of trades has fallen by a third. That’s too many; it shouldn’t be like that.
PS/ Even though you were experimenting with the Martingale strategy. Which, by definition, is a strategy in its own right – pure money management. What does the result tell us? Mainly that you didn’t fine-tune the Martingale strategy properly – in some places you’ve taken on too much risk, in others not enough… ;-)
There’s clearly room for improvement.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use



Check out the new article: Risk Manager for Trading Robots (Part I): Risk Control Include File for Expert Advisors.
Experience shows that trading accounts without a well-thought-out risk management system tend to have a short life cycle.
There are three classic psychological traps that almost every beginning trader falls into. The first is euphoria after a series of profitable trades. After a few successful market entries, you get the feeling that you have figured out the market, unlocked its secrets. Your inner voice whispers, "I am in the black, I can afford to take more risk!", and the trader increases the lot, ignores stop losses, and opens more positions simultaneously. The result is predictable: in one day the trader loses what took weeks to earn.
The second trap is hoping for a market reversal. The position goes further into loss, the red numbers on the screen become larger, but the trader continues to hold the trade. "It is about to reverse," "It is just a correction," "The market cannot fall forever" — thousands of traders repeat these mantras until a margin call puts an end to their trading careers.
The third trap is the most insidious — ignoring your own rules. A trader creates a trading system, sets clear entry and exit rules, and sets risk limits. But at some point the thought appears: "What could possibly go wrong? It is okay to break my own rules once". Stop losses are disabled, the maximum lot is exceeded, and trades are opened against the trend. This is the path to inevitable collapse, and the trader understands this perfectly well, but cannot stop.
Author: Yevgeniy Koshtenko