# TradersAlly Trade Zones

## TradersAlly Trade Zones

### Product Description

TradersAlly Trade Zones is a market-structure indicator for NinjaTrader 8 that turns price action into actionable, risk-defined trade plans. It detects shifts in market structure (BOS and CHoCH), draws the resulting bullish and bearish zones with configurable Fibonacci entry levels, and projects targets, stops, and optional runner extensions directly onto your chart.

Beyond visualization, it includes a built-in statistics simulator that tracks win rate, points, P\&L, and drawdown for every signal — so you can evaluate a configuration before committing real capital. When you are ready, the same logic drives live auto-trading through the Account API, with on-chart Long/Short toggle buttons, bracket management, breakeven runner stops, and a hard-session-close safeguard.

A full suite of filters lets you trade only the setups you want: time-of-day windows, ATR bands, zone-size limits, EMA directional bias, higher-timeframe confirmation, consecutive-zone streak limits, and Fib-bias gating. Dynamic position sizing reads your instrument's point value automatically and sizes base and runner legs so a stop-out never exceeds your chosen dollar risk.

Everything works identically in simulation and live, so what you backtest is what you trade. Whether you want a clean structural map of the market, a tested statistics engine, or a hands-off automated execution layer, Trade Zones brings all three into a single, configurable tool built for futures traders who manage risk first.

***

### User Manual

#### Overview

The indicator tracks swing highs and lows over a lookback window, confirms a market structure shift (Break of Structure or Change of Character), and creates a directional **zone** between the swing points. A Fibonacci entry level inside that zone defines where a limit entry sits; targets and stops are derived from the zone edges. The indicator can simulate these trades for statistics, execute them live, or both.

> **Note:** This is an *indicator* with its own internal trade simulator. The simulator resolves fills on bar close using bar High/Low, so its statistics are an estimate and will not perfectly match tick-level live or Market Replay fills. The live auto-trade path uses real Account-API orders.

***

#### 1. Structure

| Parameter             | Description                                                                                                             |
| --------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| **Show Swing Points** | Draws dots at confirmed swing highs/lows used to build zones.                                                           |
| **Structure Length**  | Lookback (in bars) for swing detection. Larger = fewer, more significant zones; smaller = more frequent, noisier zones. |

#### 2. Zones

| Parameter                  | Description                                                                                       |
| -------------------------- | ------------------------------------------------------------------------------------------------- |
| **Show Last**              | How many recent zones to keep drawn (only when *Display All Zones* is off).                       |
| **Display All Zones**      | Ignores *Show Last* and keeps every zone on the chart.                                            |
| **Zone Display**           | Which zones to draw/trade: Bullish Only, Bearish Only, or Both.                                   |
| **Clean-Up Level Overlap** | Trims a new zone's lines so they start where the previous zone ended, keeping the chart readable. |

#### 3. Fib Levels

Five independent Fibonacci lines (F1–F5) drawn inside each zone.

| Parameter         | Description                                         |
| ----------------- | --------------------------------------------------- |
| **Fib N - Show**  | Toggle this level on/off.                           |
| **Fib N - Level** | Retracement fraction (0 = near edge, 1 = far edge). |
| **Fib N - Style** | Line style: Solid, Dashed, or Dotted.               |

#### 4 & 5. Fib Colors (Bull / Bear)

Per-level line colors for bullish zones (section 4) and bearish zones (section 5).

#### 6. Style

| Parameter                | Description                 |
| ------------------------ | --------------------------- |
| **Structure Color**      | Color of swing-point dots.  |
| **Bullish Zone Color**   | Fill color for bull zones.  |
| **Bearish Zone Color**   | Fill color for bear zones.  |
| **Zone Opacity (0-100)** | Transparency of zone fills. |

#### 7. Statistics

