Understanding Strategy Tester from TrendSpider

TrendSpider offers a powerful backtesting engine called the Strategy Tester. It is designed to make it easy to create, test, refine and explore how any of your trading strategies would perform based on the entry and exit conditions defined by you, using an intuitive visual interface.

With Strategy Tester, you can backtest your trading strategies with 50+ years of historical market data, depending on the symbol you have selected and how much history is available for it. In most cases, it can backtest all the way from the inception of the symbol’s trading (subject to the data feed limitations).

In this way, you can avoid the strategies that would have underperformed and focus on high-probability opportunities only. In this documentation, we will explore

  • What is Strategy Tester
  • The Advantages of Backtesting
  • The Limitations of Backtesting
  • Create a New Strategy
  • Visualize the Results
  • Save & Clone Strategies
  • Download Backtest Data to CSV or TSV
  • Create Multi-Factor Alert

Let’s get started 🚀

What is Strategy Tester

Using the Strategy Tester from TrendSpider allows you to perform rapid iteration backtesting on any asset or timeframe. This is a constructive method of investigating whether a trading strategy would have worked or not in the past. One of the greatest things about the Strategy Tester is you can conduct complex backtesting experiments without having to write any code. Any trader who can describe a strategy in words to a friend can use our Strategy Tester just as easily.

The Advantages of Backtesting

#1 You can determine how your strategy would have behaved in a given market with given parameters. By understanding this behavior, it’s easier to find an appropriate market for an existing strategy or to experiment with new strategies. .

#2 You can optimize your strategy through backtesting. With this exploratory process, you can experiment with entry conditions and without exit conditions. Our Strategy explorer offers a powerful way to learn about price behavior for your positions without having to make real investments.

#3 You can use the strategy tester to evaluate and backtest the performance of a strategy or idea before trading it on a real account with real funds. TrendSpider’s strategy tester consumes only a few seconds to complete the full backtest on any timeframe with any depth, which makes it easy for the traders to test hundreds of ideas/models without risking real capital in the markets to test them.

#4 You can use the strategy tester to validate the effectiveness of a trading strategy fetched from online research or from a recommendation by fellow traders or from a social media post/forum so you do not risk your money trading someone else’s ideas uninformed.

#5 Strategy Tester allows you to make the calculative decision by developing an understanding of the market, rather than acting out of emotions or instincts. Backtesting trading ideas or strategies before executing them reduces your emotional investment in the process and increases the probability of a successful trade.

For more information on how Strategy Tester can be beneficial to help you become a better trader without incurring any risks, please refer to our product page on Backtesting.

The Limitations of Backtesting

#1 Backtesting assumes $0 broker fees. While most brokers offer $0 trading fees now for most asset classes, not all of them do. There is no accounting for any trade-related costs of any kind. In real life, you will likely have at least some costs, commissions, etc. that may eat into your returns.

#2 Backtesting assumes perfect execution and zero slippage. In other words, it assumes you have perfect liquidity, and your orders fill at a specific, predefined price every time (either the open, close, low, high, or some average of these). You can use Trade by next to help make more realistic assumptions to reduce the impact of potential slippage on your strategies once you bring them to the market.

#3 Backtesting is backward-looking. As the name implies, you are testing how something would have worked if you traded it perfectly in the past. Past performance does not indicate future performance and you should not assume it does.

#4 Backtesting assumes you are a robot. It assumes you never miss fire, that you get in and out at the exactly perfect moment each time with zero latency. Humans are just not that fast, you most likely will not be able to execute trades at the exact same prices that the strategy tester would have.

Create a New Strategy

You can use the Strategy Tester to create long or short strategies while defining your own custom entry and exit conditions. Alternatively, you can also use the built-in scripts from TrendSpider or your saved scripts.

Step 1: Click on the Strategy Tester button from the top-right corner of the top menu bar.

Click on the Strategy Tester button

The Strategy Tester will appear below the primary price chart. You can also use the Maximize toggle on the far-right to make the Strategy Tester larger.

The Strategy Tester will appear below the primary price chart

Step 2: Name the Strategy or keep the default auto-generated name.

Name the Strategy

Step 3: Select the Type of Chart that you’d like to scan, including Generic OHLC, Heiken Ashi, Line, or Raindrop charts.

Select the Type of Chart

Step 4: Select the Timeframe to scan from the dropdown list.

Note: Unlike the scanner, alerts, and smart watch lists that support multiple time frames, the strategy tester supports only a single time frame.*

 Select the Timeframe

Step 5: Check the Ext. Hours to allow the system to incorporate the data from extended sessions while running the strategy tester.

Please refer to the documentation on Extended Hours Support for more information.

Check the Ext. Hours

