Generic Strategy Backtesting with Risk-Based Sizing and Bracket Exits
Summary
This generic backtesting script accepts user-provided long and short input series and turns changes in those series into entry signals. It permits a new position only when flat, sizes orders from a chosen fraction of equity and the configured stop distance, and attaches percentage-based stop-loss and take-profit exits around the average entry price. It also plots the entry markers and active exit levels.
The document provides implementation details and default risk and exit settings, but no test results or evidence that the framework performs well. Its sizing function refers to the average price of the current position when calculating quantity at entry, which may be undefined while flat, so users should validate that behavior in their platform. The input-to-signal conversion, execution assumptions, and risk sizing also need review before relying on a backtest; the script is a reusable scaffold, not a validated strategy.
Key ideas
- Long and short entries are triggered by changes in user-supplied input series.
- The script restricts entries to periods when no position is open.
- Position quantity is intended to reflect a fraction of equity and the stop distance.
- Percentage stop-loss and take-profit levels are based on the average position price.
- No performance evidence is supplied, and the entry-time sizing calculation warrants validation.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.