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

Let’s get started 🚀

Strategy Tester

A Strategy Tester (or Backtester) is a tool that you can use to see how a strategy you have defined has behaved on the past data. One of the best things about the TrendSpider 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 Limitations of Backtesting

First and foremost, you should understand that no back tester ever can tell you that your strategy is awesome and you should use it right away. The only thing a strategy tester can do (and it's quite good at that!) is tell you if your strategy sucks badly. Realizing that changes the game.

You should not focus on building a strategy that beats buy and hold in a backtest. You should rather focus on building a strategy that can not be disproven (aka "illustrated to suck badly") by a back tester.

Backtesting looks at the past. It tests how a strategy would have performed if traded perfectly in the past. Remember, past performance doesn't guarantee future results, so don't assume it will.

In backtesting, it's assumed that you can execute trades flawlessly and without delay like a robot would. However, as a human trader, it's important to recognize that you may not be able to execute trades at the exact same prices as the strategy tester unless you automate your trading process. Keep in mind the limitations of human speed and consider automation for more precise trade execution.

Here are some limitations that are specific to TrendSpider.

#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 Our back tester assumes that you always can afford an entry, never mind what kind of losses you have had. This might introduce some unrealistic outcomes into strategies with significant drawdown.

The Advantages of Backtesting

Despite the fact that past performance can't guarantee results in the future, you want to backtest your strategies. Backtesting is going to give you some very valuable information. You need to step away from obvious things like "Was it profitable or not" and go a step deeper. You can see how the strategy behaved, so you can see the important meta-information about its character or personality, so to speak. For example,

  1. Was the strategy producing lots of trades or rather few of them? You need to know that to consider brokerage fees etc.
  2. Were your trades delivering a consistent outcome or some of them were negligible and some were spiky? You need to know that to evaluate the risk of investing real money.
  3. What was the worst draw-down for your trades? You need to know that to evaluate the risks and to decide if you need more stop-losses etc.
  4. What were the common drawbacks of a strategy? Did it exit on time or later, did it enter in a timely manner, did it produce early exits?
  5. Is your Win Rate anywhere close to what you need with an R/R ratio like that?

You can figure out the overall temper of a given strategy, which gives you a better vision of what you can expect from it all. Like, if after backtesting your strategy you see that it did 10 trades for the last year, then don't expect it to generally do 3 deals a day in the future.

If 99% of trades in the past were limited to ±1%, then you can fairly assume that doing 30% per trade is going to be an extremely rare (maybe even "barely real") case for this strategy.

If it did a late entry in 100 trades of 120, then don't expect it to catch the moves perfectly (or even "good enough") in the future.

Backtesting is especially good at signaling when your strategy is a definite no-go. It can't ever tell you "You must take this strategy for a ride now", but it can easily tell "Never use this strategy, nothing to see here, pass by". Interpreting the results of backtesting is all about figuring out the nature of a given strategy on a given market, and learning more about chances.

#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 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 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 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.

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.


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.

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

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

Step 4: Select the time frame to scan from the dropdown list.

Note: Unlike the scanner, alerts, and smartwatch 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 7,000 candles as Data Depth from the dropdown will instruct the tester to accumulate and scan the data from the past 7,000 days.

It is to be noted that 7,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, 7,000 candles selected on a 1-minute chart will scan the data for 7,000 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 7,000 candles will include 3.59~ days of data (7000 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 27.7 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 and 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. 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. 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 anymore. A thing like that can be useful if your entry criteria do not include the "trigger condition" (which only stays true for a candle or two) and only include "filter conditions" (which can last).


C. # CANDLES PASSED: Exits the position after a given period of time, for example. “30 candles”. This condition can also take your current PnL into account. I.e., if your Price Behavior Explorer shows you that if a position has not gained +1% after 10 candles then it will never be a winner, then you might add Exit after 10 candles if PnL < 1% in order to capture at least some profits from the positions which will convert into losers otherwise. Be aware that using that means curve-fitting your strategy. It's not necessarily a bad thing to do, but you have to understand the implications.


D. TAKE PROFIT: Exits when your position gains more than X%. The logic uses a "Limit Order" to provide a realistic price. The "after candle close" checkbox uses "market price after candle close" to emulate filling your stop loss order. This is not how real stop market orders work, but it's a safe way to go if you're going to automate your strategy and run it as a Trading Bot.


E. STOP-LOSS: Exits when your position loses more than X%. The logic uses a "Stop Market" order to provide a realistic price. Mind the "after candle close" checkbox, just like for a stop loss.


F. TRAILING STOP: Uses a classic percentage-based trailing stop; exits when your position loses X% from its highest high. Mind the "after candle close" checkbox, just like for a stop loss or take profit.


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 and time-based Conditions

Also, every time you flip through the charts from the Watch list, the back tester 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 happened 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 to create 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 them as per your requirements.

Once done, 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 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 29, 2023

Contact Us

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