Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Trade Station vs Ninja Trader
Collapse
X
-
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?Tags: None
-
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.
-
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<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
Comment
-
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
-
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.
- Likes 1
Comment
-
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
-
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 XXfea, Yesterday, 07:01 PM
|
2 responses
17 views
0 likes
|
Last Post
![]()
by XXfea
Today, 08:38 AM
|
||
Started by mrgreentrading, 04-11-2025, 08:41 PM
|
10 responses
94 views
0 likes
|
Last Post
|
||
Started by ulisesguerrero, Today, 08:17 AM
|
0 responses
12 views
0 likes
|
Last Post
![]() |
||
Started by raysinred, Yesterday, 10:32 AM
|
2 responses
26 views
0 likes
|
Last Post
![]()
by raysinred
Today, 08:08 AM
|
||
Started by momchi, 04-26-2025, 10:22 AM
|
1 response
15 views
0 likes
|
Last Post
|
Comment