What it does

Market Structure Swing Labels helps traders read trend state without manually annotating every swing. It is most useful when you want a cleaner view of sequence and confirmation during pullbacks, transitions, and structure breaks.

Who this is for

This page is aimed at traders who already know what problem Market Structure Swing Labels is solving and want clearer notes on setup, tradeoffs, and platform coverage.

Key terms for this tool

Review the core trading and platform terms tied to this page before changing settings or using the study in a live workspace.

What it is not

Market Structure Swing Labels is a chart-context tool. It does not place trades, manage risk automatically, or promise that a specific pattern will resolve in one direction. Use it to organize decisions, not to outsource them.

Chart examples

This chart capture shows the study on a real NinjaTrader workspace. Use it as visual reference, then confirm behavior on your own instrument, session, and timeframe.

Best fit

  • Reading trend state faster on busy charts.
  • Reviewing structure around pullbacks.
  • Teaching newer traders how swing sequences develop.

Before using it live

  • Import the NinjaTrader 8 ZIP through NinjaTrader's normal import flow.
  • Tune swing strength before relying on labels.
  • Use it to summarize structure, not replace trade planning.
  • Review how the tool behaves on your actual session template, chart type, and instrument.

Settings to review

Swing strength

Sets the bars required to confirm a swing.

Trend state

Optionally colors labels based on current structure.

Break markers

Shows when price breaks a prior structural swing.

Installation notes

  1. Import the NinjaTrader 8 ZIP through NinjaTrader's normal import flow.
  2. Tune swing strength before relying on labels.
  3. Use it to summarize structure, not replace trade planning.
  4. Expect the most recent swing label to change until confirmed.

Downloads

FreeIndicators Market Structure Swing Labels for NinjaTrader 8 NinjaTrader 8
Download

Source code

These source examples are provided for copy/paste workflows on other charting platforms. Review and test any script in a simulator before using it on a live chart.

TradeStation EasyLanguage / MultiCharts PowerLanguage MarketStructureSwingLabels.eld.txt
{
  Market Structure Swing Labels
  FreeIndicators.com source example.
  Works as a starting point for TradeStation EasyLanguage and MultiCharts PowerLanguage.
}

Inputs: SwingStrength(3);
Vars: SwingHighValue(0), SwingLowValue(0);

If SwingHigh(1, High, SwingStrength, SwingStrength + 1) <> -1 Then Begin
  SwingHighValue = SwingHigh(1, High, SwingStrength, SwingStrength + 1);
  Plot1(SwingHighValue, "SwingHigh");
End;

If SwingLow(1, Low, SwingStrength, SwingStrength + 1) <> -1 Then Begin
  SwingLowValue = SwingLow(1, Low, SwingStrength, SwingStrength + 1);
  Plot2(SwingLowValue, "SwingLow");
End;
MetaTrader 4 MQL4 MarketStructureSwingLabels.mq4
// Market Structure Swing Labels
// FreeIndicators.com source example for MetaTrader 4.
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 DodgerBlue
#property indicator_color2 Crimson
#property indicator_color3 SeaGreen

double Buffer1[];
double Buffer2[];
double Buffer3[];

int init() {
   SetIndexBuffer(0, Buffer1);
   SetIndexBuffer(1, Buffer2);
   SetIndexBuffer(2, Buffer3);
   return(0);
}

int start() {
   int counted = IndicatorCounted();
   int limit = Bars - counted - 1;
   int strength = 3;
   for(int i = limit; i >= strength; i--) {
      bool swingHigh = true, swingLow = true;
      for(int j = 1; j <= strength; j++) {
         if(High[i] <= High[i + j] || High[i] <= High[i - j]) swingHigh = false;
         if(Low[i] >= Low[i + j] || Low[i] >= Low[i - j]) swingLow = false;
      }
      Buffer1[i] = swingHigh ? High[i] : EMPTY_VALUE;
      Buffer2[i] = swingLow ? Low[i] : EMPTY_VALUE;
   }
   return(0);
}
MetaTrader 5 MQL5 MarketStructureSwingLabels.mq5
// Market Structure Swing Labels
// FreeIndicators.com source example for MetaTrader 5.
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_plots 3

double Buffer1[];
double Buffer2[];
double Buffer3[];

int OnInit() {
   SetIndexBuffer(0, Buffer1, INDICATOR_DATA);
   SetIndexBuffer(1, Buffer2, INDICATOR_DATA);
   SetIndexBuffer(2, Buffer3, INDICATOR_DATA);
   return(INIT_SUCCEEDED);
}

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[]) {
   int start = prev_calculated > 1 ? prev_calculated - 1 : 1;
   int strength = 3;
   for(int i = start + strength; i < rates_total - strength; i++) {
      bool swingHigh = true, swingLow = true;
      for(int j = 1; j <= strength; j++) {
         if(high[i] <= high[i + j] || high[i] <= high[i - j]) swingHigh = false;
         if(low[i] >= low[i + j] || low[i] >= low[i - j]) swingLow = false;
      }
      Buffer1[i] = swingHigh ? high[i] : EMPTY_VALUE;
      Buffer2[i] = swingLow ? low[i] : EMPTY_VALUE;
   }
   return(rates_total);
}
TradingView Pine Script v5 MarketStructureSwingLabels.pine
//@version=5
indicator("Market Structure Swing Labels", overlay=true)

strength = input.int(3, "Swing strength", minval=1)
ph = ta.pivothigh(high, strength, strength)
pl = ta.pivotlow(low, strength, strength)
plotshape(not na(ph), "Swing high", shape.labeldown, location.abovebar, color=color.red, text="SH", offset=-strength)
plotshape(not na(pl), "Swing low", shape.labelup, location.belowbar, color=color.green, text="SL", offset=-strength)

Limitations

  • Confirmed swing labels lag by design.
  • Microstructure can be noisy on low timeframes.
  • The indicator does not determine position size or invalidation.

Frequently asked questions

Does it repaint?

This tool can revise its most recent labels or levels until enough bars have formed to confirm the swing or range it is using. Older confirmed values should be more stable than the most recent developing ones.

Which platforms are covered?

NinjaTrader 8, TradeStation EasyLanguage, MultiCharts PowerLanguage, MetaTrader 4, MetaTrader 5, TradingView Pine Script are currently represented through downloads or source pages.

Is source code included?

Yes. This page includes source examples or links to platform-specific source pages where applicable.