# Quick Start: Deploy to NinjaTrader 8

**Status:** Phases A, B, C Complete ✅  
**Ready For:** Immediate NT8 Deployment  
**Estimated Time:** 30 minutes to first strategy running

---

## 🚀 5-Step Quick Start

### Step 1: Deploy to NT8 (2 minutes)

Open PowerShell and run:

```powershell
cd C:\dev\nt8-sdk
.\deployment\Deploy-To-NT8.ps1
```

**What This Does:**
- Builds SDK in Release mode
- Runs all 319 tests (should pass)
- Copies NT8.Core.dll to NinjaTrader
- Copies 3 strategy files to NT8
- Verifies deployment

**Expected Output:**
```
[1/6] Building SDK...
  ✓ Build succeeded

[2/6] Running tests...
  ✓ All tests passed (319 tests)

[3/6] Copying SDK DLLs...
  ✓ Copied NT8.Core.dll
  ✓ Copied NT8.Core.pdb

[4/6] Copying dependencies...
  ✓ Copied dependencies

[5/6] Copying strategy files...
  ✓ Copied NT8StrategyBase.cs
  ✓ Copied SimpleORBNT8.cs
  ✓ Copied MinimalTestStrategy.cs

[6/6] Verifying deployment...
  ✓ Deployment verified

✓ Deployment succeeded!
```

---

### Step 2: Compile in NinjaTrader 8 (2 minutes)

1. **Open NinjaTrader 8**

2. **Open NinjaScript Editor:**
   - Press `F5` OR
   - Tools → NinjaScript Editor

3. **Compile All:**
   - Press `F5` OR
   - Compile → Compile All

4. **Verify Success:**
   - Look for "Compilation successful" message
   - Check Output window for zero errors

**If Compilation Fails:**
- Check NinjaTrader version (need 8.0.20.1+)
- Verify .NET Framework 4.8 installed
- Review error messages in Output window
- See troubleshooting section below

---

### Step 3: Test MinimalTestStrategy (5 minutes)

**Purpose:** Verify basic NT8 integration works

1. **Create New Strategy Instance:**
   - File → New → Strategy
   - OR Right-click chart → Strategies

2. **Select Strategy:**
   - Find "Minimal Test" in dropdown
   - Click it

3. **Configure:**
   - Instrument: ES 03-26 (or current contract)
   - Data Series: 5 Minute
   - Calculate: OnBarClose (default)
   - From: 1 hour ago
   - To: Now

4. **Apply:**
   - Click "Apply" button
   - Then click "OK"

5. **Monitor Output Window:**
   - View → Output
   - Look for:
     ```
     [MinimalTest] Strategy initialized
     [MinimalTest] Bar 10: 09:35:00 O=4200.00 H=4205.00 L=4198.00 C=4203.00 V=10000
     [MinimalTest] Bar 20: 09:45:00 O=4203.00 H=4208.00 L=4201.00 C=4206.00 V=12000
     ```

6. **Let Run for 10 minutes**
   - Should see periodic bar logs
   - No errors in Log tab

**Success:** If you see bars logging, basic integration is working! ✅

---

### Step 4: Test SimpleORBNT8 - Historical Data (10 minutes)

**Purpose:** Verify full SDK integration works

1. **Load Historical Data:**
   - Create new ES 5-minute chart
   - Load 2 days of data (Data Series → Days to load: 2)

2. **Add SimpleORBNT8 Strategy:**
   - Right-click chart → Strategies
   - Add "Simple ORB NT8"

3. **Configure Parameters:**
   ```
   Strategy Settings:
   - Opening Range Minutes: 30
   - Std Dev Multiplier: 1.0
   
   Risk Settings:
   - Stop Ticks: 8
   - Target Ticks: 16
   - Daily Loss Limit: 1000
   - Max Trade Risk: 200
   - Max Positions: 1
   
   Sizing Settings:
   - Risk Per Trade: 100
   - Min Contracts: 1
   - Max Contracts: 3
   
   SDK Settings:
   - Enable SDK: ☑ (checked)
   ```

4. **Enable Strategy:**
   - Check "Enabled" box
   - Click "OK"

5. **Watch Output Window:**
   ```
   [SDK] Simple ORB NT8 initialized successfully
   [SDK] SDK initialization complete
   [SDK] Submitting: Buy 1 ES
   [SDK] Filled: SDK_ES_... @ 4203.50
   ```

6. **Verify on Chart:**
   - Should see entry markers
   - Stop loss lines
   - Target lines
   - Position indicators

**Success:** If SDK initializes and strategy generates trades, full integration works! ✅

---

### Step 5: Test SimpleORBNT8 - Simulation Account (10+ minutes)

**Purpose:** Verify live order submission works

1. **Connect to Simulation:**
   - Tools → Connections
   - Select "Kinetick - End Of Day (free)" OR your data provider
   - Click "Connect"
   - Verify "Connected" status

2. **Create New Chart:**
   - File → New → Chart
   - Instrument: ES (current contract)
   - Type: 5 Minute

3. **Add SimpleORBNT8:**
   - Right-click chart → Strategies
   - Add "Simple ORB NT8"
   - Use same parameters as Step 4

4. **Enable for Realtime:**
   - Check "Enabled"
   - Calculate: On bar close
   - Click "OK"

5. **Monitor Live:**
   - Watch for opening range calculation (first 30 minutes)
   - Look for trade signals
   - Verify orders appear in "Strategies" tab
   - Check "Orders" tab for fills

