How to Backtest a Stock Market Trading Strategy

I then ran these through TradingSim , a trading simulator where you can practice actual strategies using a simulated account. Do not rely on just backtest results. How do you prepare for the unexpected? Alexander McFarlane 3. In order to further stress-test it, I coded up a Strategy in TradingView based on the rules of my trading system. What is the best way to trade penny stock?

Good Question! In order to find the best way to backtest a stock trading strategy, you need to first know what a backtester is and does. Backtesting a strategy is a simple concept. Step 1: Identify situation and retrieve similar cases from history.

What is 'Backtesting'

Designing an algorithm couldn't be easier. There are only two required functions and we take care of everything else! You just Initialize your strategy and handle the data-events you requested. You can create new indicators, classes, folders and files with a web based full C compiler and auto-complete. We are committed to giving you the best possible algorithm design experience.

Opt in users can have their strategies presented to hedgefund clients in a transparent professional strategy dashboard. Strategies are validated by QuantConnect's backtesting and live trading, giving you a neutral third party review of code. Interested hedgefunds can contact you directly through QuantConnect to offer you employment or funding for your strategy!

We have one of the largest quantitative trading communities in the world, building, sharing and discussing strategies through our community. Converse with some of the brightest minds in the world as we explore new realms of science, mathematics and finance.

Sign up using a social network:. Or create an account below:. First and Last Name. How does it work? Past performance is not an indicator of future results. Unparalleled Speed Harness our server farm for institutional speeds from your desktop computer. World Class Execution Our live trading algorithms are co-located next to the market servers in Equinix NY7 for resilent, secure and lightening fast execution to the markets. Have some great ideas? The problem arrives when you want to apply this system to the future.

Often when a trading system has too many indicators it can predict the behavior of the market during a time period extremely well. The above statement is often difficult for traders to come to grips with, but it is true. Consider what William Eckhardt, of the New Market Wizards has to say about trading systems, In general, the delicate tests that statisticians use to squeeze significance out of marginal data have no place in trading. We need blunt statistical instruments, robust techniques.

Obviously, he is warning against the degrees of freedom error and suggesting that simple trading systems are more likely to stand test of time.

This is absolutely true. Keep this in mind as you trade, and as you attempt to find a profitable trading system. Most traders will find that with experience, they become more likely to embrace the view that simpler trading is preferred over a complex approach. Many traders forget to anticipate unforeseen events that will occur in the future.

When this happens, you should have designed your trading system to remain functioning during these times. Perhaps some examples may help with this: When the global financial crisis started unfolding in September , most currency pairs traded with much more volatility than had been seen for years. The fact is that there will be unexpected events in the future, and these events will affect the markets, so the best thing you can do is to be prepared.

How do you prepare for the unexpected? Consider these simple solutions:. Will your trading systems still be profitable under these conditions? Remember that even this level of risk is likely to be exceeded. The Importance of Correlation.

Some universal backtesting statistics include: Net profit or loss - Net percentage gained or lost Volatility measures - Maximum percentage upside and downside Averages - Percentage average gain and average loss, average bars held Exposure - Percentage of capital invested or exposed to the market Ratios - Wins-to-losses ratio Annualized return - Percentage return over a year Risk-adjusted return - Percentage return as a function of risk Backtesting Software Typically, backtesting software will have two important screens.

Here is an example of such a screen in AmiBroker: Again, here is an example of this screen in AmiBroker: Here is a list of the most important things to remember while backtesting: For example, if a strategy was only backtested from to , it may not fare well in a bear market. For example, if a broad market system is tested with a universe consisting of tech stocks, it may fail to do well in different sectors. Volatility measures are extremely important to consider in developing a trading system.

This is especially true for leveraged accounts, which are subjected to margin calls if their equity drops below a certain point. Traders should seek to keep volatility low to reduce risk and enable easier transition in and out of a given stock. Basics of Trading Systems. Although most backtesting software includes commission costs in the final calculations, that does not mean you should ignore this statistic.

Exposure is a double-edged sword. Increased exposure can lead to higher profits or higher losses, while decreased exposure means lower profits or lower losses. Traders can take larger positions and reduce commission costs by increasing their average gains and increasing their wins-to-losses ratio.

Available Backtests

Backtesting Backtest screen criteria and trading strategies across a range of dates. Tests can be made against a specific symbol or you can simulate multi-holding portfolios. When we backtest a trading strategy we look at what has happened in the past to guide our future trading decisions. Backtesting is difficult and time consuming. It is easy to make mistakes and hard to avoid curve-fitting and over-optimization. Press the "See Results" button and you see how well your strategy for the stock might have worked over the course of up to two years. Specifically, a graph of the stock comes up showing your suggested entry and exit points for the test period.