preflight
preflight.ps1 is a standalone PowerShell script for morning go/no-go checks before enabling the strategy. It does not import or reference any NinjaTrader assembly.
PowerShell was chosen because this tool is an operator-side environment check: process count, file writability, deployed-source hash verification, and disk-space checks are all native PowerShell tasks and do not need any .NET solution changes.
What It Checks
The script prints PASS or FAIL for:
- Exactly one
NinjaTraderprocess running - Log directory writable and no current-day
session_YYYYMMDD_*.logalready present - Most recent
settings_Simple_ORB_NT8_*.txtexport has:TestMode=FalseEnableKillSwitch=TrueEnableVerboseLogging=TrueEnableFileLogging=TrueMinTradeGrade=5MaxDailyTrades=1
- Most recent settings export
AccountandInstrumentmatch the expected arguments - Deployed
NT8StrategyBase.cshash matches the repo copy - Free disk space in the log directory drive is greater than
1 GB
Every failure prints a specific remedy. The script exits 0 only when every check passes. Any failure returns exit code 1.
Usage
Run with the expected account and instrument:
powershell -ExecutionPolicy Bypass -File .\tools\preflight\preflight.ps1 `
-ExpectAccount "SimSimple ORB" `
-ExpectInstrument "NQ SEP26"
Override the log directory if needed:
powershell -ExecutionPolicy Bypass -File .\tools\preflight\preflight.ps1 `
-ExpectAccount "SimSimple ORB" `
-ExpectInstrument "NQ SEP26" `
-LogDirectory "C:\Users\billy\Documents\NinjaTrader 8\log\nt8-sdk"
Override the repo/deployed file paths for validation or alternate installs:
powershell -ExecutionPolicy Bypass -File .\tools\preflight\preflight.ps1 `
-ExpectAccount "SimSimple ORB" `
-ExpectInstrument "NQ SEP26" `
-RepoStrategyBasePath "C:\dev\nt8-sdk\src\NT8.Adapters\Strategies\NT8StrategyBase.cs" `
-DeployedStrategyBasePath "C:\Users\billy\Documents\NinjaTrader 8\bin\Custom\Strategies\NT8StrategyBase.cs"
Defaults
LogDirectory:%USERPROFILE%\Documents\NinjaTrader 8\log\nt8-sdkRepoStrategyBasePath:src\NT8.Adapters\Strategies\NT8StrategyBase.csrelative to the repo rootDeployedStrategyBasePath:%USERPROFILE%\Documents\NinjaTrader 8\bin\Custom\Strategies\NT8StrategyBase.cs
Notes
- The script is read-only except for a temporary write/delete probe file in the log directory used to verify writability.
- The settings check uses the most recently modified
settings_Simple_ORB_NT8_*.txtfile in the log directory. - The hash check compares SHA-256 of the repo and deployed
NT8StrategyBase.csfiles.
Gate 3 Freeze Mode
Freeze mode captures Gate Run #3 provenance under docs/gate-runs/gate3/freeze_YYYYMMDD_HHMMSS and writes docs/gate-runs/gate3/baseline.json plus DEC-GATE3-CONFIG.md when all freeze gates pass.
powershell -ExecutionPolicy Bypass -File .\tools\preflight\preflight.ps1 `
-ExpectAccount "SimSimple ORB" `
-ExpectInstrument "NQ SEP26" `
--freeze
PowerShell also accepts -Freeze.
Freeze captures:
- current settings export
ConfigHashandCodeVersion- git commit SHA
git status --porcelain, which must be clean- full test suite result from
dotnet test NT8-SDK.sln --configuration Release --verbosity minimal - SHA-256 hash of every deployed
.csfile in the NT8Strategiesfolder tools/configdiffreport for the preceding 3 settings exports
If the worktree is dirty, freeze exits non-zero and writes a failed capture folder with git-status-porcelain.txt and FREEZE_FAILED.txt. It does not create or replace baseline.json.
Gate 3 Verify Mode
Verify mode repeats the capture and compares significant fields against docs/gate-runs/gate3/baseline.json. It exits non-zero on any difference.
powershell -ExecutionPolicy Bypass -File .\tools\preflight\preflight.ps1 `
-ExpectAccount "SimSimple ORB" `
-ExpectInstrument "NQ SEP26" `
--verify
PowerShell also accepts -Verify.
Verify compares:
- settings values
ConfigHashCodeVersion- git SHA
- clean git status
- full-suite pass/fail status
- configdiff pass/fail status
- deployed strategy source hashes