Grid Trading Backtest with Configurable Levels, Sizing, and Stops
Summary
This strategy script backtests a grid whose levels can be spaced arithmetically or geometrically around a reference price. It supports neutral, long-only, and short-only modes, with entries triggered by level crossings or pullbacks. Users can set a test window, choose automatic, compounded, or fixed order sizing, and select how take-profit levels are calculated. Manual levels are available, while automatic mode centers a range on the starting price.
Optional upper and lower price triggers can close positions, and a terminate setting prevents further entries after a trigger. The script includes configurable investment and leverage inputs, but the document reports no performance results. Its backtest settings include commission and slippage assumptions; results will depend on the instrument, chart timeframe, range, and execution assumptions. The code also flags some capital or order-size configurations that may make the reported backtest unreliable or prevent orders from opening.
Key ideas
- Grid levels can use arithmetic or geometric spacing around a chosen reference price.
- The strategy supports neutral, long-only, and short-only modes with crossing or pullback entries.
- Order sizing can be automatic, compounded, or fixed, and take-profit behavior has two options.
- Optional price triggers can close positions and can either allow later resumption or terminate trading.
- Backtest outcomes depend on configured costs, capital, order size, instrument, and timeframe.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.