6. **Validate:**
   - [ ] SDK initializes without errors
   - [ ] Opening range calculates correctly
   - [ ] Strategy generates intents when appropriate
   - [ ] Orders submit to simulation account
   - [ ] Stops and targets placed correctly
   - [ ] No exceptions in Output window

**Success:** If orders submit and fill in simulation, ready for extended testing! ✅

---

## ✅ Validation Checklist

After completing all 5 steps:

- [ ] Deploy-To-NT8.ps1 ran successfully
- [ ] NT8 compiled with zero errors
- [ ] MinimalTestStrategy ran and logged bars
- [ ] SimpleORBNT8 initialized SDK components
- [ ] SimpleORBNT8 generated trading intents
- [ ] SimpleORBNT8 submitted orders to simulation
- [ ] Orders filled correctly
- [ ] Stops/targets placed correctly
- [ ] No crashes or exceptions

**If all checked:** Ready for extended simulation testing! 🎉

---

## 🚨 Troubleshooting

### Issue: Deployment Script Fails

**Error:** "Build failed"
```powershell
# Try manual build
cd C:\dev\nt8-sdk
dotnet build --configuration Release

# Check for errors
# Fix any compilation issues
# Re-run Deploy-To-NT8.ps1
```

**Error:** "Tests failed"
```powershell
# Run tests separately to see failures
dotnet test --configuration Release

# Review failed tests
# Fix issues
# Re-run deployment
```

**Error:** "NT8 Custom directory not found"
- Verify NinjaTrader 8 is installed
- Check path: `%USERPROFILE%\Documents\NinjaTrader 8\bin\Custom`
- If different location, edit `Deploy-To-NT8.ps1` $nt8Custom variable

---

### Issue: NT8 Compilation Errors

**Error:** "Could not load file or assembly 'NT8.Core'"
- Solution: Re-run `Deploy-To-NT8.ps1`
- Verify NT8.Core.dll exists in `Documents\NinjaTrader 8\bin\Custom\`

**Error:** "Type or namespace 'NinjaTrader' could not be found"
- Solution: NT8 version too old, need 8.0.20.1+
- Update NinjaTrader 8
- Try compilation again

**Error:** "The type or namespace name 'IStrategy' could not be found"
- Solution: NT8.Core.dll not found by compiler
- Close NT8 completely
- Re-run `Deploy-To-NT8.ps1`
- Re-open NT8 and compile

---

### Issue: Strategy Won't Enable

**Error:** "Strategy initialization failed"
- Check Output window for specific error
- Common causes:
  - Invalid parameters (e.g., StopTicks = 0)
  - Insufficient data (need BarsRequiredToTrade)
  - Account issues (simulation not connected)

**Error:** "SDK initialization failed"
- Check Log tab for exception details
- Verify NT8.Core.dll is correct version
- Try MinimalTestStrategy first (no SDK dependencies)

---

### Issue: No Trade Signals Generated

**Possible Causes:**
1. **Opening range not complete yet**
   - Solution: Wait 30 minutes after session start

2. **No breakout conditions met**
   - Solution: Normal, strategy is selective

3. **Risk manager rejecting all trades**
   - Check Output window for rejection messages
   - Verify daily loss limit not already hit
   - Check position limits

4. **Wrong session time**
   - Verify strategy running during RTH (9:30-16:00 ET)
   - Check time zone settings

---

## 📞 Getting Help

**If Issues Persist:**

1. **Check Log Files:**
   - `Documents\NinjaTrader 8\log\[date]\Log.txt`
   - Look for exceptions or errors

2. **Review Output Window:**
   - Copy error messages
   - Note exact sequence of events

3. **Verify Deployment:**
   ```powershell
   .\deployment\Verify-Deployment.ps1 -Detailed
   ```

4. **Check Test Results:**
   ```powershell
   dotnet test NT8-SDK.sln --configuration Release
   ```

5. **Consult Documentation:**
   - `PHASES_ABC_COMPLETION_REPORT.md`
   - `POST_INTEGRATION_ROADMAP.md`
   - `TROUBLESHOOTING.md` (if exists)

---

## 🎯 Next Steps After Quick Start

**If All Steps Successful:**

Proceed to extended testing per `POST_INTEGRATION_ROADMAP.md`:

1. **Week 1-2:** Extended simulation validation
   - Run SimpleORBNT8 continuously for 1 week
   - Monitor for stability, errors, edge cases
   - Collect performance data

2. **Week 3-4:** Production hardening
   - Add monitoring/alerting
   - Implement configuration management
   - Add error recovery mechanisms

3. **Week 5:** Production readiness validation
   - Complete pre-production checklist
   - Final testing and validation

4. **Week 6-9:** Gradual production rollout
   - Start with micro positions
   - Scale gradually
   - Build confidence with real money

**Full details in:** `POST_INTEGRATION_ROADMAP.md`

---

## ✅ Success!

**If you've completed all 5 steps successfully:**

You now have:
- ✅ Complete NT8 integration working
- ✅ Strategy running in NinjaTrader 8
- ✅ Orders submitting to simulation
- ✅ All SDK components operational
- ✅ Ready for extended testing

**Congratulations! The hard part is done.** 🎉

**Next:** Focus on validation, monitoring, and gradual deployment to build confidence for production trading.

---

**Time to First Strategy Running:** 30 minutes ⚡  
**Project Completion:** 95% ✅  
**Ready For:** Extended Simulation Testing 🚀