Step 6: Select the Data Depth from the dropdown list. In other words, this option allows you to define how much data from the past, the strategy tester should accumulate and scan.

Selecting the Chart as the Data Depth (Default selection) will instruct the strategy tester to accumulate and scan the data from the past 320 (approx) candles.

Select the Data Depth

Let’s take another example, where the current time frame selected on the chart is Daily. In this case, selecting 10,000 candles as Data Depth from the dropdown will instruct the tester to accumulate and scan the data from the past 100,00 days.

It is to be noted that 10,000 candles are the maximum depth, which means that on different assets, the maximum amount of time that can be tested will vary based on the timeframe you have selected on the chart. For example, 10,000 candles selected on a 1-minute chart will scan the data for 10000 minutes.

For US equities, a trading session is 390 minutes long, and there are 5 trading days per week which means that in one week, there are 1950 minutes of trading that occur. This means on the 1-minute chart, running a backtest for 10,000 candles will include 5.12~ days of data (10000 Candles/1950 minutes).

However, on the Daily timeframe, this will be treated differently. There are 253 trading days in a year which means a backtest on the daily timeframe can look back 39.5 years depending on how much data the symbol has.

Note: This makes the Strategy Tester from TrendSpider different from other back testers where the users are required to select a date range to test between. With TrendSpider, it is fast and easy to test the same strategy across various timeframes and symbols in a standardized way.*

Step 7: Define the value for The Trade by Next. This option allows you to select the most realistic entry criteria for your trades. For example, the Close setting means that trades are placed after the next candle's close rather than its open.

Note: Irrespective of your selection here, the Strategy Tester will always consider the NEXT candle of the selected value.

Note: By default, the Open is selected because our design goals assume that humans are not as fast as computers to respond. Trading at the same time a trigger condition is met would be something very difficult for an individual trader to match because multiple factors are involved like slippage, etc. Hence, by trading on the following Open candles, we try to make it a bit realistic. If traders want to account for more slippage, then they could switch to an average of the next Open and Close or High and Low as well.

Define the value for The Trade by Next

Step 8: Select if your strategy is Long or Short.

Select if your strategy is Long or Short.

Step 9: Define the technical conditions for the Entry & Exit positions of your strategy.

#1 Entry Position: Define your custom technical conditions for the entry position i.e. when to buy using the same visual editor as the Multi-Factor Alerts.

Note: By default, a system-generated name is assigned to your script(s) defined in the Entry & Exit conditions. In the example below, you can observe the default name for the script in the Entry condition labeled as "Papa" and the default name for the script in the Exit condition labeled as "Yankee".

You can rename these system-generated names assigned to your scripts and if there are multiple scripts defined in your technical conditions, then you will be able to track which script triggered the entry and exit conditions through these custom names visualized on the chart.

Define the technical conditions for the Entry & Exit positions

Click on the “add parameter here” and select any of the following from the dropdown list:

  • Condition: Select this option to add a parameter(s) within a group.
  • Condition Group: Select this option to add a parameter(s) to a group nested under an existing group.
  • Load From Template: Select this option to load a pre-made script template.

Since Strategy Tester uses the same builder tool as Multi-Factor Alert, you can refer to the documentation on How to Create Multi-Factor Alertsto learn more about- pre-made script templates, saving a template, removing a template, commenting on the block, and more.

Note: You can add multiple scripts while defining the entry position.

#2 Exit Position: Define the criteria for the exit position i.e. when to sell by using any of the following or the combination of the following conditions:

A. ADD SCRIPT: Add the technical conditions for the exit position using the same visual editor as the Multi-Factor Alerts.

Add the technical conditions for the exit position

B. ADD ENTRY INVALIDATED: Using this condition means  entering a position “any time when the entry conditions become true” and exiting when the entry conditions are not true any more.

ADD ENTRY INVALIDATED

C. ADD “# CANDLES PASSED”: Exits the position after a given period of time, for example. “30 candles”.

ADD “# CANDLES PASSED

D. ADD “TAKE PROFIT”: Exits when your position gains more than X%. The logic uses a "Limit Order" to provide a realistic price.

ADD “TAKE PROFIT”

E. ADD “STOP-LOSS”: Exits when your position loses more than X%. The logic uses a "Stop Market" order to provide a realistic price.

ADD “STOP-LOSS”

F. ADD “TRAILING STOP”: Exits when your position loses more than X% from its most recent high price.

ADD “TRAILING STOP”

Note: Take Profit, Stop Loss and Trailing Stop have an option of “executing upon candle close only” which is different from how they work in the real world. However, this option makes them match “how Trading Bots behave” on TrendSpider. So in case if you are testing a strategy for the purpose of running a Trading Bot with it, please make sure to have this “On candle close” option active.

