Creating a New Strategy

The Strategy Tester enables you to easily test entry and exit strategies over any period of time.





Strategy tester condition

#1 - You can access the Strategy Tester by clicking on the Strategy Tester button in the web application by navigating to the bottom left corner.

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

#2 - Specifying the Chart TypeTimeframe, and Data Depth, as well as your Settings.  Settings enabled you to select whether you strategy is going long or short, as well as setting your Trade Costs.

Next, you can specify multiple Entry Conditions and Exit Conditions. Click Add Parameter Here to create a new script and then select a condition or load an existing script template. Exit conditions include both conditions and Take ProfitTrailing Stop, and # Candles Passed capabilities. You can also add a Stop Loss as a static percentage. You can also add negative conditions (e.g. "none of the following") to identify cases where certain candlestick patterns haven't evolved over time when other conditions are true.

#3 - Defining Entry Conditions

The first step is defining an Entry Condition — or “when to buy” (#2). You can define these entry conditions using the same visual editor that powers TrendSpider’s multi-factor alerts. For example, you might create an entry condition where the SMA 20 is above SMA 50 and the “4 Green Candles” pattern forms.

#4 - Defining Exit Conditions

After you’ve added an Entry Condition, you need to decide when to exit the positions — or “when to sell” — by setting Exit Conditions (#3).

The Strategy Explorer offers a few options:

  • The most obvious option is adding another “Script” (e.g. the same kind of multi-line conditions as the Entry Condition).
  • “X Candles Passed” exits the position after given period of time (e.g. “5 candles”). This is not very useful for real trading conditions, but we’ve added it for research purpose only (e.g. when you’re willing to focus on exploring Entry Condition only).
  • “Take Profit” exits when your position gains more than X%. The logic uses a "Limit Order" to provide a realistic price.
  • “Stop Loss” exits when your position loses more than X%. The logic uses a "Stop Market" order to provide a realistic price.
  • "Trailing Stop Loss" exits when your position loses more than X% from its most profitable point. Note: This exit condition can be imprecise for very long candles, but closely matches reality in most situations.

You can use any combination of these conditions.

For example, you may exit the position when the SMA 20 crosses down through SMA 50 and implement a 2% stop-loss.

When you're ready to run the test, simply click the Run button (#4).

For more information on Strategy Tester, please refer to the documentation on Understanding Strategy Tester from TrendSpider

Using explicit list of signals

You can also specify time stamps of triggering candles explicitly, instead of configuring backtester criteria in TrendSpider directly. This is useful in case if you already have a system which generates signals and you want to leverage TrendSpider's unique visualizations for results of backtests.

You can have a list of signals in both Entry and Exit sections. Each list is supposed to contain one signal per line. Order of signals does not matter. Comments (any line starting from #) and empty lines are allowed.

Date/time formats supported

We are flexible in terms of formats of dates we support. Here's a list of options, but it's not exhaustive.

  1. Unix time stamp. I.e., 1683755663
  2. JS time stamp. I.e., 1683755663924
  3. ISO datetime (ISO 8601). I.e., 2023-05-10T21:54:49.486Z
  4. Various human-readable formats, like 23 Aug 2022 09:00 EST, or 03/21/2023 10:00 CST, May 10, 2023 18:30 GMT-04 e.t.c

Time stamps passed as human-readable text should have a time zone specified.

For Daily charts and above, you should still specify full date and time, specifying the date only won't work. Time is supposed to be equal to session start time.

Time zones of signals

It is your responsibility to provide time in a correct time zone. If you don't specify any time zone in your time stamps, then we'll use UTC by default. We're suggesting you specifying time stamps in UTC since it's going to result in the most straightforward behavior. Using other time zones can be quirky. In example, if you'll want to specify a time zone explicitly, then you'll have to know when to use EST and when EDT.

Please mind your chart's time axis time zone when browsing a chart. We suggest you holding everything (charting and time stamps in your backtester) to the same time zone, whatever it is.

Signal order and time stamp

If you provide signals, then please remember the following:

  1. You should provide a list of time stamps of triggering candles. Backtester will always enter on the next candle after trigger, just like it does with other condition types like Script.
  2. Order of records in your list does not matter.
  3. In case if backtester is in a position and then it faces a candle which has yet another Entry signal, this new signal will be ignored. The same is true for Exits.
  4. You should specify time stamps of "triggering candle open" precisely. Internally, backteser uses strict mathematical equality of JS time stamps when determining whether a candle shoudl trigger a signal.

Other use cases for lists of signals

You can also use this feature in case if you're willing to share your strategy without revealing its underlying criteria. In example,

  1. Build a real strategy (with your criteria) on TrendSpider.
  2. Run a backtest and download list of positions as CSV.
  3. Create a new blank strategy and specify signals using time stamps (use Triggering Candle Open Time columns).
  4. Share this new strategy.
Oct 7, 2024

Contact Us

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