Building a Pine Grid Strategy with Configurable Orders and Exits
Summary
The document walks through a long, short, or two-sided grid strategy written in Pine for use with FMZ. Users set grid spacing, order size, grid count, and take-profit distance. When the live bar begins, the strategy records a starting price, plots grid levels, and places limit entries at levels above or below that price. It assigns each grid order an identifier to avoid submitting another entry while a position with that identifier is open, then attaches an exit at the chosen profit distance.
The article explains Pine inputs, live-versus-historical bars, order identifiers, and the order and exit calls, alongside an FMZ backtest configuration. It includes a sample configuration and charts, but gives no detailed performance statistics or costs. The author explicitly cautions that grid trading can lose money and that results depend on usage and parameters. The example is an implementation tutorial, not evidence that the strategy is profitable; its behavior also depends on platform and execution assumptions.
Key ideas
- The grid starts from the price observed when the script enters its live-bar phase.
- Grid spacing, direction, order size, number of levels, and exit distance are configurable inputs.
- The strategy places limit orders at grid levels and gives each entry a label to check for an existing open trade.
- Historical bars are distinguished from live bars so the example does not initialize its grid from past data.
- Grid trading carries risk, and the example provides no basis for assuming profitable results.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.