Your internet drops for forty seconds in the middle of the New York open. The router blinks, the connection comes back, and NinjaTrader reconnects on its own. Now look at your strategy. Is it still enabled? Does it still think it is long? Did it place anything while you were gone? The answer depends on one setting most traders never open: connection loss handling.
Every NinjaTrader 8 strategy has it. It decides what the strategy does when the platform loses its connection to the data feed or the order route, and what happens when that connection returns. This guide covers the three choices, the timer that decides when they kick in, the restart limits that sit behind them, and how we think about the setting on a prop firm account where a short outage can turn into a broken rule.
What Connection Loss Handling Controls
NinjaTrader's ConnectionLossHandling documentation defines it in one line: it "sets the manner in which your strategy will behave when a connection loss is detected." It is a strategy property, so each strategy carries its own value. The same choices also appear in the platform's strategy settings under a group called On connection loss.
There are three values.
| Value | What the Help Guide says | What you find after the connection returns |
|---|---|---|
KeepRunning |
Keeps the strategy running and resumes as if no disconnect occurred | Strategy still enabled, carrying on from where it was |
Recalculate |
Attempts to recalculate the strategy position when a connection is reestablished | Strategy restarted and its position worked out again, if the disconnect was long enough to stop it |
StopStrategy |
Stops the strategy when disconnected for more than the disconnect delay; no action when the connection returns | Strategy stopped, waiting for you |
The default, per the same page, is ConnectionLossHandling.Recalculate. If nobody changed the setting, that is what your strategy does. One small trap: the Help Guide's own code sample sets KeepRunning in State.SetDefaults. A developer who copied that sample into a strategy changed the default without meaning to, so check the value in the properties window rather than assuming.
The Timer: Disconnect Delay Seconds
None of the three options reacts to a blip. A second property, DisconnectDelaySeconds, "determines the amount of time a disconnect would have to last before connection loss handling takes action." The default value is 10.
So with the defaults, a five second hiccup does nothing. The strategy keeps running whatever its handling mode says, because the disconnect never lasted long enough to count. A thirty second outage is a different story. That one crosses the delay, and the handling mode decides what happens next.
This is the first lever most people should look at. If your connection has short, frequent drops, a delay of 10 seconds may be shorter than a normal hiccup on your line, and the strategy will keep reacting to outages that do not matter. Raising the delay makes the strategy more patient. Lowering it makes the strategy react faster to a real outage. There is no right number for everyone. It depends on how your connection fails.
Keep Running
Here is the Help Guide's description of the first value:
"Keeps the strategy running. When the connection is reestablished the strategy will resume as if no disconnect occurred." (NinjaTrader 8 Help Guide, ConnectionLossHandling)
The strategy settings page adds that it logs the disconnection. That is all it does. The strategy stays enabled through the outage and picks up again when data flows.
The phrase "as if no disconnect occurred" is the part to think about. While the connection was down, the strategy did not see those prices. Our reading is that any signal it would have acted on during the gap is simply missed, and the strategy carries on with whatever it believed before the drop. If the market moved hard while you were offline, the strategy's view of the world and your account can drift apart.
Keep Running suits a strategy that would rather miss a trade than restart, and an operator who watches the account and can step in. It is the least disruptive choice for short outages. It is also the one that gives you the least information that anything went wrong, apart from a line in the log.
Recalculate
Recalculate is the default, and it is the most misunderstood of the three. The Help Guide says strategies "will attempt to recalculate its strategy position when a connection is reestablished." The key detail is a note on the same page: recalculations will only occur if the strategy was stopped based on a set of conditions. If the connection comes back before any of those conditions are met, the strategy keeps running and nothing is recalculated.
The page lists three conditions that stop the strategy:
- The data feed is disconnected for longer than the disconnect delay.
- The order feed is disconnected and the strategy tries to act on an order while it is down. The order route can drop without the data feed dropping, and a strategy that tries to submit, change or cancel an order during that window is stopped.
- Both feeds are disconnected for longer than the disconnect delay.
Once the strategy has been stopped under one of those conditions and the connection returns, NinjaTrader tries to bring it back and work out its position again. The strategy settings page words the trigger slightly differently. It says the strategy tries to recalculate when a connection is restored and held for more than 10 seconds. With the default delay of 10, the two pages describe the same thing. If you change the delay, treat the property page as the more specific description and test the behavior yourself.
In plain terms, Recalculate behaves like Keep Running for short drops and like a controlled restart for long ones. That is why it is the default. It is also why the restart rules below matter.
Stop Strategy
The third value is the bluntest. The Help Guide says it automatically stops the strategy when disconnected for more than the disconnect delay, and "no action will be taken when a connection is reestablished." The strategy settings page adds that NinjaTrader logs the disconnection.
When the connection returns, the strategy stays stopped until you deal with it. Nothing restarts on its own. You decide whether to re-enable it, and how.
Before choosing Stop Strategy, check what a stopped strategy leaves behind. NinjaTrader's strategy settings include Cancel entry orders when a strategy is disabled and Cancel exit orders when a strategy is disabled. If either is off, orders can stay working at the broker after the strategy stops. Also remember that while the connection is down, NinjaTrader may not be able to cancel anything at all. Any stop or target already resting at the broker is what protects an open position during that window. We covered how long those resting orders live in our guide to NinjaTrader 8 time in force.
The Restart Limits Behind Recalculate
A bad connection rarely drops once. It drops, comes back, drops again. Two more properties stop a strategy from restarting forever in that loop.
- NumberRestartAttempts sets the maximum number of restart attempts allowed within a time span when the strategy experiences a connection loss. The default value is 4.
- RestartsWithinMinutes sets the length of that time span in minutes. The default value is 5.
The Help Guide explains the rule: the strategy restarts only when there have been fewer restart attempts than the limit within the last time span. If the attempts exceed the limit inside that window, the strategy is stopped and no further restarts are attempted.
Here is a hypothetical with the defaults. Your connection flaps five times in four minutes, each outage long enough to cross the 10 second delay. The first four drops trigger restarts. The fifth one lands inside the same five minute window, the limit is used up, and the strategy stays stopped. When the line settles down, you find a strategy that is off, even though Recalculate was selected. That surprises a lot of people who thought the default meant "always recovers."
A stopped strategy is not a flat account
Whichever mode you pick, a strategy that ends up stopped tells you nothing about the account by itself. A position can still be open at the broker, and orders can still be working, depending on your cancel-on-disable settings and what was resting when the connection dropped. After any outage, compare the strategy's position with the account position in the Control Center before you re-enable anything.
Re-enabling After an Outage
When a strategy is stopped, by Stop Strategy or by running out of restarts, you bring it back by enabling it again. What it does with an existing account position at that moment depends on its start behavior setting, which is a separate decision from connection loss handling. We walked through the options in NinjaTrader 8 start behavior explained, and it is worth reading the two articles together. Connection loss handling decides whether the strategy stops. Start behavior decides how it reconciles when it starts again.
If a strategy keeps stopping and you cannot see why, the cause is not always the connection. Order rejections and other errors can stop a strategy too. Our checklist for why a NinjaTrader 8 strategy stopped trading covers the other common causes, and the Log tab in the Control Center usually names the one you hit.
Want a strategy that is ready to run?
NQ Ultra is a ready-to-run NinjaTrader 8 strategy for NQ futures, built for traders running prop firm accounts. Start from a finished system instead of debugging platform settings.
Get NQ Ultra on WhopWhich Setting on a Prop Firm Account?
What follows is our view, not NinjaTrader's. If the strategy you run came with setup instructions, follow the vendor's recommendation first, because the strategy was built and tested around it.
Fix the connection before you tune the setting. No handling mode makes a bad line safe. A wired connection, a machine that does not sleep, and a platform that is not fighting other software for resources do more than any of the three options. If outages are frequent, that is the problem to solve. We looked at hosted machines in do you need a VPS to run a NinjaTrader 8 algo.
Recalculate is a sensible default for most intraday strategies. It rides out short drops and restarts after long ones. Know the restart limit, and know that after a stormy few minutes you can still come back to a stopped strategy.
Stop Strategy suits traders who want a human in the loop. On an account with a daily loss limit or a trailing drawdown, some traders would rather the strategy stop and wait than restart into a market that moved while they were offline. The cost is that you must be around to restart it, and any open position is protected only by what is already resting at the broker.
Keep Running asks the most of you. It is the least disruptive, and also the least likely to tell you something went wrong. If you use it, watch the log and the account after any outage, because the strategy will not stop to get your attention.
Check your firm's rules on outages. Prop firms generally treat the account as your responsibility, whether or not your connection held. Read your firm's current rules page yourself rather than relying on a summary, since prop firm rules change often.
A Short Connection Loss Checklist
- Read the current value. Open the strategy's properties and find the connection loss handling setting. Do not assume it is the default.
- Pick a disconnect delay that fits your line. The default of 10 seconds is a starting point. Match it to how long your normal hiccups last.
- Know your restart limits. With the defaults, four restarts in five minutes is the ceiling. More drops than that and the strategy stays stopped.
- Check the two cancel-on-disable settings. Decide on purpose what a stopped strategy should leave working at the broker.
- Make sure protective orders rest at the broker. During an outage, they are the only thing guarding an open position.
- Test it in simulation. Disconnect your network on a sim account with the strategy running, for longer and shorter than the delay, and watch what each mode does. Do this before you find out live.
- After every outage, compare positions. Strategy position, account position, working orders. Re-enable only when they agree.
Connection loss handling is easy to ignore because most days the connection holds. It matters on the day it does not. Know which of the three modes your strategy uses, how long a drop has to last before it acts, and how many restarts it gets, and you will not be guessing about the state of your account the next time the router blinks.