Occasionaly, there are cases with a 0.00 profit factor in backtesting with the strategy tester. Looking closer at these cases, it turnes out that they all have 100% win trades. Moreover, these cases have typically a poor combined score, although all other criteria (profit, number of trades, drawdown etc.) are pretty good.
Theoretically, the profit factor is calculated dividing gross profit by gross loss. So cases with 100% win trades should have an indefinite profit factor (division by zero). They are, however, stated with profit factor 0.00 and a poor combined score (usually below 70), which distorts there real value significantly.
It is hard to believe that this is the intention of the MT5 developers.
You are absolutely correct, mathematically you cannot divide by zero. When gross loss is 0 - Profit Factor defaults to 0.00 to prevent system crash - that is standard software architecture, not a bug.
Furthermore, a 100% win rate in backtesting is a massive red flag for overfitting, look-ahead bias or flawed data. The tester downweights the score precisely to flag these unrealistic results. Educate yourself on basic market variance and tester logic before claiming developer error.
You are absolutely correct, mathematically you cannot divide by zero. When gross loss is 0 - Profit Factor defaults to 0.00 to prevent system crash - that is standard software architecture, not a bug.
Furthermore, a 100% win rate in backtesting is a massive red flag for overfitting, look-ahead bias or flawed data. The tester downweights the score precisely to flag these unrealistic results. Educate yourself on basic market variance and tester logic before claiming developer error.
After analyzing strategy tester results, I came up with an empiric formula (RMSE = 1.38) for the calculation of the combined score:
Result = 100 × f_trades × [0.80 × Q + 0.20 × f_pf]
where
f_trades = clamp((trades − 27) / 26, 0, 1)
f_dd = clamp((47.6 − DD%) / 39.3, 0, 1)
f_rf = clamp((RF − 1.08) / 1.28, 0, 1)
f_sr = clamp((SR − 0.86) / 1.57, 0, 1)
f_pf = clamp((ln(PF) − 0.05) / 0.56, 0, 1)
Q = 0.544 x f_dd + 0.210 x f_rf + 0.246 x f_sr
The real formula used in the strategy tester might be slightly different. Also, not sure if ExpectedPayoff is used in the real formula – it was mostly noise in my calculations, but it might have been included in the real formula with a small weight.
As one can see, the number of the total trades is the highest weighted factor, which is statistically sound. Returning to our initial topic, cases with ProfitFactor = 0 are penalized. They cannot have a combined score higher than 80.
Penalizing cases with a win rate of 100 % (ProfitFactor defaults to 0) is obviously a deliberate and defensive design choice. A 100 % win rate over a finite backtest sample is a statistical red flag, not a quality signal. With zero losses, you have no empirical estimate of how bad a losing trade could be. The strategy hasn't been stress-tested by the market. MetaTrader is essentially saying: we can't evaluate your downside risk if you have no losses in the sample.
Using ProfitFactor = ∞ is not informative. Profit factor measures the ratio of gross profit to gross loss. With zero losses, the denominator is zero — the metric is undefined. MetaTrader has to handle this edge case somehow. Capping it at ~80 rather than treating it as the best possible score is a reasonable choice: it signals "this result is statistically insufficient" rather than "this is a perfect strategy."
So far so good. However, here is the down side of the chosen implementation:
The same parameter set scoring 79.9 (or below) on one testing period and 99.9 on another — purely because the second period happened to contain one losing trade — is an arbitrary discontinuity. The underlying strategy quality hasn't changed; the score jumps 20 points based on a single trade outcome in the sample. That's not a quality measure, that's noise.
Even more fundamental: The strategy tester uses ProfitFactor = 0.00 to represent two completely opposite situations: 100 % win rate (gross loss = 0, infinite ProfitFactor) and 100 % loss rate (gross profit = 0, ProfitFactor = 0). Both get the same display value and the same formula treatment. A strategy that wins every trade and a strategy that loses every trade receive the same ProfitFactor component score. That is mathematically indefensible.
The designers chose to store ProfitFactor as a bounded float and didn't implement a separate flag or sentinel to distinguish the two edge cases. A sound solution would have been to either cap infinite ProfitFactor at a large finite value, or exclude the ProfitFactor component from the score entirely when it is undefined, rather than defaulting to zero in both degenerate cases.After analyzing strategy tester results, I came up with an empiric formula (RMSE = 1.38) for the calculation of the combined score:
Result = 100 × f_trades × [0.80 × Q + 0.20 × f_pf]
where
f_trades = clamp((trades − 27) / 26, 0, 1)
f_dd = clamp((47.6 − DD%) / 39.3, 0, 1)
f_rf = clamp((RF − 1.08) / 1.28, 0, 1)
f_sr = clamp((SR − 0.86) / 1.57, 0, 1)
f_pf = clamp((ln(PF) − 0.05) / 0.56, 0, 1)
Q = 0.544 x f_dd + 0.210 x f_rf + 0.246 x f_sr
The real formula used in the strategy tester might be slightly different. Also, not sure if ExpectedPayoff is used in the real formula – it was mostly noise in my calculations, but it might have been included in the real formula with a small weight.
As one can see, the number of the total trades is the highest weighted factor, which is statistically sound. Returning to our initial topic, cases with ProfitFactor = 0 are penalized. They cannot have a combined score higher than 80.
Penalizing cases with a win rate of 100 % (ProfitFactor defaults to 0) is obviously a deliberate and defensive design choice. A 100 % win rate over a finite backtest sample is a statistical red flag, not a quality signal. With zero losses, you have no empirical estimate of how bad a losing trade could be. The strategy hasn't been stress-tested by the market. MetaTrader is essentially saying: we can't evaluate your downside risk if you have no losses in the sample.
Using ProfitFactor = ∞ is not informative. Profit factor measures the ratio of gross profit to gross loss. With zero losses, the denominator is zero — the metric is undefined. MetaTrader has to handle this edge case somehow. Capping it at ~80 rather than treating it as the best possible score is a reasonable choice: it signals "this result is statistically insufficient" rather than "this is a perfect strategy."
So far so good. However, here is the down side of the chosen implementation:
The same parameter set scoring 79.9 (or below) on one testing period and 99.9 on another — purely because the second period happened to contain one losing trade — is an arbitrary discontinuity. The underlying strategy quality hasn't changed; the score jumps 20 points based on a single trade outcome in the sample. That's not a quality measure, that's noise.
Even more fundamental: The strategy tester uses ProfitFactor = 0.00 to represent two completely opposite situations: 100 % win rate (gross loss = 0, infinite ProfitFactor) and 100 % loss rate (gross profit = 0, ProfitFactor = 0). Both get the same display value and the same formula treatment. A strategy that wins every trade and a strategy that loses every trade receive the same ProfitFactor component score. That is mathematically indefensible.
The designers chose to store ProfitFactor as a bounded float and didn't implement a separate flag or sentinel to distinguish the two edge cases. A sound solution would have been to either cap infinite ProfitFactor at a large finite value, or exclude the ProfitFactor component from the score entirely when it is undefined, rather than defaulting to zero in both degenerate cases.Good effort (and nice use of AI), but this is pure over-thinking.
A backtest with zero losses - is 100% broken statistical sample (massive red flag).
Tester dumps the score because the result is useless - end of story.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Occasionaly, there are cases with a 0.00 profit factor in backtesting with the strategy tester. Looking closer at these cases, it turnes out that they all have 100% win trades. Moreover, these cases have typically a poor combined score, although all other criteria (profit, number of trades, drawdown etc.) are pretty good.
Theoretically, the profit factor is calculated dividing gross profit by gross loss. So cases with 100% win trades should have an indefinite profit factor (division by zero). They are, however, stated with profit factor 0.00 and a poor combined score (usually below 70), which distorts there real value significantly.
It is hard to believe that this is the intention of the MT5 developers.