Very different changes after changing code from Pine to C#

Hello everyone,

Quite new to this whole NT thing but I’ve found a very reliable strategy in Pine and I wanted to convert this to NT. Used ChatGPT for this obviously because I have no clear skill in C#. After lots of trial and error I’ve come to the conclusion that backtesting/optimizing doesn’t give any comparable P&L or amount of trades etc. Is this normal other than the different ways of calculating/smoothing certain indicators? Or am I just completely wrong/bad off going from Pine to C#.

Planning on joining a funded trading account soon if I can get this automated part thing going…

Hi @FlorpDorp, It’s impossible to tell for certain from the information in your post what the cause of the problem is in your conversion of your strategy from PineScript to NinjaScript and your switching from back-testing on TradingView I am assuming to NinjaTrader and probably switching the data sources and back-testing settings of your back-tests on the two different platforms, but NinjaTrader is a really strong algorithmic trading platform and is massively programmable.

The fact that the NinjaTrader software architects decided to make NinjaScript an API on top of C# instead of its own language was such a good decision in retrospect, and the software developers in charge of creating the NinjaScript API and the algorithmic trading features of NinjaTrader made a very large number of good design decisions that over many years has meant that NinjaTrader has become the algorithmic trading platform that it is today.

I know this doesn’t answer your question exactly, but I wanted to impress upon you that whatever the reason for the differences in back-test results, the odds of it being a problem with NinjaTrader are very small.

There is a high likelihood that your conversion of your PineScript strategy to a NinjaScript strategy wasn’t done such that the logic in the new strategy matches the logic in the old one.

It also could be that not only are you back-testing on a different data source but also perhaps you are back-testing on a different type of market data or are back-testing using different settings.

I recommend scrolling to the same trading date on a chart of back-test results on each platform to identify one single trade that is off in some interesting way and then diving into that single difference to determine what the difference was due to. Printing out results to the NinjaScript Output window and drawing tiny shapes or little labels with the output of your calculations on the NinjaTrader chart when entry or exit conditions are true or false, and doing the same thing in your other platform, and zooming into a single difference on a single day of trading with this output in both platforms will be where I would suggest you start so that you can get to the real reason for the differences in back-test results you are experiencing.