# CS0246 — Type or namespace not found
## Pattern
`error CS0246: The type or namespace name 'X' could not be found (are you missing a using directive or an assembly reference?)`
## Root Causes (ordered by likelihood)
1. Missing `using` directive for the namespace that declares the type
2. Namespace mismatch — type placed under `Indicators` namespace but referenced from `Strategies` (or vice versa)
3. Type defined in a file that failed to compile or was excluded from the NT8 build
4. SharpDX type used without the correct `SharpDX` or `SharpDX.Direct2D1` assembly reference
## Fix Strategies
### Strategy 1: Add missing `using` directive
- **Detect**: The type name in the error matches a known NT8, .NET, or SharpDX type. The file's `using` block at the top does not include the namespace that owns it.
- **Lookup**: Use the NT8 Type→Namespace Map below to find the correct namespace. For .NET BCL types, check the MSDN docs for the type's namespace.
- **Fix**: Add the missing `using` directive at the top of the file, after any existing `using` statements.
- **Verify**: The type resolves without error after the `using` is added.
```csharp
// Add the appropriate using at the top of the file
using NinjaTrader.NinjaScript.Indicators;
using System.Windows.Media;
using SharpDX;
using SharpDX.Direct2D1;
```
### Strategy 2: Namespace mismatch between Indicators and Strategies
- **Detect**: The error references a DEEP6 type (e.g., `DEEP6Footprint`, `DataBridgeIndicator`) from inside a Strategy file. The Strategy's `using` block references `NinjaTrader.NinjaScript.Indicators.DEEP6` but the type is declared under a different namespace, or vice versa.
- **Lookup**: Check the `namespace` declaration at the top of the file that defines the type. Confirm it matches what the consuming file expects.
- **Fix**: Either add the correct `using` in the consuming file, or qualify the type with its full namespace inline.
- **Verify**: The full namespace path resolves and the type is accessible.
```csharp
// Option A: add using in the consuming file
using NinjaTrader.NinjaScript.Indicators.DEEP6;
// Option B: qualify inline
NinjaTrader.NinjaScript.Indicators.DEEP6.DEEP6Footprint fp = ...;
```
### Strategy 3: Type in uncompiled or excluded file
- **Detect**: The type is defined in a DEEP6 `.cs` file that is either shelved, not deployed to NT8, or failed to compile in a prior build. The error appears in a file that depends on it.
- **Lookup**: Check the DEEP6 File Compile Status table in `nt8-fix/knowledge.md`. Confirm the defining file is deployed to `C:\Users\Tea\Documents\NinjaTrader 8\bin\Custom\` and compiled successfully (DLL mtime updated).
- **Fix**: Deploy the missing file using `nt8-deploy.ps1`, then recompile. If the file is shelved intentionally (e.g., `FootprintBar.cs`), remove the reference from the consuming file.
- **Verify**: The defining file compiles first, then the consuming file resolves the type.
### Strategy 4: SharpDX assembly not referenced
- **Detect**: The type name starts with `SharpDX.` or is a known SharpDX type (`RenderTarget`, `Brush`, `TextFormat`, `Factory`, `Color4`, `RectangleF`, etc.) and the error appears in an indicator that uses `OnRender`.
- **Lookup**: NT8 ships SharpDX assemblies. They are available automatically in NT8's compile context but require explicit `using` directives.
- **Fix**: Add `using SharpDX;` and/or `using SharpDX.Direct2D1;` at the top of the file. Do not add assembly references manually — NT8 manages them.
- **Verify**: The SharpDX type resolves after the `using` is added.
## NT8-Specific Type→Namespace Map
| Type | Namespace |
|------|-----------|
| `Indicator` (base class) | `NinjaTrader.NinjaScript.Indicators` |
| `Strategy` (base class) | `NinjaTrader.NinjaScript.Strategies` |
| `AddOnBase` | `NinjaTrader.NinjaScript.AddOns` |
| `DrawingTool` | `NinjaTrader.NinjaScript.DrawingTools` |
| `MarketAnalyzerColumn` | `NinjaTrader.NinjaScript.MarketAnalyzerColumns` |
| `Brush`, `SolidColorBrush`, `Color` | `System.Windows.Media` |
| `RenderTarget`, `Factory`, `Brush` (SharpDX) | `SharpDX.Direct2D1` |
| `Color4`, `RectangleF`, `Vector2` | `SharpDX` |
| `TextFormat`, `TextLayout` | `SharpDX.DirectWrite` |
| `Series<T>` | `NinjaTrader.NinjaScript` |
| `ISeries<T>` | `NinjaTrader.NinjaScript` |
| `NinjaScriptBase` | `NinjaTrader.NinjaScript` |
| `Instrument` | `NinjaTrader.Data` |
| `MarketPosition` | `NinjaTrader.NinjaScript.Strategies` |
| `Order` | `NinjaTrader.Cbi` |
| `Account` | `NinjaTrader.Cbi` |
| `ChartControl` | `NinjaTrader.Gui.Chart` |
| `ChartPanel` | `NinjaTrader.Gui.Chart` |
| `DEEP6Footprint` | `NinjaTrader.NinjaScript.Indicators.DEEP6` |
| `DataBridgeIndicator` | `NinjaTrader.NinjaScript.Indicators.DEEP6` |
| `CaptureHarness` | `NinjaTrader.NinjaScript.Indicators.DEEP6` |
| `DEEP6GexLevels` | `NinjaTrader.NinjaScript.Indicators.DEEP6` |
| `DEEP6Strategy` | `NinjaTrader.NinjaScript.Strategies.DEEP6` |
## Example Fix
```diff
using System;
using System.Collections.Generic;
using NinjaTrader.NinjaScript;
+ using NinjaTrader.NinjaScript.Indicators;
+ using System.Windows.Media;
+ using SharpDX;
+ using SharpDX.Direct2D1;
namespace NinjaTrader.NinjaScript.Indicators.DEEP6
{
public class DEEP6Footprint : Indicator
{
- private SolidColorBrush _bidBrush; // CS0246: SolidColorBrush not found
+ private SolidColorBrush _bidBrush; // Resolved after adding System.Windows.Media
}
}
```