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

Examples of StreamWriter / StreamReader ?

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

    Examples of StreamWriter / StreamReader ?

    At the day's end, in my strategy, I have certain data organized as a simple array that I'd like to write to a file so this file can be read once again when the new session begins. I've been searching and reading about the use of : StreamWriter and StreamReader on the microsoft site but it's hard to understand all that formal way to explain without clear examples.

    Could you please indicate me where can I see some examples in order to be able to write and read this type of data files?

    Thanks

    #2
    Hi pstrusi, thanks for posting. We have a few examples for studying. I have linked them below.

    This indicator will write all of the chart’s historical bar data and indicator data to a CSV type file that can then be imported into a spreadsheet. To use this indicator, add it to a chart and (critical) wait until all indicators have finished reloading (no longer shows (Calculating…)). Click the green button in the […]



    Kind regards,
    -ChrisL

    Disclaimer:
    The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      I'm looking for something similar to this:

      Code:
      using System.IO;
      using System;
      public class Program {
         public static void Main() {
            string[] stringArray = new string[] {
               "one",
               "two",
               "three"
            };
            File.WriteAllLines("new.txt", stringArray);
            using (StreamReader sr = new StreamReader("new.txt")) {
               string res = sr.ReadToEnd();
               Console.WriteLine(res);
            }
         }
      }​

      Comment


        #4
        Originally posted by NinjaTrader_ChrisL View Post
        Hi pstrusi, thanks for posting. We have a few examples...........
        Thanks for answering ChrisL, but unfortunately it doesn't address the request. First, I wrote for the NT7 forum, not NT8, although they have similar guides ( by the way, all the links in the NT8 leads to an empty web page, error 404 ) . Second, at the final it gave the same useless example, working with indicators with a file of Strings. This is the link for NT7: https://ninjatrader.com/support/help...ce_samples.htm


        I just need to write in my disk, a data array that comes from a running strategy.
        In case you find some better idea, please let me know.

        Thanks

        Last edited by pstrusi; 10-19-2022, 11:56 AM.

        Comment


          #5
          Hi pstrusi, sorry for the oversight. The example is still basically the same since this is a C# library (StreamWriter) we are using to write to a file The only difference here is the setup where path is set up and OnStateChange() is similar to Initialize() in NinjaTrader 7. I'm not getting a 404 error on the links that I posted, your browser might not be pointing to the correct URL.

          Kind regards,
          -ChrisL
          Chris L.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_ChrisL View Post
            Hi pstrusi, sorry for the oversight. The example is still basically the same since this is a C# library (StreamWriter) we are using to write to a file ..........

            Kind regards,
            -ChrisL
            Since I consider that being able to write/read a data file for a Strategy use might be useful, I'm working to find a method for this and then letting know it in this forum.

            Comment


              #7
              Solved. Goto https://ninjatrader.com/support/foru...-from-strategy

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Mongo, Today, 11:05 AM
              0 responses
              2 views
              0 likes
              Last Post Mongo
              by Mongo
               
              Started by Tim-c, Today, 10:58 AM
              0 responses
              1 view
              0 likes
              Last Post Tim-c
              by Tim-c
               
              Started by traderqz, Yesterday, 09:06 AM
              3 responses
              23 views
              0 likes
              Last Post NinjaTrader_ThomasC  
              Started by f.saeidi, Today, 10:19 AM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by kujista, Today, 06:23 AM
              5 responses
              18 views
              0 likes
              Last Post kujista
              by kujista
               
              Working...
              X