PipCircle app icon

Install PipCircle

Add the app to your device - fast access, full screen, and it works offline.

Important Disclaimer

PipCircle is the social network for traders. We connect forex, stock, crypto, and prop firm traders with broker reviews, community insights, and real-time trading discussions.

The information on this platform, including user posts, broker reviews, and discussions, is for informational and educational purposes only. It does not constitute financial advice, investment recommendations, or an endorsement of any broker or trading strategy.

Risk Warning: Trading in financial markets involves substantial risk of loss and is not suitable for every investor. Past performance is not indicative of future results. You should carefully consider your investment objectives, level of experience, and risk appetite before trading.

Users are solely responsible for their own trading decisions.

Back-testing

A back-test runs fixed rules over past prices and adds up the trades. Done carefully it is a cheap way to reject a method. Done carelessly it flatters almost any rule.

  • Level 11 Your Trading Plan
  • Lição 13 de 25
  • 5 min de leitura
  • 2 perguntas

Back-testing means applying a system’s rules to past prices, one candle at a time, and recording every trade they would have taken. Level 5 set out what a back-test can and cannot show. This lesson covers how to run one, using the example system from section 11.3. The system is an illustration, with no edge claimed, and the prices were made with no pattern in them.

By hand and by software

By hand, you scroll a chart back, reveal one candle at a time and apply the rules as the last lesson did, writing each trade down. It is slow, and it teaches what the rules feel like. By software, a platform’s tester does the same work in seconds. The tester’s assumptions then decide the result: when it enters, how it fills a stop, what costs it charges.

Two lines of the running result of 423 trades in R. Before costs the test ends at +20.2R. After costs it ends at −6.5R. After costs the line peaks at +28.5R on trade 165 and falls 40.1R to its low on trade 388.Two lines of the running result of 423 trades in R. Before costs the test ends at +20.2R. After costs it ends at −6.5R. After costs the line peaks at +28.5R on trade 165 and falls 40.1R to its low on trade 388.
Figure 1. The example system over six years, before and after costs. Example prices made by a formula, not market data.

What the example test showed

Six years of four-hour candles gave 423 trades. Of these, 149 won: a win rate of 35.2%.

Before costsAfter costs
Total+20.2R−6.5R
Average per trade+0.048R−0.015R
Six bars in R a trade. Before costs the example system averages +0.048R. Spread takes 0.019, commission 0.015, slippage 0.007 and swap 0.022. After costs the average is −0.015R a trade.Six bars in R a trade. Before costs the example system averages +0.048R. Spread takes 0.019, commission 0.015, slippage 0.007 and swap 0.022. After costs the average is −0.015R a trade.
Figure 2. The average trade of the example system with each cost taken off. Example prices made by a formula, not market data.

The example costs are a spread of 0.8 pips, commission worth 0.6 pips, slippage of 0.3 pips and a swap of 0.3 pips a night. On an average stop of 41 pips they come to 0.063R a trade. A small profit became a small loss.

Five ways to flatter a test

Each row changes one thing in the same test.

What was doneResult shown
Honest test, with costs−6.5R
Costs left out+20.2R
Orders reached through a gap filled at their own price, no costs+24.0R
Test stopped at its best point, after trade 165+28.5R
Entry at the open of the signal candle, no costs+313.4R

The last row uses information from the future: the candle’s close is not known at its open. The third row gives fills that could not have happened. Level 1 showed that a stop is filled at the first price after a gap. Four stops in the test met weekend gaps, and one lost 2.6R where 1R was planned.

What testers assume

Read your tester’s help before trusting it. TradingView’s documentation says its strategies fill orders from chart data alone by default, apply no commission unless one is set, and typically give unrealistic results on Heikin Ashi and other non-standard charts, which is the point Level 8 made. PipCircle’s Strategy Builder has fields for commission, spread and slippage that start at zero, and it fills a stop hit through a gap exactly at the stop price, which its own notes call optimistic. Set the costs, and read its results with that in mind.

Key points

  • A back-test applies fixed rules to past prices candle by candle and records every trade.
  • The example system made +20.2R before costs and −6.5R after them over 423 trades in six years.
  • Leaving out costs, filling gapped orders at their own price, stopping at the best point and using future information all flatter a test.
  • A tester’s assumptions about entries, fills and costs decide its result. Read them first.

Verificação rápida

Estas perguntas não contam para a pontuação do questionário.

1. A back-test shows +30R over 200 trades before costs. Costs are 0.08R a trade. What is the result after costs?
2. A test enters at the opening price of the same candle whose close produced the signal. What is wrong?

Common mistakes

  • Testing with no costs. The example system’s profit before costs became a loss after them. A short-term rule is hit harder still.
  • Letting the test see the future. Entering on the candle that gives the signal, or using a day’s high before the day has ended, produces results no trader could have had.
  • Trusting fills at the stop price. A stop is filled at the first price available after a gap, and that price can be far away.
  • Ending the test where it looks best. The test period is chosen before the test and not shortened afterwards.

Another example

One of the example test’s gapped trades. The system bought at 1.0983 on a Wednesday with a stop 43 pips away at 1.0940. Price was still above the stop on Friday’s close. On Monday the market opened at 1.0883, below the stop, and the stop was filled there: 100 pips lost, which is 2.33R. At 0.11 lots the loss was 110 dollars where 47.30 had been planned. A tester that fills the stop at 1.0940 records a loss of 1R and makes this trade 1.33R better than it could have been.

Questions people ask

What is back-testing in trading?

Back-testing is running a fixed set of trading rules over past prices and recording every trade they would have taken. The results show how the rules behaved in that period, with a win rate, an expectancy and a drawdown. They describe the past and do not promise the same in the future.

How do I back-test a strategy by hand?

Scroll the chart back so that later candles are hidden, then move forward one candle at a time. At each closed candle apply the rules exactly, and write down every entry, stop, target and result, including costs. Keep going for at least a hundred trades, and do not skip the losing ones.

How many years of data do I need for a back-test?

Enough to produce several hundred trades and to include rising, falling and sideways markets. For a system that trades five times a month that means several years. For a scalping rule a few months of detailed price data may hold thousands of trades, though a short period covers fewer kinds of market.

What is look-ahead bias?

It is the error of letting a test use information that was not available at the moment of the trade, such as a candle’s close when entering at its open. Results improve dramatically and are impossible to achieve. In the lesson’s example this one error turned a small profit into more than 300R.

SeguinteForward testing on demo

As lições são gratuitas sem conta. Inicie sessão e a PipCircle lembra-se de onde parou, guarda as suas pontuações e atribui as suas medalhas. Iniciar sessão grátis

Trading foreign exchange and CFDs carries a high risk of losing money. PipCircle Learn is education and is not investment advice.

PT flag

Showing PipCircle in Português. Prefer another language?

We use cookies

Necessary cookies keep PipCircle working. Optional cookies (analytics, marketing, preferences) help us improve the product. You can change this any time from Settings → Privacy & Data. Read our Privacy Policy.