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
  • Performance Chart
  • Tabular Data
  • Price Behaviors Explorer
  • 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 than 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 theNEXTcandle of the selected value.

Note: By default, theOpenis 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 followingOpencandles, 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: Invalidates the entry conditions. As a result, when you will run the test, then it will indicate “Buy” when the entry conditions are true or “Sell” when the entry conditions are not true.

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”

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.

Price Behavior Explorer

After running your backtest strategy, you will be able to view the Price Behavior Explorer chart that lets you explore the average behavior of price in your strategy for a certain amount of time while you are in a position.

Price Behavior Explorer

You can use this chart to discover if you were buying and selling at the right time, as well as to discover ways for improving your exit conditions.

Price Behavior Explorer Full Screen

Mean Change% (Blue Line)

Toggle on the Mean Change % from the chart legend at the bottom. The mean change% line on the chart reflects the mean (average) percentage change in returns after certain candles. You can co-relate this mean change% with the Y-axis (right) which reflects the percentage return scale and the X-axis at the bottom which reflects the number of candles from entry.

Mean Change%

Median Change% (Purple Line)

Toggle on the Median Change % from the chart legend at the bottom. The median change% line on the chart reflects the median percentage change in returns after certain candles. You can co-relate this median change% with the Y-axis (right) which reflects the percentage return scale and the X-axis at the bottom which reflects the number of candles from entry.

Median Change%

Random Control (Mean)

Toggle on the Random Control (Mean) from the chart legend at the bottom. Sometimes the market just goes up regardless of the strategy which makes it difficult to know if your strategy is responsible or if it’s the underlying market. The same is true for extensively declining markets and short trades. This is where Random Control Line (Dotted) helps by allowing you to know the root cause for your outcome while testing the strategy.

Random Control \(Mean\)

# Of Positions

Toggle on the # Of Positions from the chart legend at the bottom. This will plot the black line on the chart reflecting the number of positions/trades that have been completed after certain candles from entry. Toggling this on will plot the number of positions on the X-axis (left).

# Of Positions

25th/75th Percentile (Pale Blue Cloud)

Toggle on the 25th/75th Percentile from the chart legend at the bottom. The 25% percentile to 75% percentile range is shaded on the chart widget to show where “most” of the percentage changes or volatility took place.

25th/75th Percentile

Min/Max Change%

Toggle on the Min/Max Change% from the chart legend at the bottom. The minimum and maximum mean percentage changes are shaded on the chart to show the absolute highs and lows over certain candles.

Min/Max Change%

Performance Chart

After running your backtest strategy, you will also be able to view the Performance Chart that reflects the relevant performance of your strategy vs. buy and hold.

Performance Chart

It combines a bird-eye view of a whole lot of history used for your backtesting using gray and blue lines.

bird-eye view of a whole lot of history used for your backtesting

Asset (Gray Line)

Toggle on the Asset (BMEA) the chart legend at the bottom. This is the stock price line (gray) which shows the performance of the buy and hold. In the example below, if you would have bought this stock and would have never sold it, then you would have lost -32.08%. However, through your trading strategy, you would have lost only -25.73%, hence you outperformed the buy and hold strategy in this case.

 Asset \(BMEA\)

Positions

Toggle on the Positions from the chart legend at the bottom. This makes some parts of the Asset Performance line green and some parts red. The green area on the line indicates that you entered the trade and you were profitable. The red area on the line indicates that you entered the trade but lost your funds.

Toggle on the Positions from the chart legend

Position Contribution Chart

The position contribution chart, also known as Winners Vs. Losers chart gives you a sense of consistency of your positions’ outcomes. It is a horizontal chart in which the Winning attributes (shaded in green) are placed on the right and Lost attributes (shaded in red) are placed on the left.

In the example below, you can observe that you lost 86% of the trades and won only 14%. Hence, in this case, it is communicating that your strategy has not been very effective.

Position Contribution Chart

You will observe each strip (red and green) having a number of short vertical lines painted on it. These lines indicate the impact of a single position — the further the line stands from a previous one, the higher was the impact of this trade.

Position Return Distribution Chart

The Distribution of Gains and Losses is a powerful chart that reflects the total distribution of all your trades. The horizontal axis is “change (%)”, and each circle represents the outcome of one position. All the losing positions are painted red, all the winners are green.

The biggest winning trade is found on the extreme right and the biggest losing trade is found on the extreme left. Moreover, you can also view the Average Loss%, Average Return%, and Average Gain%.

Position Return Distribution Chart

Drawdown

Toggle on the Drawdown from the chart legend at the bottom. This shows how lows (how much you have given back) in comparison to your highs. With this, you can navigate your worst point (drawdown) in your strategy. In the example below, the worst point is at -25.73%.

Drawdown from the chart legend

Tabular Data

To the right of the performance chart, you will find the tabular data, which is a result of the backtest and provides you with the statistics that help you compare your strategy.

Tip: You can also copy and paste this information if you want to share it with others 💡

tabular data

The meaning for each of the metrics in the Tabular Data has been explained in the table below:

Metrics Interpretation
Market Represents the symbol on which the backtesting has been performed
Net Profit Represents the Net Profit Margin Ratio for the entire strategy during its entire duration
Data Analyzed Represents the time for which the data has been analyzed in the backtesting
Asset Performance Represent what would have happened if you bought and held the asset the entire time
Beta Vs. Asset Represent how close the value of the buy/sell strategy is relative to the price (e.g. does it move with the price or not).
Positions Represent the number of positions/trades analyzed during the backtesting
Wins Represent the percentage and number of winning trades out of the total trades analyzed
Losses Represent the percentage and number of lost trades out of the total trades analyzed.
Max Drawdown Represents the biggest pullback during the strategy in terms of the percentage. For example, when you gave back the most gains. The smaller this percentage, the better it is.
Average Win Represents the average of a winning trade.
Average Loss Represents the average of a losing trade.
Average Return Represents the average of a series of returns generated over time as analyzed in the backtesting.
R/R Ratio Represents the Risk vs. Reward ratio which measures the profit potential of a trade relative to its potential loss.
Expectancy Represents the average amount you can expect to win or lose per trade with your strategy when a large number of trades are taken (at least 30 to be statistically significant).

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 theReset Backtest Resultsfrom the list populated under theTradesbutton.

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

Jul 1, 2022

Contact Us

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