← All projects

NinjaTrader 8 SuperTrend Multi-Target Strategy

A three-leg NT8 futures strategy built on a SuperTrend signal, with adaptive ATR targets, trailing runners, equity-based sizing, margin-level position trimming and an optional breakout-structure filter.

Client
Futures trader
Year
2025
Category
Trading Systems
Stack
  • NinjaTrader 8
  • C#
  • NinjaScript
  • Pine Script

The problem

The client traded a SuperTrend-and-ribbon signal by hand and wanted it automated in NinjaTrader 8. He wanted three scale-out targets, several stop styles and sizing that reacts to account equity. The work ran over about a dozen revisions as he tested it.

What I built

  • Signal indicator: SuperTrend with a trend-ribbon cloud and a moving-average confirmation. A “strong signal” tier lets the strategy trade only the higher-conviction setups.
  • Three-leg entries: every signal opens three named entries, and each leg carries its own stop and target (PerEntryExecution). The strategy checks at start-up that the three leg sizes add up to the contract count.
  • Target modes: fixed points, ATR multiples or R-multiples of the stop distance. An adaptive mode switches the ATR multiplier set based on the volatility regime (ATR as a percentage of price).
  • Stops: current-bar ATR, a fractal hybrid or a custom swing, plus an offset. A max-stop-distance guard skips trades whose stop would be too wide.
  • Runner management: the third leg can hold a fixed target or trail on an EMA or ATR. The trail only starts after the first two legs fill, and it only moves in the trade’s favour. Breakeven is applied after the second target.
  • Sizing: equity-based position size, a multiplier step after losses that resets on a win, and a max-consecutive-losses block.
  • Breakout-structure filter: ported from a Pine Script v6 indicator. It tracks swing highs and lows, fair value gaps and their mitigation, and only allows entries after a valid structure break within a set number of bars.

Details

  • Margin protection: when the account’s margin level drops below a threshold, the strategy trims 25% of each position’s original size, oldest position first, in round-robin, up to three trims per position.
  • Fill inference: target fills are matched to legs from their fill order in OnOrderUpdate, so breakeven and the trail start at the right moment.
  • Signal reversal: an opposite signal closes the open position and re-evaluates the new entry on the same bar.
  • Bar colours: signal candle colouring is disabled when the strategy hosts the indicator, so it doesn’t clash with a copy of the indicator already on the chart.