← All notes

Porting Pine Script to NinjaTrader 8 — what actually breaks

2026-09-30 · Pine Script · NinjaTrader 8 · Porting

A port is done when both platforms produce the same values on the same bars, not when the code compiles.

Where ports usually diverge

  • Bar indexing: Pine’s close[1] is NinjaScript’s Close[1], but NT8 fires OnBarUpdate per tick or per bar depending on Calculate. Pine scripts run on bar close unless told otherwise.
  • na handling: Pine propagates na quietly. In C# you have to decide explicitly what a missing value means during warm-up.
  • Built-in math: ta.rma, ta.ema seeding and ta.stdev (population vs. sample) differ from NT8’s built-in indicators. Re-implement them when exact parity matters.
  • Sessions and time: exchange time vs. local time, and the session template NT8 applies to the data series.
  • Order semantics: strategy.entry reversal behavior, process_orders_on_close and pyramiding don’t map one to one onto NT8’s managed order rules.

How I prove parity

  1. Export the Pine values bar by bar from TradingView.
  2. Log the same series from NT8 on the same instrument and session.
  3. Diff them and check every mismatch until the only differences left are data-feed differences.