# Dynamic Grid Mode (DGrid)

Dynamic Grid is an adaptive version of Grid and Reverse Grid mode. Instead of having to manually switch between the two, DGrid continuously reads the market's volatility regime and automatically switches between **Grid** (mean-reverting) and **Reverse Grid** (trending) behavior, while also resizing its own spread to match recent price movement.

Think of it as a Grid bot that adjusts its own dials. While the market is relatively calm and ranging sideways, it stays in Grid mode. As volatility spikes and price starts trending.

#### How it works

Every 30 seconds, DGrid pulls two pieces of market information:

1. **Variance ratio** of a chosen volatility proxy - the bot's signal for whether the market is ranging or trending.
2. **Realized move** on the pair you're trading, measured as the average 5-minute price change over the last hour - the bot's signal for how much price is actually moving.

It then makes two decisions:

1. **Which mode to be in.** Using a hysteresis band to avoid flip-flopping:

* Variance ratio at or above **1.25** - switch to **Reverse Grid** (trend regime)
* Variance ratio at or below **1.15** - switch to **Grid** (mean-reverting regime)
* Anything in between - hold the current mode

2. **What spread to quote.** Sized automatically from realized move, capped at 50 bps. In Reverse Grid phase the spread is forced to zero, since the two directional legs create the offset themselves.

* **Soft reset threshold.** Automatically derived as roughly 4x the current spread, snapped to the nearest standard option (5, 12.5, 25, 50, 100 bps), so the grid recenters at the right sensitivity for current volatility.

#### Configuration

| Setting                    | What it does                                                                                                                                                                 |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Volatility asset class** | The proxy DGrid watches to detect regime: **Crypto** (BTC), **Metals** (XAUT), **Stocks** (S\&P 500), or **Oil** (CL). Choose the one most correlated with your traded pair. |
| **Spread (bps)**           | Optional starting value. DGrid overwrites this on the first 30-second tick using realized-move sizing.                                                                       |
| **Stop loss %**            | Standard MM stop loss. Default 10%.                                                                                                                                          |
| **Take profit %**          | Optional. Same behavior as other modes.                                                                                                                                      |
| **Grid soft reset**        | Auto-derived by DGrid when set to a percentage. If you set explicit price bounds instead, those are respected.                                                               |
| **POV preset**             | Aggressive / Normal / Passive, same as other modes.                                                                                                                          |

#### Risk controls

DGrid inherits the same protections as Grid and Reverse Grid, applied automatically based on which phase it is currently in:

* **In Grid phase:** stop loss watches **realized PnL** - cancels if losses exceed your threshold.
* **In Reverse Grid phase:** stop loss watches **unrealized PnL** - cancels if open exposure moves against you.
* **Take profit:** evaluated against total PnL across both phases.
* **Soft reset:** triggers when mid-price drifts beyond the auto-derived threshold, recentering the grid around the new price.

#### When to use DGrid

DGrid is best for pairs whose behavior shifts between ranging and trending throughout the day. If you find yourself manually toggling between Grid and Reverse Grid, or constantly retuning your spread as volatility changes, DGrid automates that process.

It is less suited for situations where you have a strong view on market direction (use Grid or Reverse Grid directly) or where the pair's behavior is very stable (a static mode is simpler and more predictable).

#### Comparison

|                    | Grid            | Reverse Grid     | DGrid                      |
| ------------------ | --------------- | ---------------- | -------------------------- |
| **Mode switching** | Static          | Static           | Automatic every 30s        |
| **Spread sizing**  | User-set        | User-set         | Auto from realized move    |
| **Soft reset**     | User-set        | User-set         | Auto-derived (\~4x spread) |
| **Best for**       | Ranging markets | Trending markets | Shifting / mixed regimes   |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tread.fi/bots/market-maker-bot/reference-price-modes-and-risk-controls/dynamic-grid-mode-dgrid.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