Using the combination of any condition from A to F explained above allows you to create a sophisticated exit condition. For example, you may exit the position when the SMA 20 crosses down through SMA 50 and implement a 2% stop-loss.

Note: The traders can have as many Scripts for entry and exit conditions as they want.

Step 10: When you're ready to run the test, simply click the Run button and visualize the results of your strategy on the chart.

click the Run button and visualize the results of your strategy

Note: TrendSpider provides advanced backtesting conditions for traders looking for greater control, including offsets and time-based conditions. Offsets are required for some situations like when testing Ichimoku Cloud strategies. In these cases, the TrendSpider will warn the users.

For more information, please refer to the documentation on Offsets & Time-based Conditions

Also, every time you flip through the charts from the Watch list, the backtester will run again.

Visualize the Results

TrendSpider makes it easy to visualize how a strategy performs on a given chart by automatically painting entry and exit arrows onto the chart as long as you have your Strategy Explorer widget open.

In other words, it helps you understand and explore when you would have traded if you happen to be trading with your custom strategy. In the example below, you can observe the results of the test run on the chart.

TIP: You can also maximize the chart to the full screen by clicking on the full-screen option at the top-right corner of the chart 💡

Visualize the Results

In this example above, it can be observed that::

  • Some positions seem to exit fast and lose money. You might want to search for a way to avoid that, such as by modifying your Stop Loss level or overall Exit condition. You might think of reworking the Entry condition as well, as these entries do not look very promising.
  • Sometimes you exit too late, missing the highest points. You might want to revisit your Exit condition to identify better spots.

For more information on exploring charts to view the performance of your strategy, please refer to the Understanding Charts in Strategy Tester documentation.

Save & Clone Strategies

Save Strategies

A saved strategy is a complete set of buy and sell rules that are saved together in one place for easy recall. Saved strategies will include:

  • All technical (script) entry and exit conditions
  • The timeframe of the strategy
  • The depth of the strategy
  • The "Trade By" selection of the strategy (by default, set to Next Open)
  • The directional bias of the strategy (e.g. Long or Short)
  • Any non-technical exit criteria, such as stop losses, time-based exits, etc.

To save your strategy, a name should be assigned to the same first by using the name field provided in the top left corner of the Strategy Tester. After that, simply click on the Save button

save your strategy

As a result, your strategy will be added to the Strategy List in the left panel. The strategy list displays all the saved strategies, along with some premade strategies shared by TrendSpider for everyone.

 Strategy List in the left panel

Clone Strategies

TrendSpider provides you with an option to clone any of the existing strategies from the strategy list for creating a duplicate copy of a particular strategy.
When a strategy is cloned, a complete copy of all of its entry and exit conditions is done along with the rest of the configuration without any specific exceptions which you can use as a base for creating the new strategy.

Note: If the original strategy had any unsaved changes, then the cloned version will have them too.

Step 1: Click on the vertical ellipsis () adjoining the Save button.

vertical ellipsis \(⋮\) adjoining the Save button. 

Step 2: Select the Clone this Scanner option from the list.

Clone this Scanner option

As a result, you will be able to create a new strategy by using the existing entry and exit conditions and other configurations as a base. You can choose to keep these or edit the same as per your requirements.

Once done, then you can Scan your conditions and Save them as well.

Scan your conditions and Save them

If you add a hashtag to the strategy name (like Top Gun Strategy #sma #rsi), then the tag name will become clickable in the list of your strategies. This will allow you to group and organize your pre-made strategies.

Download Backtest Data to CSV or TSV

You can easily download the results of any backtest in the CSV or TSV data by following the steps outlined below:

Step 1: Click on the Trades button.

Click on the Trades button.

Step 2: Select either of the following as per your requirements:

  • Download test results as TSV
  • Download test results as CSV

Download Test Results in TSV or CSV

The resulting file has several columns including

  • Entry Candle Open Time
  • Entry Price
  • Exit Candle Open Time
  • Exit Price
  • Closed (Boolean)
  • Exit Reason
  • Length in Candles
  • Return (%)
  • Max Gain (%)
  • Max Drawdown (%)

Note: You can also reset your backtest results by selecting the Reset Backtest Results from the list populated under the Trades button.

Create Multi-Factor Alert

On the top of each technical condition set, you will find the option to create the Multi-Factor Alert by clicking on the Alert me Next Time This Happens.

Create Multi-Factor Alert

As a result of this action, you will be able to create Multi-Factor Alerts on your conditions. For more information, please refer to the documentation on Multi-Factor Alerts.

Setup MFA conditions

Sep 27, 2022

Contact Us

Not finding what you're looking for? Contact Us Directly