A Basic Price-Crossing Grid Strategy with Fixed Price Levels
Summary
This script initializes a ladder of price levels around the current market price, spaced at 0.3% intervals, then checks the latest price once per second. When price crosses below a level with no tracked buy assigned there, it submits a fixed-size buy and records that level. When price crosses back above a tracked level, it sells a fixed quantity if the account’s available stock meets a threshold, then removes the lowest tracked level from the list.
The example illustrates a simple grid approach intended to buy downward moves and sell on upward recrossings. It provides no backtest or performance evidence, and omits important controls: the level range is fixed at initialization, order results are not checked, fees and slippage are ignored, and inventory or cash risk is not capped. Its state tracking and selling logic may not match actual fills or corresponding entry levels, so live behavior can diverge from the intended grid.
Key ideas
- The script creates fixed price levels around the starting market price at 0.3% spacing.
- It buys when the latest price crosses below an unoccupied level and records that level.
- It sells a fixed quantity after an upward crossing if the account passes a stock threshold.
- The example does not include performance evidence, fill reconciliation, or comprehensive position limits.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.