| Parameter                     | Description                                                                                             |
| ----------------------------- | ------------------------------------------------------------------------------------------------------- |
| **Show Statistics**           | Enables the trade simulator and the on-chart stats panel. Required for backtesting numbers.             |
| **Show Trade Markers**        | Draws Entry / TP / RTP / SL markers on each simulated trade.                                            |
| **Filter Overlap By Size**    | When two zones overlap, only the larger zone is traded (in its direction).                              |
| **Contracts**                 | Base position size. Used for sim P\&L and as the fixed live size when Dynamic Sizing is off.            |
| **Fib Entry Percent (0-1)**   | Entry level inside the zone (0 = near edge, 1 = far edge). Drives the sim, Fib plots, and live entries. |
| **Pending Order Expire Bars** | Bars a pending entry stays live before cancellation. 0 = never expires.                                 |
| **SL Offset (ticks)**         | Ticks beyond the zone's far edge for the stop loss.                                                     |
| **Stats Font Size**           | Font size of the stats panel.                                                                           |
| **Stats Position**            | Screen corner for the stats panel.                                                                      |
| **Stats Text Color**          | Text color of the stats panel.                                                                          |

#### 8. Time Filter

| Parameter                 | Description                                                                          |
| ------------------------- | ------------------------------------------------------------------------------------ |
| **Use Time Filter**       | Only trade within a daily time window (sim + live).                                  |
| **Start Time / End Time** | Window bounds (set chart to your reference timezone). Window may wrap past midnight. |

#### 9. Debug

| Parameter       | Description                                                           |
| --------------- | --------------------------------------------------------------------- |
| **Debug Mode**  | Prints structure, zone, trade, and order events to the Output window. |
| **Stats Debug** | Prints cumulative stats each time a simulated trade fully resolves.   |

#### 10. Alerts

| Parameter                                             | Description                                                                     |
| ----------------------------------------------------- | ------------------------------------------------------------------------------- |
| **Alert: New Zone**                                   | Audio alert when any new zone forms.                                            |
| **Alert: Fib Entry Reached**                          | Audio alert when price retraces to the Fib Entry level of the most recent zone. |
| **Sound - New Bull Zone / New Bear Zone / Fib Entry** | `.wav` filenames (from the NinjaTrader 8\sounds folder).                        |

#### 11. Auto Trade

| Parameter              | Description                                                                        |
| ---------------------- | ---------------------------------------------------------------------------------- |
| **Show Trade Buttons** | Shows the on-chart L / S auto-trade toggle buttons.                                |
| **Longs Enabled**      | When on, each new bull zone auto-places a live limit entry at the Fib Entry level. |
| **Shorts Enabled**     | Same for bear zones / short entries.                                               |
| **Account**            | Connected account to trade on. Test on a simulation account first.                 |

#### 12. Runner / TP Extension

| Parameter                   | Description                                                                       |
| --------------------------- | --------------------------------------------------------------------------------- |
| **Use Extension TP**        | Single-position mode: target the extension instead of the zone level.             |
| **Extension Percent (0-1)** | Extension beyond the far edge as a fraction of zone range (0.20 = 20%).           |
| **Enable Runner**           | Split into a Base leg (targets zone level) plus a Runner leg (targets extension). |
| **Runner Contracts**        | Contracts for the runner leg (added on top of base).                              |
| **Use Breakeven**           | When the Base TP fills, move the Runner stop to entry +/- 1 tick.                 |

#### 13. ATR Filter

| Parameter            | Description                                                  |
| -------------------- | ------------------------------------------------------------ |
| **Use ATR Filter**   | Only trade when ATR is within the Min/Max band (sim + live). |
| **ATR Period**       | Period for the ATR calculation.                              |
| **Min ATR (points)** | Lowest ATR allowed. 0 = no lower bound.                      |
| **Max ATR (points)** | Highest ATR allowed. 0 = no upper bound.                     |

#### 14. Bias Filter

| Parameter               | Description                                                                                             |
| ----------------------- | ------------------------------------------------------------------------------------------------------- |
| **Use Fib Bias Filter** | Only take the direction whose Fib level is higher (BullFib above BearFib = longs only, and vice versa). |

#### 15. HTF Filter

| Parameter                   | Description                                                                                     |
| --------------------------- | ----------------------------------------------------------------------------------------------- |
| **Use HTF Filter**          | Only allow an entry if current price sits inside the matching last-known higher-timeframe zone. |
| **HTF Period Type / Value** | The higher timeframe (e.g. Minute / 15 = 15-minute).                                            |
| **HTF Structure Length**    | Swing lookback used for HTF zone detection.                                                     |

