Daily Loss Limit Kill Switch for NinjaTrader 8
Set a profit target and a loss limit. When either is hit it disables your other strategies, cancels every order, flattens every position, then switches itself off.
You will also get the Monday macro read. Unsubscribe in one click. How we handle it.
What it does
- It stops the automation, not just the positions — Disables every other strategy on the account before it flattens. Flattening alone does not stop a running strategy — it re-enters moments later, and you would never know.
- Both sides, independently — A profit target and a loss limit, either of which trips it. Set one to zero to switch that side off and run a loss-only or profit-only guard.
- The whole account, not one chart — Cancels orders and flattens positions across every instrument the account holds, not only the one it happens to be running on.
- Counts open profit if you want — Include unrealized P&L in the total, or measure on closed trades only.
- Then it stops itself — Once fired it disables itself, so it cannot re-arm and start flattening a fresh position you opened deliberately.
The rule you already have
Most traders have a number. Down this much and I stop for the day. Almost nobody honours it, because the moment it arrives is the exact moment you are least able to.
A limit that depends on your judgement at your worst is not a limit. It is an intention.
What happens when it fires
Three things, in this order, and the order is deliberate:
- Every other strategy on the account is disabled.
- All orders are cancelled and every position flattened, across all instruments the account holds.
- It disables itself.
Step one is the part most kill switches get wrong, including the first version of this one.
Why flattening is not enough
Flattening closes positions. It does not stop automation. A strategy that is still enabled keeps running, and on its next signal it opens a fresh position — now unsupervised, because the tool meant to protect you has already fired.
That is worse than having no kill switch at all, because you believe you are protected.
So this disables the strategies first, then flattens. The gap where something could re-enter mid-flatten is closed rather than left open.
Both directions
The loss limit is the one that matters, but the profit target is not decoration. Giving back a good day is its own failure mode, and it is easier to argue yourself out of stopping when you are ahead.
Either threshold trips it. Set one to zero if you only want the other.
Test it on simulation first
This cancels orders, closes positions and disables strategies on a live account. Test it on sim: set a small loss limit, run another strategy alongside it, and watch both the flatten and the shutdown happen with your own eyes.
It will not make you money. It exists to stop a bad day becoming a worse one.
Install
- Download the zip. Do not unzip it — NinjaTrader imports the zip as it is.
- In NinjaTrader: Tools → Import → NinjaScript Add-On…, then pick the zip.
- Restart NinjaTrader.
- It is a strategy, not an indicator: Control Center → Strategies tab, or apply it to a chart.
- Set your account, profit target and loss limit, then enable it.
Settings
| Setting | What it changes |
|---|---|
| Account | Which account to watch and flatten. |
| Profit target | Stop once P&L reaches this. 0 to ignore profit. |
| Loss limit | Stop once P&L falls this far into loss. Enter a positive number — 300 means −300. 0 to ignore loss. |
| Include unrealized in Total PnL? | Count open profit as well as closed. |
| PnL currency | Currency the thresholds are quoted in. |
| Disable all strategies | Also stop other strategies when it fires. On by default. |