Skip to content
All library documents

Backtesting Limit and Stop Strategies with Intraday Bars and Bracket Orders

Article Quant Q&A · Author: dizzy

Summary

The document identifies a backtesting problem that close-to-close price series may not capture: a signal generated from daily data can lead to a limit or stop order that may or may not fill on the next session. The desired research setup would evaluate those orders against hourly bars, allow different intraday trade-management rules, and support one-cancels-other brackets for profit targets and loss stops.

A response points to the R quantstrat package, associated with TradeAnalytics, as a possible fit for someone already using R. It also mentions an introductory article and a presentation on quantitative strategy development in R as starting points. The discussion provides a software lead rather than a demonstrated implementation or comparison of tools. It does not establish how accurately the package simulates order priority, intrabar sequencing, slippage, or partial fills, so those capabilities would need to be checked against the intended backtest assumptions.

Key ideas

  • Daily signals can be evaluated with finer intraday bars to model order management.
  • Limit and stop orders require explicit assumptions about whether and when they fill.
  • One-cancels-other brackets can represent linked profit-taking and loss-control orders.
  • The response suggests the R quantstrat package as a possible backtesting tool.
  • The document offers no package comparison or validation of fill simulation behavior.

Tags

Full text
# What tools and libraries may be used to model limit/stop systematic trading?


# What tools and libraries may be used to model limit/stop systematic trading?












A lot of the tools/libraries out there seem to focus on close to close time series analysis. This is all fine but I typically do not trade close to close, I will use limit or stop orders that may or may not get filled.

So for example if I get a buy signal at time t, I would place a buy limit for time t+1 at the level suggested by my model.

I was wondering if there was an existing library or package out there that I could use for backtesting such a system. Ideally, it could handle signals based off a daily series, but move through using hourly bars so I can test different intraday trade management strategies as well. It would also be good if I could put OCO bracket orders for profit/loss stops.

I am using R at the moment but can use whatever has what I am after.

## Answer by Louis Marascio (score 1)

https://quant.stackexchange.com/a/3854

The quantstrat R package (which seems to be a part of TradeAnalytics) might be a good solution if you're already using R for analysis. This introductory blog post explains some of the features. There was a presentation at R/Finance 2011 by Brian Peterson about developing quantitivate strategies in R, here is the PDF of the talk.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.