The Best Way to Properly Backtest on Tradestation
How to Download TradeStation
If you have not already downloaded TradeStation, then please do so before continuing with this backtesting on TradeStation guide. First, head to the TradeStation’s home page to login to your Client Center. Next, select the Download Software tab in the top menu. At the time of writing, TradeStation offers both version 9.5 and version 10. Build Alpha and this guide are compatible with both. Additionally, TradeStation has a great installation video and user guide here:
Create a Strategy for Backtesting and Live Trading
In order to backtest, we need a strategy. There are two ways to create a strategy for backtesting and live trading in TradeStation. One requires coding and one does not.
Easy Language Development Environment
TradeStation’s proprietary coding language, called Easy Language, was designed to make programming easy for traders. TradeStation handles all of the “no fun” tasks like data connectivity, order routing, and account monitoring while traders get to focus on the logic of the strategy.
Easy Language allows traders to express their trading ideas in almost human readable syntax. Below is an example of a moving average crossover system that buys 100 shares on a cross above and sells 100 shares on a cross below
If Close[0] crosses above Average(Close,10)[0] then buy 100 shares next bar open;
If Close[0] crosses below Average(Close,10)[0] then sell 100 shares next bar open;
Learning the ins and outs of easylanguage are not as gruesome as learning a traditional programming language. In addition, TradeStation has great documentation and tons of pre-built-in functions for all popular indicators.
Build Alpha and Generated Code
Build Alpha is a no code strategy builder that enables traders to build, test, and generate code for tons of automated trading strategies. This presents an option for those that do not want to learn how to program but still want to do algorithmic trading.
After generating a strategy, simply hit the ‘Generate EL Code’ button to get full code. This code can be copy and pasted into TradeStation’s Development Environment as if you coded it yourself.
Compile or Verify the Strategy
Whether coded yourself or built with Build Alpha, we must save the strategy in TradeStation’s development environment. To do so follow these steps
- View >> Development Environment
- File >> New Strategy
- Name the strategy
- Code your strategy or copy and paste from Build Alpha
- Hit F3 or Verify to save the strategy
How to Add a Strategy to a Chart
Ok, now that we have a trading system how do we view it on a chart? The next step to properly backtest on the TradeStation trading platform is to open a chart.
Step 1 Open a New Chart
In the File menu, head over to View >> TradingApp Launcher >> Chart Analysis. Alternatively, one can do File >> New >> TradingApp Window >> Chart Analysis.
Double-click on the prices to access the settings. You can adjust the date range, candlestick type, timeframe, and symbol. Alternatively, you can right-click on the chart and select Format Symbol to do the same.
Step 2 Insert Strategy
Now that our chart is set, we need to insert the strategy onto the chart. From the File menu you can Insert >> Strategy or you can right-click on the chart and select Insert Strategy.
Next, select your desired strategy. You should see the trades appear on the chart.
Step 3 Turn on and configure settings
Let’s make sure our strategy settings are correct. Right-click on the chart and select Format Strategies or double-click on one of the entry or exit arrows to open the settings menu.
To automate the strategy, one must
- check the box “Generate Strategy Orders for Display in TradeManager’s Strategy Orders tab”
- check the box “Automate execution using”
- select an account
- select a confirmation setting
Please note these steps are the same for simulated trading and live accounts. Always confirm which account you are signed into prior to automating anything!
Max Bars Back and sufficient market data
The trading software needs sufficient data to calculate whatever it is your trading systems do. TradeStation has a setting called “Maximum number of bars study will reference” but it is more colloquially known as “Max Bars Back”.
This setting instructs TradeStation how many bars to wait before the trading strategy should begin trading. If your strategy uses a 200-period simple moving average, then it would be wise to set the Max Bars Back to 201.
To find this setting, right-click on the chart and select Format Strategies. In the next window, choose the “Properties for All” tab and look in the lower left. After setting an appropriate value hit OK and then continue to hit Close on the Format Analysis Techniques & Strategies window.
This setting is meaningful regardless of timeframe, tick data, daily, weekly, etc. as TradeStation considers bars.
Advanced Automation Settings in TradeStation
We have now set up a simple strategy with simple settings. TradeStation has many more noteworthy settings. In the Properties for All window, there are three tabs across the top. Select the ‘Automation’ tab to see a new set of configurations.
Fill historical orders
The first option is to instruct TradeStation on what to do when your strategy logic generates an order, but the market does not give you a fill. The default setting is to change your limit order to a market order 15 seconds after the strategy logic generates an order (assuming no fill).
Multiple Strategies on the Same Symbol
The next option to enable is if you will have multiple strategies for the same symbol. TradeStation will make sure one strategy’s exit does not close out a position from another strategy if you select the “Allow multiple automated strategies on multiple charts using the same symbol” option.
Stop Orders
Finally, enable TradeStation to send stop orders to their own server. This is an underrated feature and worth explaining. If your TradeStation account is down, internet goes out, lose power, etc. while you have an open position then this may save you. TradeStation will notice stop orders from your strategy logic and house them on their server. If you lose power, no problem, your order is still live on a TradeStation Technologies Inc server.
Read more
Viewing the Strategy Performance Report
How do we view our back test results? After loading the strategy on the chart we can view the Strategy Performance Report. To open the report you can either
- Hit “ALT” + “SHIFT” + “P”
- View >> Strategy Performance Report
The report is extensive and has many options. I will briefly describe them all below
- Performance Summary – shows all relevant performance metrics
- Trade Analysis – provides insights into streaks, run ups and drawdowns
- Trades List – list of all entries, exits, and P&L
- Periodical Returns – strategy returns broken down by day, week, month and year
- Performance Graphs – equity curves and various other visual displays
- Trade Graphs – more visuals to view trade results
- Settings – an overview of symbol, strategy, and system settings
You can also save or print this report in the upper left near the File menu. Reminder, backtest results are not indicative of future results.
Read more
Importing Trading Strategies into Build Alpha
TradeStation is great but is missing many advanced tools professional system traders require or only has them in a limited capacity such as
- Monte Carlo Simulation
- Walk forward optimizer
- Portfolio mode
Luckily, the Strategy Performance Report can be saved to a csv or excel file and imported into Build Alpha. Build Alpha has a converter that can take these Strategy Performance Reports and import any strategy.
Build Alpha offers more advanced robustness testing and portfolio testing than TradeStation does. This is also a way to combine your TradeStation strategies with your Build Alpha strategies to do more thorough research.
TradeStation Backtesting Summary
TradeStation securities offers a trading platform, brokerage account, and programming language called easylanguage for systematic traders. Traders can load strategies onto real time charts and view past performance, the trades on a chart, and various performance results. TradeStation has data for all assets such as Futures, Stocks, ETFs, forex, cryptocurrencies and various indexes. Build Alpha provides a no code strategy builder to produce fully automate-able Easy Language code for TradeStation.
For those interested in getting started with Build Alpha and TradeStation, please reach out to me to find out how TradeStation will cover your Build Alpha license cost. Read more here TradeStation and Build Alpha promo
Author
David Bergstrom – the guy behind Build Alpha. I have spent a decade-plus in the professional trading world working as a market maker and quantitative strategy developer at a high frequency trading firm with a Chicago Mercantile Exchange (CME) seat, consulting for Hedge Funds, Commodity Trading Advisors (CTAs), Family Offices and Registered Investment Advisors (RIAs). I am a self-taught programmer utilizing C++, C# and python with a statistics background specializing in data science, machine learning and trading strategy development. I have been featured on Chatwithtraders.com, Bettersystemtrader.com, Desiretotrade.com, Quantocracy, Traderlife.com, Seeitmarket.com, Benzinga, TradeStation, NinjaTrader and more. Most of my experience has led me to a series of repeatable processes to find, create, test and implement algorithmic trading ideas in a robust manner. Build Alpha is the culmination of this process from start to finish. Please reach out to me directly at any time.