web analytics
< All Topics
Print

Debug Your Strategy

Watch our tutorial video below to see how to debug / fix your  trading strategy when it is not working as expected.  Login to your account to follow along with the video!

There are usually 2 reasons why your strategy may not be working as expected:

  • Your trading signal / entry signals may not have triggered properly.
  • If your trading signals were triggered but no transactions were “filled”, your strategy block / strategy filters may NOT match any available spreads at the time of order execution.

Check Trading Signals / Studies

To debug your strategy, first check if your trading signals are being triggered:

  • Technical studies that take a timePeriod as an argument (i.e. 20 period Moving Average) won’t be fully initialized until (timePeriod + 1). For example, the 20-day Moving Average will take (20+1=21) data ticks before it is fully initialized.
  • Try reducing the timePeriod in your studies or increasing the backtest time range if your study doesn’t trigger. Check that your backtest time range is much greater than the longest timePeriod specified in your studies.
  • Plot your trading signals using the Plot block, and inspect the chart to see if market conditions indeed match your trading signals.
Screen Shot 2018-12-02 at 8.24.19 AM
Screen Shot 2018-12-02 at 8.26.10 AM
  • Attach a Log block entry to your trading signals / rules.  This will print out messages to the Log panel if your trading signals were actually triggered.
Screen Shot 2018-12-02 at 8.29.42 AM
  • Inspect the logs to see if your trading signals triggered.  If your trading signals triggered, you will see it in the Log entries.  If you do not see any such Log entries, your trading signals did not trigger and you should modify your trading rules / signals.
Screen Shot 2018-12-02 at 8.34.16 AM

Check Strategy Block

  • If you see Log messages with “Order [XYZ] was executed, but no positions match at eval time“, there may be issues with your Strategy Block / Strategy Filters.
  • The Log messages may specify which strategy filters may be causing problems. Try removing / disabling the problematic strategy filters.
  • Preview your trade at the timestamps where your orders were executed but failed to match any positions.  You can preview your strategy but clicking on the Magnifying Icon on the Strategy block.
Screen Shot 2018-12-02 at 8.40.17 AM
  • If you are using the SetVariable block as part of your strategy filters, previewing the trade is a slightly more involved. Please use the Log block to print of the values of the variables, and temporarily change the variable to use the values printed in the Logs. (Please see Debugging Variables for more info)
  • Specify the date of evaluation to match the timestamps from the Log entries.
Screen Shot 2018-12-02 at 8.43.28 AM
Screen Shot 2018-12-02 at 8.43.10 AM

Check Strategy Filters

  • If no transactions match during the preview, you need to determine which strategy filters are causing problems.
  • To identify the problematic strategy filters, remove all your filters and manually add your filters back one-by-one, previewing your strategy each time you add a filter.
Screen Shot 2018-12-02 at 8.49.11 AM
Screen Shot 2018-12-02 at 8.50.35 AM
Screen Shot 2018-12-02 at 8.52.20 AM

  • If no positions match after adding a new filter / criteria, this new filter may be problematic.  In this case, remove the filter or modify the filter until at least one position matches your overall strategy.
  • Some strategies already have default filters defined to improve the speed of the backtest.  These default filters may conflict with your filters.  If this is the case, you can disable these default filters by using the “ignoreDefaultFilters” option.
Screen Shot 2018-12-02 at 8.57.55 AM

Check Inputs

  • Check your filter inputs to match the appropriate scale / sign of the filter.  Some inputs may be percentages (i.e. 0.55, 0.75) while others may be numbers (i.e. 20, 45).  Inputs may be signed (positive versus negative) or un-signed. Make sure to use the correct scale / sign of the filters.
  • Check your strategy filters are consistent with the instruments that you are trading.
    •   For example, SPX strikes are generally 10 points apart, while SPY strikes are generally 1 point apart.

Check For Inconsistencies

  • Check whether your filters conflict with each other.  One filter may be incompatible / inconsistent with another filter, resulting in no matching positions.
  • For example, lower strike put options have a lower delta than higher strike put options.  But if you specify a higher delta for your lower strike put options than your higher strike put options, the filters are inconsistent and will result in no matching positions.
  • For example, a standard iron condor has equidistant strike width for the short put vertical (bull put spread) and the short call vertical (bear call spread).  But if you specify different distances / strike widths for the call vertical versus the put vertical, the filters are inconsistent and may result in no matching positions.

Check Position Sizing

Check the position sizing rules in the Size By field to make sure the specified position size is correct. If you are using risk / margin / quantity to size your positions, ensure that the input is a non-zero value. (i.e. non-zero risk, non-zero margin, non-zero quantity)

If you are using a percentage of your portfolio’s buying power / cash balance to size your positions, ensure that your Initial Cash value (in Backtest Settings) is large enough to support the capital requirements of your trades. For example, selling strangles / straddles / naked puts often requires significant buying power / cash balance.


Check Variables

Since the state of variables is dynamic and can change constantly over the course of a backtest, debugging a strategy that use variables is slightly more involved.

To debug your strategy, you should examine the state / value of the variables. Fortunately, you can use the Log block to print the value of the variables. The values of the variables will be outputted into the Log tab where you can view the state of the variables over time. 

To preview trades which use the variables inside the Strategy Block / Strategy Filters, please print the value of the variables using the Log Block, and temporarily set the variables to the values printed in the Logs.  Be sure to set the preview date to correspond to the entries in the Logs. 

Previous Analyze Your Results
Next Tune Your Backtests
Table of Contents