NinjaTrader 8 indicators & series in Pine Script v6
Generated directly by pineForNinjaScript() at build time so every row matches the live browser converter.
| NinjaScript 8 C# (.cs) | Pine Script v6 |
|---|---|
double x = EMA(Close, 21)[0]; | x = ta.ema(close, 21) |
double x = SMA(Median, 50)[1]; | x = ta.sma(hl2, 50)[1] |
double x = HMA(Close, 14)[0]; | x = ta.hma(close, 14) |
double x = RSI(Close, 14, 3)[0]; | x = ta.rsi(close, 14) |
double x = RSI(Close, 14, 3).Avg[0]; | x = ta.ema(ta.rsi(close, 14), 3) |
double x = ATR(14)[0]; | x = ta.atr(14) |
double x = CCI(Typical, 20)[0]; | x = ta.cci(hlc3, 20) |
double x = Bollinger(Close, 2.0, 20).Upper[0]; | x = (ta.sma(close, 20) + 2.0 * ta.stdev(close, 20)) |
double x = MACD(Close, 12, 26, 9).Diff[0]; | x = ((ta.ema(close, 12) - ta.ema(close, 26)) - ta.ema((ta.ema(close, 12) - ta.ema(close, 26)), 9)) |
double x = Stochastics(7, 14, 3).D[0]; | x = ta.sma(ta.sma(ta.stoch(close, high, low, 14), 3), 7) |
double x = DonchianChannel(20).Upper[1]; | x = ta.highest(high, 20)[1] |
double x = MAX(High, 20)[1]; | x = ta.highest(high, 20)[1] |
bool bull = CrossAbove(EMA(Close, 21), SMA(Close, 50), 1); | bull = ta.crossover(ta.ema(close, 21), ta.sma(close, 50)) |
bool rth = ToTime(Time[0]) >= 93000 && ToTime(Time[0]) <= 160000; | rth = not na(time(timeframe.period, "0930-1600", "America/New_York")) |
double v = VOL()[0]; | v = volume |
double rng = Math.Max(Math.Abs(Close[0] - Open[0]), TickSize); | rng = math.max(math.abs(close - open), syminfo.mintick) |
Why OnBarUpdate() CurrentBar guards disappear in Pine Script v6
In NinjaTrader 8 C#, indexing Close[20] on bar 0 throws an out-of-range error unless you guard OnBarUpdate() with if (CurrentBar < 20) return;. Pine Script v6 evaluates every top-level ta.* series across every bar and propagates na automatically until enough historical bars exist—in fact, putting ta.ema() inside a conditional branch in Pine prevents it from updating on every bar.
[NinjaScriptProperty] inputs and Strategy orders
[Display] and [Range] attributes plus defaults in State.SetDefaults map straight to TradingView's settings dialog.
| NinjaScript 8 C# (.cs) | Pine Script v6 |
|---|---|
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name = "Fast Length", GroupName = "Parameters")]
public int FastLength { get; set; } = 21; | FastLength = input.int(21, "Fast Length", minval = 1, group = "Parameters") |
[NinjaScriptProperty]
[Range(0.5, 5.0)]
[Display(Name = "ATR Mult", GroupName = "Bands")]
public double AtrMult { get; set; } = 1.5; | AtrMult = input.float(1.5, "ATR Mult", minval = 0.5, maxval = 5.0, group = "Bands") |
EnterLong(1, "BreakoutLong"); | strategy.entry("BreakoutLong", strategy.long, qty = 1) |
ExitLong("ExitMid", "BreakoutLong"); | strategy.close("BreakoutLong") |
What cannot convert automatically (and why)
Flagged inline with TODO(NinjaScript) and 1-based C# line numbers rather than silent guesswork.
Compiled .dll assemblies, SharpDX OnRender(), ATM strategies and AddDataSeries()
- Compiled .dll vs .cs inside .zip archives: Exported NinjaScript
.ziparchives that include editable.cssource unpack automatically in your browser above; closed-source vendor archives that ship only a compiled.dllcontain .NET IL rather than editable C# source and cannot be converted. - SetStopLoss() / SetProfitTarget() / ATM templates: NinjaTrader expresses stops in
CalculationMode.Ticks,Currency, orPercentinsideOnStateChange(); attach a Pine v6strategy.exit()withlossandprofitin ticks (check tick math on ES, NQ, MES and MNQ with our futures tick value calculator). - AddDataSeries() & BarsInProgress: Secondary series (such as a 15-minute filter on a 1-minute NQ chart) map to
request.security(syminfo.tickerid, "15", expr[1], lookahead = barmerge.lookahead_on)in Pine v6—review closed-candle multi-timeframe hygiene in our non-repainting Pine Script guide. - SharpDX / OnRender(): Custom GPU canvas drawing (order-flow footprints, DOM heatmaps) has no canvas equivalent in Pine; use
box.new(),line.new(),polyline.new()ortable.new()instead.
Migrating from other platforms too? Try our MQL5 to Pine Script v6 converter, MQL4 to Pine Script v6 converter, thinkScript to Pine converter, or combine multiple Pine indicators into one slot before trading on FTMO Futures or FundedNext Futures.