If SetStopLoss() isn't doing what you expect, check the order of your calls and the reset first. You need to call it before you submit the entry. And if you change it during a trade, you need to reset it when you're flat. Otherwise, your next trade uses the last value.
| Symptom | What to check |
|---|---|
| The new trade uses the previous stop | Reset the value when the strategy is flat. The guide warns that the last price or offset is used otherwise. |
| The stop doesn't have the initial level you expect | Call SetStopLoss() before the entry: the stop is submitted when the execution arrives. |
SetTrailStop() does nothing | It can't be used with SetStopLoss() for the same position. If both are called, SetStopLoss() takes precedence. |
| The stop is an absurd distance away | Check the calculation mode. In Percent, 1 is 100%, 0.1 is 10% and 0.01 is 1%. |
| There are several stop orders | With partial fills, a strategy can generate one stop per fill or one for all fills. It depends on the stop and target setting. |
| It fails with several series of the same instrument | Submit orders for that instrument only from its first Bars context. |
| The stop disappears | It's canceled automatically if another strategy exit closes the position. |
Moving the stop without carrying over the old value
This example is ours, based on those rules: it sets 20 ticks while flat and, when long, moves the stop to the average entry price once the close is 10 ticks above it.
protected override void OnBarUpdate()
{
if (CurrentBar < 1) return;
if (Position.MarketPosition == MarketPosition.Flat)
{
SetStopLoss(CalculationMode.Ticks, 20); // first, the initial stop
if (Close[0] > Close[1])
EnterLong(); // then, the entry
}
else if (Position.MarketPosition == MarketPosition.Long
&& Close[0] > Position.AveragePrice + 10 * TickSize)
{
SetStopLoss(CalculationMode.Price, Position.AveragePrice);
}
}
Details worth knowing
- For a static stop, the guide suggests calling the method from
OnStateChange(). It can't be called duringState.SetDefaults: useState.Configure. - To change it while a position is open, call it from
OnBarUpdate(). CalculationMode.Currencyautomatically setsStopTargetHandlingto ByStrategyPosition.- The stop is a stop-market order. If there's also a target, they're submitted as OCO: when one fills, the other is canceled.
- With
isSimulatedStopset to true, the stop is simulated locally and submitted as a market order once triggered.
On a prop firm account, verify your stop before you rely on it. An old value or the wrong mode changes your risk per trade. Work out how many contracts fit your drawdown and test the strategy in simulation.
If NinjaTrader ignores an order, see the internal order handling rules. If no orders go out, see the 11 causes of a strategy not placing orders.
Want someone to review it? We check the stops and exits in your NinjaScript strategy.
Review from $90 Analyze NinjaTrader with AISource
Keep reading
Free: The Other Half Workbook. Nine templates for trading with a cool head: your one-page plan, the pre-session checklist, the twelve-patterns test, your size and the bill for your mistakes.
Get the free workbookGet ready for 2027: the Trader Planner. Each day's US releases in New York time, your pre-market routine and a log for every session.
Paperback on Amazon, $16.99 Get the PDF, $9Educational content based on the official NinjaTrader documentation. Not investment advice. Test any change on a simulation account before using it live.