Skip to main content
Black Friday25% off your first year of WiSE, SweepScope or All Access on an annual plan. Through December 1.See the plans
All posts
Blog

NinjaTrader 8 Swing Indicator: What Strength Really Does

The built-in Swing indicator has one setting and four behaviours the properties window never mentions, including a confirmation delay and a Calculate mode you cannot change. Read from the shipped NinjaScript.

Wizdough7 min read

Before you buy anything that marks structure on a chart, find out what NinjaTrader 8 already gives you. The Swing indicator ships with the platform, costs nothing, and marks swing highs and lows with two dotted lines. Plenty of traders apply it, set Strength to a number that looks right, and never think about it again.

The properties window shows one setting. The shipped NinjaScript, which sits in Documents\NinjaTrader 8\bin\Custom\Indicators\@Swing.cs on every install, shows several behaviours the window does not. Some of them decide whether you can use the indicator for entries at all.

The one setting, and the number behind it

Swing has exactly one parameter: Strength, defaulting to 5, with a minimum of 1. Everything else about the indicator follows from it.

Strength is the number of bars that must sit on each side of a candidate bar for it to count. The source builds a working window from it on the first line of setup:

constant = 2 * Strength + 1;

At the default that is 11 bars: five to the left, the candidate, five to the right. The indicator holds a rolling cache of exactly that many bars and evaluates nothing until the cache is full. On a fresh chart, nothing plots for the first 11 bars. On a 5-minute chart that is 55 minutes of blank chart before the first dot can appear, and it is the usual reason a trader thinks the indicator is broken on a chart they just opened.

Eleven bars in a row with the candidate swing high in the middle, 5 bars on its left and 5 on its right. At Strength 5 the window is 2 times Strength plus 1, or 11 bars, and nothing plots until the chart has that many.

Raising Strength does not make the indicator stricter in the way most people picture. It widens the window on both sides at once, so a higher number gives fewer swings and pushes them further into the past.

The delay nobody puts in the settings screen

This matters most, and the UI does not mention it anywhere.

The bar being tested is not the current bar. It is the bar in the middle of that 11-bar window, Strength bars back. The indicator can only decide whether a high was a swing high once five more bars have closed after it. When it decides yes, it writes the value backwards across the bars it already has:

for (int i = 0; i <= Strength; i++)
    SwingHighPlot[i] = currentSwingHigh;

So the dot you are looking at was placed five bars after the high it marks. At the default setting, a swing high on a 5-minute chart is confirmed 25 minutes late. That is fine for measuring structure after the fact and useless as a trigger. It is also why a chart of the last three months looks so much cleaner than the same indicator did in real time: the historical picture uses information the live chart did not have yet.

A high followed by 5 more bars. Only when the fifth one closes does the Swing indicator confirm the swing high and write its value back across those bars. On a 5 minute chart the dot appears 25 minutes after the high.

Four behaviours the properties window does not mention

The first is that Calculate is forced and your setting is ignored. Swing sets its own calculation mode during configuration:

Calculate = Calculate.OnBarClose;

That line runs after your properties are applied, so switching the indicator to On Each Tick does nothing. There is no error and no warning, just a setting that reads one way and behaves another. If you have wondered why the dots never update intrabar however you configure it, this is why. The general trade-off is in Calculate on bar close vs on each tick, but with Swing you do not get the choice.

The second is that it hides from the Data Box. The defaults include DisplayInDataBox = false and PaintPriceMarkers = false. This trips people up because the usual quick test for whether an indicator exposes a plot is to hover over the chart and look for its value in the Data Box. Swing fails that test while having two perfectly good plots, SwingHigh and SwingLow. Turn Display in Data Box on in the properties window if you want to read the values while you work.

The third is that ties count differently on each side of the window. The older side requires strictly lower highs, so a bar equal to the candidate disqualifies it. The newer side allows equal highs. The two comparisons in the source really are different operators, not a typo. You see it on a double top whose peaks are at the same tick and within Strength bars of each other. The first peak gets marked and the second does not, because the second has an equal high behind it while the first only has one ahead of it. Most people assume the opposite when a dot is missing from an obvious level.

The fourth is that the line erases itself. When price trades above the current swing high without a new swing forming, the plot is reset instead of left in place, so the dotted level you were watching disappears the moment price exceeds it. For a structure display that is reasonable. For anything downstream that reads the plot, it is a problem, because the value it reads becomes unset with no event to announce it.

Reading it from your own script

If you are calling Swing from a strategy or another indicator, two details will save you an afternoon.

SwingHighBar(barsAgo, instance, lookBackPeriod) returns how many bars ago a swing high occurred, and returns -1 when it finds nothing in the lookback. Feeding that -1 straight into a price series as a bars-ago index throws, because the same class rejects a negative barsAgo with an exception rather than a null. Check for -1 before you use the result.

instance is 1-based, not 0-based. Asking for instance 0 throws immediately. And the search does not start at the current bar; it starts at CurrentBar - barsAgo - Strength, which is the same confirmation delay showing up again in a different place.

Where this leaves a second-entry trader

Swing answers one question well: where were the pivots. Use it to draw structure, measure leg sizes, and check after the session whether you read the day correctly.

It cannot answer the question a second-entry trader is asking, which is whether this pullback has now failed twice and offers an entry right now. That question is about the count of attempts inside a pullback, not about pivots, and it has to be answered on the bar it happens, not five bars later. Swing cannot do that by design. No Strength setting fixes it.

WiSE is built for that second question. It marks second entries as they form, on the bar, with the trend context and the bar quality filters already applied, so what you see on the chart is the signal and not an input you still have to interpret. The second entry guide walks through the setup logic it applies, and there is a 7-day free trial.

The two indicators sit together fine on one chart: Swing for the structure behind the move, WiSE for the entry inside it.

If you want an order to follow either of them, both expose real plots, and a plot is what you need to attach an order to a level. An order tool that follows Swing needs a BarsAgo style setting that reads the value from a completed bar instead of the forming one, because Swing confirms its value late by design. The attach to indicator guide covers what the platform does natively and where that stops.

A short first-run checklist

  1. Give the chart at least 2 × Strength + 1 bars before deciding the indicator is broken. Eleven at the default.
  2. Turn on Display in Data Box if you want to read SwingHigh and SwingLow values while you trade.
  3. Do not try to make it calculate on each tick. It will not.
  4. Compare the same chart in Playback against your memory of the live session before you trust the historical picture. The gap between the two is the confirmation delay, and it is larger than most people expect.
  5. If you are scripting against it, handle -1 from SwingHighBar and SwingLowBar on the first line, not the last.

Futures trading involves substantial risk of loss and is not appropriate for all investors. Indicators mark conditions on a chart; they do not create an edge.

Share
Email updates

Get the trading tool updates.

New releases, setup guides, and the occasional NinjaTrader tip. About once a week.

We keep your address in our own database and send from team@news.wizdough.com. Replies go to support@wizdough.com. Read how we handle your data in our Privacy Policy.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.