Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Trade Station vs Ninja Trader

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Trade Station vs Ninja Trader

    How can I use the same data to back-test my code back-test from TradeStation to Ninja Trader or vice versa? The problem is my code is the same but my results are different? How can I make sure my new Ninja trader code is executing the same as my trader station code?

    #2
    Export the bar data from TradeStation and import it into NinjaTrader as a symbol - for instance, if it's a minute-bar strategy, you could export 1-minute data from TS for ES as TS_ES, and then import it into NinjaTrader as a new futures symbol TS_ES, then build any kind of minute bars from that knowing that the merges, holidays, etc. are all the same as on TS.
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      Hello RMin101,

      Thanks for your post.

      As a general rule for backtesting: Same Input data + Same strategy code and parameters = Same results. If there is different data being used then you will likely have different backtest results.

      You could consider following QuantKey_Bruce's advice to export your TradeStation historical data and import it into NinjaTrader to use for backtests.

      See the help guide documentation about importing historical data.

      Importing Historical Data: https://ninjatrader.com/support/help.../importing.htm
      Brandon H.NinjaTrader Customer Service

      Comment


        #4
        I am trying to export TS data and import it into NT 8, but I get errors because the formats are slightly different.. Any ideas how I make the formats the same, so that NT doesn't give errors? I could write a Python script, but I would think someone already created a solution for this.

        NT

        20231106 060100;4378;4378.5;4377.75;4378.5;127
        20231106 060200;4378.25;4378.25;4378;4378;42

        TS (has an additional column for open interest, different datetime formats and different delimiters)

        12/30/2022,07:31,3972.50,3972.50,3971.25,3971.75,123,361
        12/30/2022,07:32,3971.75,3973.75,3971.50,3973.50,436,149

        Thanks in advance,
        Sam

        Comment


          #5
          To convert the TradeStation (TS) data format to the NinjaTrader 8 (NT 8) format, you can use a Python script. The script will do the following:

          1. Read the TS data.
          2. Convert the date and time format from `MM/DD/YYYY,HH:mm` to `YYYYMMDD HHmmss`.
          3. Remove the open interest column.
          4. Adjust the delimiter from a comma to a semicolon.
          5. Write the transformed data in the NT 8 format.

          Here's the Python script that accomplishes this:

          ```python
          import pandas as pd
          from datetime import datetime

          def convert_ts_to_nt(ts_file, nt_file):
          # Read the TS data
          ts_data = pd.read_csv(ts_file, header=None)
          ts_data.columns = ['Date', 'Time', 'Open', 'High', 'Low', 'Close', 'Volume', 'OpenInterest']

          # Process each row
          nt_data = []
          for index, row in ts_data.iterrows():
          # Convert date and time format
          date_time_str = f"{row['Date']} {row['Time']}"
          date_time_obj = datetime.strptime(date_time_str, '%m/%d/%Y %H:%M')
          formatted_date_time = date_time_obj.strftime('%Y%m%d %H%M%S')

          # Format the row according to NT format
          formatted_row = f"{formatted_date_time};{row['Open']};{row['High']};{row['Low']};{row['Close']};{row['Volume']}"
          nt_data.append(formatted_row)

          # Write the NT data to a file
          with open(nt_file, 'w') as f:
          for line in nt_data:
          f.write(line + '\n')

          # Example usage
          convert_ts_to_nt('ts_data.csv', 'nt_converted_data.csv')
          ```


          The script reads the TS data from a CSV file. Then it iterates through each row, converting the date and time to the required format and removing the open interest column. Then each row is formatted according to the NT 8 format and written to a new file.

          Comment


            #6
            I really appreciate this. I was hoping there are built in features in TS or NT that allowed for changing the data formats. Someone does mention EL scripts that handled import/export conversions between the two formats in this thread at NexusFi https://nexusfi.com/ninjatrader/3598...tml#post892861

            Ymcapital ​- regardless of my wishful thinking, I do appreciate this code! Many thanks!

            Comment


              #7
              You can do that in the newest version of Excel as well since Python is built into Excel now if that's easier.

              NT is pretty selective about the format of the data that will work. It's not a common format (from what I've seen). I've bought data from different vendors before and I almost always have to reformat the data for NT which is a pain in the butt.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by fx.practic, 10-15-2013, 12:53 AM
              5 responses
              5,406 views
              0 likes
              Last Post Bidder
              by Bidder
               
              Started by Shai Samuel, 07-02-2022, 02:46 PM
              4 responses
              98 views
              0 likes
              Last Post Bidder
              by Bidder
               
              Started by DJ888, Yesterday, 10:57 PM
              0 responses
              8 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by MacDad, 02-25-2024, 11:48 PM
              7 responses
              160 views
              0 likes
              Last Post loganjarosz123  
              Started by Belfortbucks, Yesterday, 09:29 PM
              0 responses
              9 views
              0 likes
              Last Post Belfortbucks  
              Working...
              X