Skip to content

Troubleshooting

You will get stuck at some point. It happens to everybody. Assuming all build errors have been resolved and you are able to produce a backtest report, but it doesn’t look right, start here:

  • Start with the data. Visualize the data using the Chart() extension method. Make sure it looks reasonable. Are there any bad ticks that might be causing problems?
  • Make sure all the BarSeries you are testing have a properly specified Instrument, particularly for futures data.
  • Run the strategy on an individual symbol and call Chart() on the strategy itself. Confirm that the trade entries/exits look correct.
  • Consider exporting the strategy calculations to Excel for further study. Run a strategy and then call GetActiveSeries().ExportToExcel().
  • Set breakpoints in OnBarClose() to step through trading logic that might be problematic.
  • Enable order history for futher analysis.
var strat = new TestStrat();
strat.OrderHandler.EnableOrderHistory = true;
strat.RunSimulation();
strat.OrderHandler.GetOrderHistory().ExportToExcel();
  • Pay attention to warning messages printed to the Console. More verbose logging may help as may watching order status change messages.
var strat = new TestStrat();
strat.Message += ConsoleLogger.Verbose;
strat.OrderStatusChanged += (o, e) =>
{
if (e is OrderRejectedEventArgs reject)
{
Console.WriteLine(reject.Reason);
}
};
  • Beware of path dependency problems for strategies that are active and both enter and exit on stops or limits. Daily bars do not have the resolution required to definitively know the sequence in which orders are filled. Try changing the strategy’s SimulationOptions.IndeterminatePriceSequenceRule property. Do the results differ dramatically depending on this setting? If so, you may need to modify logic or test on more granular data.
  • If you have a money manager attached to the strategy, make sure the risk levels are reasonable. If you are risking too much, extreme volatility can cause strange results, not to mention 100% drawdowns.