#### 16. Combo Setup

| Parameter                        | Description                                                                                                                 |
| -------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| **Detect Combo Setup**           | Detects and gold-boxes a "mirror overlap": two consecutive opposite zones where the newer one is larger and shares an edge. |
| **Combo Edge Tolerance (ticks)** | Max tick difference for shared edges to count as aligned.                                                                   |
| **Combo Border Color**           | Outline color of the combo box.                                                                                             |

#### 17. Consecutive Limit

| Parameter                   | Description                                                                                     |
| --------------------------- | ----------------------------------------------------------------------------------------------- |
| **Limit Consecutive Zones** | Stop trading after too many same-direction zones in a row (an opposite zone resets the streak). |
| **Max Consecutive Bear**    | Max bear zones traded in a row before a bull zone must appear. 0 = unlimited.                   |
| **Max Consecutive Bull**    | Same for bull zones. 0 = unlimited.                                                             |

#### 18. EMA Filter

| Parameter             | Description                                                                       |
| --------------------- | --------------------------------------------------------------------------------- |
| **Use EMA Filter**    | Take longs only when entry is above the EMA, shorts only when below (sim + live). |
| **EMA Period**        | Period of the directional EMA.                                                    |
| **Show EMA on Chart** | Plot the EMA line on the price panel.                                             |

#### 19. SL Shortening

| Parameter                  | Description                                                                                                                                 |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| **Long SL Shorten (0-1)**  | Pull the long stop in from the far edge by this fraction of the zone range. 0 = off (stop at far edge); 0.25 = stop at the 75% retracement. |
| **Short SL Shorten (0-1)** | Same for short stops.                                                                                                                       |

#### 20. Hard Close

| Parameter           | Description                                                                                                                                |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| **Use Hard Close**  | At the Hard Close Time, flatten any open position, cancel all working orders, and halt new entries for the rest of the session. Live only. |
| **Hard Close Time** | Chart-time at/after which the force-flatten fires (on the first bar closing at/after this time).                                           |

#### 21. Zone Size Filter

| Parameter                  | Description                                                                          |
| -------------------------- | ------------------------------------------------------------------------------------ |
| **Use Zone Size Filter**   | Only trade when the zone height (in points) is within the Min/Max band (sim + live). |
| **Min Zone Size (points)** | Smallest zone height allowed. 0 = no lower bound.                                    |
| **Max Zone Size (points)** | Largest zone height allowed. 0 = no upper bound.                                     |

#### 22. Dynamic Sizing

| Parameter                 | Description                                                                                                                                            |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Use Dynamic Sizing**    | Size base + runner from risk so the combined loss at the stop is capped at Max Risk. Auto-detects the instrument's point value. Applies to sim + live. |
| **Max Risk ($)**          | Maximum *combined* dollar loss (base + runner) if the trade stops out.                                                                                 |
| **Max Contracts Per Leg** | Hard ceiling on contracts for each leg.                                                                                                                |

**How Dynamic Sizing works:** risk per contract = `|entry − stop| × point value`. Total contracts = `floor(Max Risk / risk per contract)`. When a runner is enabled, the total is split base-heavy on odd counts (e.g. 5 → 3 base / 2 runner). Each leg is capped at *Max Contracts Per Leg*. If even one contract would exceed Max Risk, the trade is skipped entirely. A wide stop therefore yields fewer contracts; a tight stop yields more — keeping dollar risk roughly constant across trades.

***

#### Quick Start

1. Attach to your chart and set **Structure Length** for your timeframe.
2. Turn on **Show Statistics** to backtest a configuration; review the on-chart panel.
3. Add filters (Time, ATR, Zone Size, EMA, HTF) to refine which setups trade.
4. When satisfied, set **Account**, enable **Longs/Shorts**, and (optionally) **Use Dynamic Sizing** with your **Max Risk ($)**.
5. Keep **Use Hard Close** on for an end-of-session safety flatten.

*Always validate on a simulation account before trading live.*


---

# 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://tradersally.gitbook.io/tradinghabitually/docs/tradersally-trade-zones.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.
