GridRunner

Spot & FuturesMean Reversionv1.0

Overview

Adaptive grid trading strategy that dynamically adjusts to market conditions. Places a grid of buy orders below and sell orders above a calculated center price, profiting from price oscillations within the grid range. Detects the current market regime (ranging, trending up/down, or high volatility) and adapts grid spacing, center bias, and position sizing accordingly. Grid spacing is ATR-based and automatically adjusts to current volatility. Includes margin ratio gating, max filled level limits, trailing stops on accumulated positions, and emergency close for when price breaks the grid boundary.

Requirements

Required Indicators

RSIMACDBollinger BandsADXATR
Supported MarketsSpot & Futures

Configuration Parameters

Grid Settings

Configure grid structure, spacing, and direction

ParameterTypeDefaultDescription
TRADE_DIRECTIONTrade DirectionSelect: long | short | bothbothGrid direction: long = buy low/sell high, short = sell high/buy low, both = bidirectional
GRID_LEVELSGrid LevelsNumber4Number of grid levels per side
SPACING_MODESpacing ModeSelect: atr | percentage | fixedpercentageHow grid spacing is calculated
SPACING_ATR_MULTSpacing ATR MultiplierNumber1ATR multiplier for spacing (when mode=atr)
SPACING_PERCENTSpacing PercentNumber1Percentage between levels (when mode=percentage)
SPACING_FIXEDSpacing FixedNumber100Fixed dollar spacing (when mode=fixed)
GRID_RECENTER_THRESHOLDRecenter ThresholdNumber3Recenter grid when price moves beyond N levels

Risk Management

Configure margin, position sizing, and emergency limits

ParameterTypeDefaultDescription
MAX_POSITION_MARGIN_PCTMax Margin (%)Number40Max margin usage percentage before pausing entries
MAX_FILLED_LEVELSMax Filled LevelsNumber4Max simultaneous filled levels on one side
SIZE_PER_LEVEL_PCTSize Per Level (%)Number3Balance percentage allocated per grid level
EMERGENCY_CLOSE_ATR_MULTEmergency Close ATR MultNumber8Emergency close when price moves N x ATR from center
MIN_SPIN_BETWEEN_ORDERSMin Spins Between OrdersNumber1Minimum spins between consecutive orders

Strategy Logic

Configure trend detection and grid bias behavior

ParameterTypeDefaultDescription
TREND_ADX_THRESHOLDTrend ADX ThresholdNumber25ADX above this = trending market
ENABLE_TREND_BIASEnable Trend BiasBooleanDisabledShift grid center with detected trend direction (opt-in)
ENABLE_TRAIL_STOPEnable Trailing StopBooleanDisabledEnable trailing stop on accumulated position (opt-in)
TRAIL_ACTIVATION_PCTTrail Activation (%)Number5Trailing stop activation percentage
TRAIL_PERCENTTrail PercentNumber2Trailing stop distance percentage

TP/SL Configuration

Configure take profit and stop loss distance modes

ParameterTypeDefaultDescription
TAKE_PROFIT_MULTTake Profit MultiplierNumber0.7Take profit as fraction of grid spacing
TP_SL_MODETP/SL ModeSelect: spacing | percentage | atrspacingTP/SL distance mode: spacing = fraction of grid spacing, percentage = fixed %, atr = ATR-based
TP_PERCENTTP PercentNumber1TP distance as percentage of fill price (when mode=percentage)
SL_PERCENTSL PercentNumber2SL distance as percentage of fill price (when mode=percentage)
TP_ATR_MULTTP ATR MultiplierNumber1TP distance as ATR multiple (when mode=atr)
SL_ATR_MULTSL ATR MultiplierNumber2SL distance as ATR multiple (when mode=atr)

Version Info

Current Version: v1.0

Latest Changes

Initial release

Changelog

VersionDateTypeChanges
v12025-02-18Initial release