What it does

Donchian Channels gives NinjaTrader 8 traders a straightforward high-low envelope based on a configurable lookback. It works well when you want recent price boundaries on screen without adding heavier indicator logic.

Who this is for

This page is a good fit for traders who want a readable Donchian Channels workflow without having to reverse-engineer the setup from forum posts or screenshots.

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

Donchian Channels 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

  • Tracking simple breakout levels.
  • Reading whether price is pressing the top or bottom of its recent range.
  • Using the midpoint as a quick range-balance reference.

Before using it live

  • Import the NinjaTrader 8 ZIP through NinjaTrader's normal import flow.
  • Start with a 20-bar lookback, then adjust for your chart timeframe.
  • Compare channel breaks with broader trend and volatility context.
  • Review how the tool behaves on your actual session template, chart type, and instrument.

Settings to review

Lookback

Controls the range used for the upper and lower channel.

Upper color

Sets the color of the recent high channel.

Lower color

Sets the color of the recent low channel.

Installation notes

  1. Import the NinjaTrader 8 ZIP through NinjaTrader's normal import flow.
  2. Start with a 20-bar lookback, then adjust for your chart timeframe.
  3. Compare channel breaks with broader trend and volatility context.

Downloads

FreeIndicators Donchian Channels 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 DonchianChannels.eld.txt
{
  Donchian Channels
  FreeIndicators.com source example.
  Works as a starting point for TradeStation EasyLanguage and MultiCharts PowerLanguage.
}

Inputs: Lookback(20);
Vars: Upper(0), Lower(0), Mid(0);

Upper = Highest(High, Lookback);
Lower = Lowest(Low, Lookback);
Mid = (Upper + Lower) / 2;

Plot1(Upper, "Upper");
Plot2(Lower, "Lower");
Plot3(Mid, "Mid");
MetaTrader 4 MQL4 DonchianChannels.mq4
// Donchian Channels
// 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 lookback = 20;
   for(int i = limit; i >= 0; i--) {
      int hi = iHighest(NULL, 0, MODE_HIGH, lookback, i);
      int lo = iLowest(NULL, 0, MODE_LOW, lookback, i);
      Buffer1[i] = High[hi];
      Buffer2[i] = Low[lo];
      Buffer3[i] = (Buffer1[i] + Buffer2[i]) / 2.0;
   }
   return(0);
}
MetaTrader 5 MQL5 DonchianChannels.mq5
// Donchian Channels
// 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 lookback = 20;
   for(int i = start; i < rates_total; i++) {
      double upper = high[i];
      double lower = low[i];
      for(int j = 1; j < lookback && i - j >= 0; j++) {
         upper = MathMax(upper, high[i - j]);
         lower = MathMin(lower, low[i - j]);
      }
      Buffer1[i] = upper;
      Buffer2[i] = lower;
      Buffer3[i] = (upper + lower) / 2.0;
   }
   return(rates_total);
}
TradingView Pine Script v5 DonchianChannels.pine
//@version=5
indicator("Donchian Channels", overlay=true)

lookback = input.int(20, "Lookback", minval=2)
upper = ta.highest(high, lookback)
lower = ta.lowest(low, lookback)
mid = (upper + lower) / 2.0
plot(upper, "Upper", color=color.red)
plot(lower, "Lower", color=color.green)
plot(mid, "Mid", color=color.blue)

Limitations

  • Breakouts can fail quickly in choppy markets.
  • The channel is based only on price range, not volume or volatility.
  • Short lookbacks can create noisy signals.

Frequently asked questions

Does it repaint?

This indicator is designed as a chart reference tool, not as a hindsight-only backfitted signal. Even so, you should still test it bar by bar on your chart type to confirm how it behaves on the active bar.

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.