Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
For analysis in CSV or Excel
Collapse
X
-
Hello ラリー,
Yes you can use any C# means to read external data like .csv files. There is a sample of using a stream reader in the following link:
There is a post about using excel files in the following link, this is not something our support can help with but there is a large amount of information in the post. NT8 related information is near the end of the pages on that post: https://ninjatrader.com/support/foru...96-ninja-excel
JesseNinjaTrader Customer Service
-
Hello ラリー,
No those are two separate topics. The first link I provided shows how to use C# built in features to read from .csv files. The second link is an unsupported Microsoft excel api to interact with Microsoft excel documents. That post was for NT7 originally but there are NT8 details nearing the end of that post as well. NinjaScript is C# language and NinjaTrader can reference C# dlls as described in that post.
JesseNinjaTrader Customer Service
Comment
-
Hello ラリー,
The first sample I had provided shows how to read .csv files and parse the text inside the file. If you would like to learn more about reading .txt or other type of files I would suggest to search online for C# tutorials to do that. Reading files is not NinjaScript specific, that is part of C# and how the StreamReader works. For example searching for "C# streamreader read text" will bring up many examples including on from Microsoft: https://docs.microsoft.com/en-us/dot...xt-from-a-file
The sample that I provided also goes into some detail about parsing the text data from the .csv file. The file extension does not really matter as long as the contents is a string or text, the streamreader can be used to read that text in C#.
In your question you asked about both .csv and excel so I provided resources for both of those topics. You can choose which you wanted to use based on the type of file. Excel files are not text files so you would need to use that second link if you waned to read excel files specifically.
JesseNinjaTrader Customer Service
Comment
-
Hello ラリー,
The sample does not display anything on the chart. You would need to review the code to see how the text is being read into the code. The purpose of that sample is to show how the C# feature streamreader works to read files. There is also logic in that to show how to parse the text data.
If you are having trouble understanding how streamreader works or how parsing text works you can find C# tutorials online to learn how to use those features. the streamreader is part of C# which is the language NinjaTrader uses for NinjaScript. There are a large number of tutorials and courses for C# in external sites. You can use a search engine like google to search for "C# streamreader examples" or "C# parse text from csv file" as some examples.
NinjaScript uses the NinjaScript Print statement in a lot of samples to output data to the output window which is what the streamreader sample does. Most samples you find wont do anything visual but instead are a way for you to look at what code is needed to do a task, you will need to read through the code to make sure you understand all the concepts it is using.
JesseNinjaTrader Customer Service
Comment
-
Thank you for your response.
I tried to run it and the output result shows that the symbols were loaded in visualstudio2022 as shown in the attached image, is this behavior correct?
NinjaScript uses the NinjaScript Print statement in a lot of samples to output data to the output window which is what the streamreader sample does. Most samples you find wont do anything visual but instead are a way for you to look at what code is needed to do a task, you will need to read through the code to make sure you understand all the concepts it is using.
Comment
-
Hello ラリー,
You don't need to use visual studio to run that sample, you would just apply it to a chart and then observe the NinjaScript output window.
https://ninjatrader.com/support/help...nt8/output.htm
Unless you are extremely comfortable with using visual studio outside of NinjaTrader I would not suggest using that tool for debugging NinjaScript objects. We can't provide help on how to use visual studio directly however it can be used to attach to NinjaTrader and step through code. if you are familiar with debugging C# code in your own external C# projects it would be the same process.
JesseNinjaTrader Customer Service
Comment
-
Hello ラリー,
That looks like its reading the .csv data and printing it to the output window. That script uses some logic to parse dates so if the data used does not match the output window you would need to make modifications to match the data you used. If you just wanted to print the .csv data you can remove the logic checking for dates and other parsing its doing and just print the read text.
.csv data is just a text file that's separated, csv means comma separated values so the output being text is correct because the input was also just text.
JesseNinjaTrader Customer Service
Comment
-
Hello ラリー,
Yes a csv file is just a text file, you can type anything you wanted in the file as long as its in the same format using commas or a specific symbol as a delimiter. If you review the code in the sample you can see that the file is being read line by line which is how each line is a new element. The data on each line is separated by commas and the line which is read is split using the comma as the delimiter.
As a side note you don't need to include quotes in the csv file, that is already a string. Quotes " " are only needed in C# code to denote a string.JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Haiasi, 04-25-2024, 06:53 PM
|
2 responses
16 views
0 likes
|
Last Post
by Massinisa
Today, 05:32 AM
|
||
Started by Creamers, Today, 05:32 AM
|
0 responses
4 views
0 likes
|
Last Post
by Creamers
Today, 05:32 AM
|
||
Net Change
by Segwin
Started by Segwin, 05-07-2018, 02:15 PM
|
12 responses
1,785 views
0 likes
|
Last Post
by Leafcutter
Today, 05:30 AM
|
||
Started by poplagelu, Today, 05:00 AM
|
0 responses
3 views
0 likes
|
Last Post
by poplagelu
Today, 05:00 AM
|
||
Started by fx.practic, 10-15-2013, 12:53 AM
|
5 responses
5,407 views
0 likes
|
Last Post
by Bidder
Today, 12:22 AM
|
Comment