Backtesting — The Cure for Losses
Backtesting is the process of testing a trading idea on historical data before you risk real money. It’s like going back in time and asking: “If I had traded these rules before, would I have made money or not?”
Why Backtesting Matters
Separate Ideas from Illusions
Many strategies look promising at first glance. Visually — they seem solid. Emotionally — “it’s obvious this should work.” Backtesting quickly sobers you up:
Understand the Math Behind the Strategy
Backtesting answers questions you can’t solve intuitively:
After a solid backtest, you stop fearing normal drawdowns — because you know the stats.
Save Money and Nerves
The market is an expensive teacher. Backtesting is free.
Every strategy untested on history is an experiment at your own expense.
Build Confidence in the System
When you have hard numbers:
You’re trading a process, not hope.
What You Must Understand Up Front
Backtesting does not guarantee future profits. Markets evolve — and that’s normal.
But backtesting does show:
It’s like checking your car before a trip. It doesn’t guarantee no accidents, but driving without it is just foolish.
What Exactly Do We Backtest?
We don’t test a single entry model or one indicator. We test a trading system defined by clear rules. That’s crucial — until an idea becomes a system, it can’t be objectively verified.
1. The Logic of Decision-Making
The test object is the logic behind your trades. Primarily — market context:
Not just “RSI below 30” as a fact, but what it represents — imbalance, momentum, reaction to a level, or dislocation. If entry logic isn’t meaningful, backtesting degenerates into signal-hunting.
2. Trade Exit
This is where most of the results are shaped. We test:
Often the same entry, with different exit rules, produces radically different equity curves — from a robust system to a total blow-up.
3. Risk Management
Risk per trade, risk/reward ratio, the impact of losing streaks on equity — all are part of the hypothesis. A strategy may be sound, but with poor risk management it becomes unsustainable. In backtesting, we look not only at profits, but at how the system survives drawdowns.
4. Filters
When does the strategy perform best?
Often, adding a simple filter eliminates most losing trades and dramatically improves stability.
5. Repeatability
Does the hypothesis work across different historical periods, market phases, and instruments? If it only shows results in one year — that’s not a trading system, it’s curve-fitting.
What We Do Not Test
We don’t test feelings like “this looks logical.” We don’t test pretty trades. We don’t chase a perfect equity curve without drawdowns.
Backtesting is not about confirming expectations — it’s about stress-testing them.
Key Metrics to Track
1. Win Rate (Percentage of Profitable Trades)
Win Rate is the proportion of profitable trades relative to the total number of trades over a selected period.
Formula:
Win Rate (%) = (Number of Profitable Trades / Total Number of Trades) × 100
Example:
Calculation:
Win Rate = 42 / 120 × 100 = 35%
Strategy Win Rate = 35%.
What counts as a profitable trade:
A high Win Rate does not guarantee a reliable or profitable strategy.
2. Risk / Reward Ratio (R:R)
Risk / Reward (R:R) reflects the ratio between the average risk and the average potential profit per trade. It shows how much profit the strategy generates per unit of risk.
3. Expectancy
Expectancy is the average financial outcome of one trade over the long term.
It answers the key backtesting question:
Does the strategy make money on average per trade?
Basic Formula:
Expectancy = (WinRate × AvgWin) − (LossRate × AvgLoss)
Where:
A positive expectancy is a mandatory condition for a viable strategy.
4. Trade Distribution by Sessions (Asia / Europe / US or Specific Hours)
Analyze trades by time to understand where performance is actually coming from.
Key questions to analyze:
Common scenario:
Asia — negative
London — neutral
New York — generates almost all the profit
5. Time-Based Expectancy
Expectancy should be analyzed not only overall, but also:
This is one of the strongest performance filters.
Number of Trades by Time
A time slot may appear profitable, but if it has only a few trades per year, the result is statistically insignificant.
Drawdown by Session
Sometimes a session is profitable overall, but its drawdowns during specific hours are psychologically unacceptable
6. Expectancy: Long vs Short
Very often:
Or vice versa.
Win Rate by Direction
Win Rate may be similar, but:
If expectancy in one direction is below zero, it should be:
Common Backtesting Mistakes
1. Look-Ahead Bias (Future Leak)
This occurs when the principle of sequential analysis is violated.
Trading decisions are made using information that would not have been available in real time.
Examples:
Consequences:
Correct Approach:
2. Curve Fitting (Over-Optimization)
This mistake occurs when a strategy is excessively optimized for historical data by adding too many conditions and parameters.
As a result:
Rule of thumb:
If a strategy cannot be explained in simple words without a chart, it is most likely over-optimized.
3. Ignoring Commissions and Slippage
In many backtests:
Why the impact is often underestimated:
Particularly vulnerable strategies:
Scalping;
Correct Approach:
If a strategy becomes unprofitable after accounting for commissions and slippage, it never had a real edge
4. Testing Only “Favorable” Market Conditions
This methodological error occurs when a strategy is tested only during market phases where it naturally performs best.
This creates an illusion of robustness that is not confirmed across real market cycles.
A strategy must be tested under:
It is acceptable that a strategy:
The key is understanding where and why this happens.
A strategy that works only in favorable conditions is not a trading system.
Proper backtesting must account for market variability and evaluate performance across all market regimes.
Evaluating Strategy Fit for the Trader
1. Psychological Compatibility
Assess your tolerance for:
2. Lifestyle Compatibility
The strategy should align with:
3. Risk Profile
A comfortable strategy:
4. Final Check
If you break the rules on a demo account,
you will break them even more often on a live account.
A good strategy looks:
Backtesting Features and Pitfalls in TradingView
Before starting backtesting, it is important to understand certain specifics of how TradingView displays data.
If these nuances are ignored, you will almost inevitably introduce look-ahead bias and distort your test results.
Choosing a Backtest Starting Point in TradingView:
When selecting the starting point for a backtest in TradingView, there are four main tools:
Personally, for the sake of experimental integrity, I most often use Random bar.
This approach helps minimize look-ahead bias and makes the backtest closer to real trading conditions.
You do not know in advance what will happen next and are forced to make decisions under uncertainty — exactly as in live markets.
A Critically Important TradingView Behavior:
There is a TradingView behavior that many traders are unaware of, yet it can severely distort backtesting results.
When switching to a higher timeframe, TradingView always shows a fully closed candle, even if in real time that candle would still be forming.
Example 1
You are on a 5-minute chart in the middle of the trading day and decide to check the daily timeframe.
TradingView will show you the final daily candle, meaning you effectively see how the day will close.
As a result, you already know the outcome of the price movement and may subconsciously adjust your decisions based on future information.
Example 2
You are analyzing order flow on a 1-hour chart and decide to look at the weekly timeframe to identify key reaction zones.
If you simply switch to the weekly chart, TradingView will display a fully formed weekly candle, including its high, low, and close.
In practice, this means you already know how the week opens and closes while still analyzing trades within that same week.
This is direct look-ahead bias, which makes the backtest invalid.
How to Avoid Look-Ahead Bias in TradingView
To ensure an honest backtest, you must scroll the chart back before switching to a higher timeframe.
This is where the Select bar tool becomes essential.
The logic is simple:
Only after that should you switch to the higher timeframe.
In this case, you will see only the information that was actually available to the market at that moment — without spoilers and without distorted data.
Enjoy!
Backtesting is the process of testing a trading idea on historical data before you risk real money. It’s like going back in time and asking: “If I had traded these rules before, would I have made money or not?”
Why Backtesting Matters
Separate Ideas from Illusions
Many strategies look promising at first glance. Visually — they seem solid. Emotionally — “it’s obvious this should work.” Backtesting quickly sobers you up:
- Either the idea has a statistical edge,
- Or it’s pure self-deception.
Understand the Math Behind the Strategy
Backtesting answers questions you can’t solve intuitively:
- What’s the average profit per trade?
- How many losing trades in a row are normal?
- What’s the actual drawdown?
- How many trades per month/year?
After a solid backtest, you stop fearing normal drawdowns — because you know the stats.
Save Money and Nerves
The market is an expensive teacher. Backtesting is free.
Every strategy untested on history is an experiment at your own expense.
Build Confidence in the System
When you have hard numbers:
- You stop overreacting.
- You break rules less often.
- You avoid “jumping in because it felt right.”
You’re trading a process, not hope.
What You Must Understand Up Front
Backtesting does not guarantee future profits. Markets evolve — and that’s normal.
But backtesting does show:
- Whether the idea had an edge.
- What risks are involved.
- Why trading blind is reckless.
It’s like checking your car before a trip. It doesn’t guarantee no accidents, but driving without it is just foolish.
What Exactly Do We Backtest?
We don’t test a single entry model or one indicator. We test a trading system defined by clear rules. That’s crucial — until an idea becomes a system, it can’t be objectively verified.
1. The Logic of Decision-Making
The test object is the logic behind your trades. Primarily — market context:
- Why do you use this entry model here?
- What in price action or market behavior gives you reason to expect movement in your favor?
Not just “RSI below 30” as a fact, but what it represents — imbalance, momentum, reaction to a level, or dislocation. If entry logic isn’t meaningful, backtesting degenerates into signal-hunting.
2. Trade Exit
This is where most of the results are shaped. We test:
- Where losses are cut.
- Where and how profits are taken.
- Whether exits use fixed targets, logical levels, partial closes, or trailing stops.
Often the same entry, with different exit rules, produces radically different equity curves — from a robust system to a total blow-up.
3. Risk Management
Risk per trade, risk/reward ratio, the impact of losing streaks on equity — all are part of the hypothesis. A strategy may be sound, but with poor risk management it becomes unsustainable. In backtesting, we look not only at profits, but at how the system survives drawdowns.
4. Filters
When does the strategy perform best?
- During certain times of day?
- Under specific volatility conditions?
- In trends or ranges?
Often, adding a simple filter eliminates most losing trades and dramatically improves stability.
5. Repeatability
Does the hypothesis work across different historical periods, market phases, and instruments? If it only shows results in one year — that’s not a trading system, it’s curve-fitting.
What We Do Not Test
We don’t test feelings like “this looks logical.” We don’t test pretty trades. We don’t chase a perfect equity curve without drawdowns.
Backtesting is not about confirming expectations — it’s about stress-testing them.
Key Metrics to Track
1. Win Rate (Percentage of Profitable Trades)
Win Rate is the proportion of profitable trades relative to the total number of trades over a selected period.
Formula:
Win Rate (%) = (Number of Profitable Trades / Total Number of Trades) × 100
Example:
- Total trades: 120
- Profitable trades: 42
- Losing trades: 78
Calculation:
Win Rate = 42 / 120 × 100 = 35%
Strategy Win Rate = 35%.
What counts as a profitable trade:
- A trade is considered profitable only if the final result is positive after accounting for commissions and slippage.
- Trades closed at breakeven or with a small loss due to fees are not considered profitable.
A high Win Rate does not guarantee a reliable or profitable strategy.
2. Risk / Reward Ratio (R:R)
Risk / Reward (R:R) reflects the ratio between the average risk and the average potential profit per trade. It shows how much profit the strategy generates per unit of risk.
- For beginners, acceptable R:R values are typically 1:2 or 1:3.
- Strategy profitability is driven by asymmetry between losses and gains, not by the frequency of winning trades.
3. Expectancy
Expectancy is the average financial outcome of one trade over the long term.
It answers the key backtesting question:
Does the strategy make money on average per trade?
Basic Formula:
Expectancy = (WinRate × AvgWin) − (LossRate × AvgLoss)
Where:
- WinRate — proportion of profitable trades (not in %)
- LossRate = 1 − WinRate
- AvgWin — average profit of winning trades
- AvgLoss — average loss of losing trades (absolute value)
A positive expectancy is a mandatory condition for a viable strategy.
4. Trade Distribution by Sessions (Asia / Europe / US or Specific Hours)
Analyze trades by time to understand where performance is actually coming from.
Key questions to analyze:
- Where is the majority of profit generated?
- Which sessions drag overall performance down?
- Where volatility is high but results are poor?
Common scenario:
Asia — negative
London — neutral
New York — generates almost all the profit
5. Time-Based Expectancy
Expectancy should be analyzed not only overall, but also:
- By session
- By individual hour
This is one of the strongest performance filters.
Number of Trades by Time
A time slot may appear profitable, but if it has only a few trades per year, the result is statistically insignificant.
Drawdown by Session
Sometimes a session is profitable overall, but its drawdowns during specific hours are psychologically unacceptable
6. Expectancy: Long vs Short
Very often:
- Long trades produce stable and smooth results
- Short trades produce sharp gains but with deep drawdowns
Or vice versa.
Win Rate by Direction
Win Rate may be similar, but:
- Longs may have smaller stop losses
- Shorts may experience frequent stop-outs
If expectancy in one direction is below zero, it should be:
- Removed entirely, or
- Strongly restricted.
Common Backtesting Mistakes
1. Look-Ahead Bias (Future Leak)
This occurs when the principle of sequential analysis is violated.
Trading decisions are made using information that would not have been available in real time.
Examples:
- Analyzing fully formed highs or lows;
- Using closed candles that did not exist at the moment of entry;
- Adjusting entries or stop losses after seeing future price movement.
Consequences:
- Significant overestimation of strategy performance;
- Distorted and misleading statistics.
Correct Approach:
- Move strictly from left to right on the chart;
- Hide the right side of the chart;
- Make decisions only based on information available at that moment.
2. Curve Fitting (Over-Optimization)
This mistake occurs when a strategy is excessively optimized for historical data by adding too many conditions and parameters.
As a result:
- The strategy perfectly explains the past;
- But loses its ability to work in the future.
Rule of thumb:
If a strategy cannot be explained in simple words without a chart, it is most likely over-optimized.
3. Ignoring Commissions and Slippage
In many backtests:
- Entries and exits occur at “ideal” prices;
- Orders are assumed to be executed instantly;
- Commissions are ignored or underestimated.
Why the impact is often underestimated:
- Fees seem small (0.05–0.2%);
- Each individual trade appears barely affected;
- The cumulative effect becomes visible only over time.
Particularly vulnerable strategies:
Scalping;
- High-frequency trading;
- Systems with low Risk/Reward ratios.
- Such conditions do not exist in real trading.
Correct Approach:
- Always include commissions on both entry and exit;
- Apply conservative slippage assumptions;
- Test closer to the worst-case scenario, not the best;
- Use real exchange and instrument parameters.
If a strategy becomes unprofitable after accounting for commissions and slippage, it never had a real edge
4. Testing Only “Favorable” Market Conditions
This methodological error occurs when a strategy is tested only during market phases where it naturally performs best.
This creates an illusion of robustness that is not confirmed across real market cycles.
A strategy must be tested under:
- Trending markets;
- Ranging (sideways) markets;
- Periods of high volatility;
- Periods of low volatility.
It is acceptable that a strategy:
- Performs well in some regimes;
- Loses money or stagnates in others.
The key is understanding where and why this happens.
A strategy that works only in favorable conditions is not a trading system.
Proper backtesting must account for market variability and evaluate performance across all market regimes.
Evaluating Strategy Fit for the Trader
1. Psychological Compatibility
Assess your tolerance for:
- Losing streaks;
- Waiting for valid trade setups;
- Holding positions over time.
2. Lifestyle Compatibility
The strategy should align with:
- Available time;
- Required level of concentration;
- Daily work rhythm.
3. Risk Profile
A comfortable strategy:
- Does not induce panic;
- Does not trigger impulsive decisions;
- Provides a sense of control.
4. Final Check
If you break the rules on a demo account,
you will break them even more often on a live account.
A good strategy looks:
- Boring;
- Clear;
- Predictable
Backtesting Features and Pitfalls in TradingView
Before starting backtesting, it is important to understand certain specifics of how TradingView displays data.
If these nuances are ignored, you will almost inevitably introduce look-ahead bias and distort your test results.
Choosing a Backtest Starting Point in TradingView:
When selecting the starting point for a backtest in TradingView, there are four main tools:
- Select bar — you manually choose a specific bar on the chart from which you want to start the analysis.
- Select date — you set a date from which the chart will be displayed.
- Select the first available date — the backtest starts from the earliest available bar (relevant if your subscription has historical data limits).
- Random bar — TradingView moves you to a random location on the chart.
Personally, for the sake of experimental integrity, I most often use Random bar.
This approach helps minimize look-ahead bias and makes the backtest closer to real trading conditions.
You do not know in advance what will happen next and are forced to make decisions under uncertainty — exactly as in live markets.
A Critically Important TradingView Behavior:
There is a TradingView behavior that many traders are unaware of, yet it can severely distort backtesting results.
When switching to a higher timeframe, TradingView always shows a fully closed candle, even if in real time that candle would still be forming.
Example 1
You are on a 5-minute chart in the middle of the trading day and decide to check the daily timeframe.
TradingView will show you the final daily candle, meaning you effectively see how the day will close.
As a result, you already know the outcome of the price movement and may subconsciously adjust your decisions based on future information.
Example 2
You are analyzing order flow on a 1-hour chart and decide to look at the weekly timeframe to identify key reaction zones.
If you simply switch to the weekly chart, TradingView will display a fully formed weekly candle, including its high, low, and close.
In practice, this means you already know how the week opens and closes while still analyzing trades within that same week.
This is direct look-ahead bias, which makes the backtest invalid.
How to Avoid Look-Ahead Bias in TradingView
To ensure an honest backtest, you must scroll the chart back before switching to a higher timeframe.
This is where the Select bar tool becomes essential.
The logic is simple:
- If you want to view the daily timeframe — scroll back at least one full day.
- If you are analyzing the hourly timeframe — scroll back at least one full hour.
- If you want to view the weekly timeframe — scroll back at least one full week.
Only after that should you switch to the higher timeframe.
In this case, you will see only the information that was actually available to the market at that moment — without spoilers and without distorted data.
Enjoy!
Official Telegram Channel: t.me/LonesomeTheBlue_Official
You can get monthly subscription to my Pro indicators. Please visit my "LTB Professional Trading Suite" for more info
You can get monthly subscription to my Pro indicators. Please visit my "LTB Professional Trading Suite" for more info
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Official Telegram Channel: t.me/LonesomeTheBlue_Official
You can get monthly subscription to my Pro indicators. Please visit my "LTB Professional Trading Suite" for more info
You can get monthly subscription to my Pro indicators. Please visit my "LTB Professional Trading Suite" for more info
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
