You can, but translating the code isn't enough. Pine Script and NinjaScript fill orders, process bars and apply costs differently, so the same system can give different results. Before you trust the conversion, compare the trades one by one.
| What to check | Pine Script | NinjaTrader 8 |
|---|---|---|
| When it calculates | At the bar close by default | OnBarClose by default; always at the close on historical data |
| When it fills | At the next bar's open by default | Depends on the order type and the fill model |
| Adding entries | pyramiding is 1 | EntriesPerDirection is 1 |
| Costs | No commission and 0 ticks of slippage by default | You set them up in your test |
| Session end | No automatic exit from this feature | Exit on session close is on by default |
On this page
The biggest risk: repainting
TradingView calls repainting a script behaving differently on historical and realtime bars. On an open bar, the high, low and close aren't fixed yet, so a cross can appear and vanish. If your strategy does that, the conversion copies a signal your chart shows in a misleading way.
Watch out for request.security()
It's one of the causes that changes results most. In real time it can return unconfirmed values, and with lookahead it can read future data on historical bars. If your backtest uses another timeframe that way, its numbers can look too good. Fix that before you convert.
Non-standard charts
TradingView warns that on charts such as Heikin Ashi or Renko, results don't reflect actual market conditions by default. If your strategy was built there, test the logic on standard bars first.
How to convert it properly
- Write the rules in plain sentences: entry, exit, stop, schedule and size.
- Check the Pine code for repainting,
request.security()or non-standard charts. - Set realistic commission and slippage on both sides.
- Use the same instrument, period, session and timeframe.
- Compare trades one by one before you look at profit.
- Test in simulation and review why a backtest can differ from live.
If it's for a prop firm account, check the rules before coding. Some firms ban automated strategies, and others set specific conditions. See your firm's rules before you pay for a conversion.
Want us to convert it? We move your Pine Script strategy to NinjaScript and check that every entry and exit follows your rules. Simple conversions from $150.
Get a free quoteSources
- Repainting (Pine Script Docs)
- Strategies (Pine Script Docs)
- Calculate (NinjaScript Language Reference)
- EntriesPerDirection (NinjaScript Language Reference)
- IsExitOnSessionCloseStrategy (NinjaScript Language Reference)
Keep reading
Free: The Other Half Workbook. Nine templates for trading with a cool head: your one-page plan, the pre-session checklist, the twelve-patterns test, your size and the bill for your mistakes.
Get the free workbookGet ready for 2027: the Trader Planner. Each day's US releases in New York time, your pre-market routine and a log for every session.
Paperback on Amazon, $16.99 Get the PDF, $9Educational content based on the official TradingView and NinjaTrader documentation. Not investment advice. Backtest results are hypothetical. TradingView and NinjaTrader are trademarks of their owners.