> ## Documentation Index
> Fetch the complete documentation index at: https://docs.quantumvoid.org/llms.txt
> Use this file to discover all available pages before exploring further.

# XGrid Strategy

> High-frequency momentum grid scalping and the XGrid trend signal engine

# XGrid Strategy

## What It Does

**XGrid is a high-frequency momentum grid scalper: it detects short-term trend direction with technical signals, places a tight grid of orders in that direction, and takes profits within seconds-to-minutes rather than hours.**

<Note>
  **Naming, to avoid confusion:** in the **Marketplace tab**, the "XGrid" family label covers the high-frequency **Perp Market Maker** presets (MM Professional, v7/v8 Counterscalp, HFT v6, …) — the two-sided grid scalper documented in the [Perp Market Maker guide](/strategies/perp-market-maker). This page covers the **XGrid trend signal engine** that powers those presets' counter-scalp features, plus the standalone XGrid strategy. If you came here from a Marketplace card, start with the [Perp MM guide](/strategies/perp-market-maker) and come back here for the signal details.
</Note>

***

## The XGrid Trend Signal

The signal engine answers one question every 30 seconds: **is short-term momentum long, short, or unclear?** It returns `LONG`, `SHORT`, or neutral, and is consumed by the Perp MM's counter-scalp and entry logic.

### How a signal is built

```
1-minute candles
      │
      ▼
EMA 11 vs EMA 23  ──────────►  EMA11 > EMA23 → bullish bias
                               EMA11 < EMA23 → bearish bias
      │                        roughly equal → no signal
      ▼
Donchian breakout check ────►  price near the 15-candle high/low
                               (within 0.30% tolerance) confirms direction
      │
      ▼
NATR volatility filter ─────►  volatility must exceed its own recent
                               baseline (1.1x the 60-candle NATR) and an
                               absolute floor — no signals in dead markets
      │
      ▼
Peak/trough confirmation ───►  recent swing structure must agree
      │
      ▼
SIGNAL: LONG / SHORT  (cached for 30 seconds)
```

### Signal parameters (actual engine defaults)

<ParamField path="timeframe" type="string" default="1m">
  Candle timeframe the signal runs on. The engine is designed for 1-minute momentum.
</ParamField>

<ParamField path="donch_len" type="integer" default="15">
  Donchian channel lookback (candles) for the breakout confirmation.
</ParamField>

<ParamField path="breakout_tol_pct" type="float" default="0.30">
  How close to the channel boundary (in %) price must be to count as a breakout.
</ParamField>

<ParamField path="natr_len" type="integer" default="60">
  Lookback for the Normalized ATR volatility baseline.
</ParamField>

<ParamField path="natr_mult" type="float" default="1.1">
  Current volatility must exceed `natr_mult ×` its baseline for a signal to fire.
</ParamField>

<ParamField path="min_natr_abs" type="float" default="0.02">
  Absolute NATR floor (%). Below this the market is too quiet to scalp regardless of relative volatility.
</ParamField>

<ParamField path="cache_seconds" type="float" default="30">
  Signals are cached for 30 seconds to limit API load; the engine re-evaluates when the cache expires.
</ParamField>

The EMA pair (11/23) is fixed in the engine — the fast EMA reacts to the last \~10 minutes, the slow one filters noise, and their cross defines the bias.

***

## Standalone XGrid Strategy

The standalone XGrid strategy (selectable as `strategy: "xgrid"`) is a faster, tighter sibling of Vortex DCA:

* **2-second take-profit refresh** (vs 60s for Vortex) — exits are managed near-continuously
* **2-minute default grid refresh** (vs 3 minutes for Vortex)
* **Exponential level spacing**: levels start at a configurable `first_level_distance` from price and spread out with a power curve toward `outer_distance`, packing more orders close to the action
* **Startup cleanup**: cancels existing orders on boot so stale orders from a previous run can't interfere
* Shares Vortex's virtual-chunking position recovery (3% threshold, 5 chunks, 0.1% per-chunk target by default)

It uses the same core parameters as Vortex (`nr_clusters`, `outer_distance`, `wallet_exposure`, `minimum_tp`) with tighter values. Current Marketplace presets deploy the perp\_mm implementation instead, which layers full two-sided quoting and risk tiers on top of the same high-frequency idea.

***

## How the Signal Drives Perp MM

### XGrid Counter Scalp

When the Perp MM's main position is underwater and the XGrid signal points the *other* way, the bot opens a counter-position to scalp the move against you:

```
Main position: LONG, underwater
XGrid signal:  SHORT (downtrend confirmed)
        │
        ▼
Open SHORT counter-position (capped at max_counter_pct of main, default 50%)
Quick take-profit on the counter
→ losses on the main position are partially offset while it waits to recover
```

Key behavioral guards:

<ParamField path="xgrid_counter_scalp.enabled" type="boolean" default="false">
  Enable counter-trend scalping. On in the v7/v8 Counterscalp and HFT v6 presets.
</ParamField>

<ParamField path="xgrid_counter_scalp.max_counter_pct" type="integer" default="50">
  Counter position cap as % of the main position.
</ParamField>

<ParamField path="xgrid_counter_scalp.require_signal_cycle" type="boolean" default="true">
  The signal must cycle through neutral before re-entry (prevents whipsaw churn on a noisy signal).
</ParamField>

<ParamField path="xgrid_counter_scalp.min_main_age_seconds" type="integer" default="300">
  The main position must be at least this old before counter-scalping starts.
</ParamField>

### Godmode Scalp

A stricter variant that only fires when multiple confirmations align: main position underwater past a threshold, XGrid confirming the opposite trend, and a whale wall present on the counter side. Fewer entries, higher conviction.

***

## When the Signal Works Well (and When It Doesn't)

| Market                              | Signal quality                                                                                                     |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| Quiet, low volatility               | No signals by design — the NATR filter blocks them                                                                 |
| Steady directional moves            | Good — EMA cross + Donchian breakout align                                                                         |
| High volatility with follow-through | Good — strong, early signals                                                                                       |
| Violent chop / whipsaw              | Weakest case — crosses flip; the signal-cycle guard and peak confirmation reduce but don't eliminate false entries |

Prefer liquid symbols (majors, high-volume alts). On illiquid pairs, the 1-minute candles are too noisy for the breakout logic.

<Warning>
  Counter-scalping trades **against** your own underwater position. It can offset losses in a continued trend, but if the market V-reverses, the counter position loses while the main recovers. The caps above (`max_counter_pct`, signal-cycle requirement) bound that risk — they don't remove it.
</Warning>

***

## Troubleshooting

### "No signals generated"

1. Volatility below `min_natr_abs` or below `natr_mult ×` baseline — the market is too quiet, which is intended behavior
2. EMA11 ≈ EMA23 (no clear bias) — check the log's rejection reason
3. Signal cached — changes only propagate after the 30s cache expires

### "Too many false signals"

Whipsaw conditions. The signal-cycle requirement (`require_signal_cycle`) is the main defense; verify it's enabled before tuning anything else.

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Perp Market Maker" icon="scale-balanced" href="/strategies/perp-market-maker">
    The strategy these signals power (Marketplace "XGrid" family)
  </Card>

  <Card title="Preset Guide" icon="list-check" href="/strategies/preset-guide">
    Which counterscalp preset to pick
  </Card>
</CardGroup>
