Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

StreamWriter

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

    StreamWriter

    I have slightly modified example "SampleStreamWriter". First option works, but my code doesn't.
    I am trying to write data to my file at user defined location. It doest write at the same time no error message. How to write to a file at user defined location?
    Any help please?
    Regards,

    Code:
    protectedoverridevoid Initialize()
    {
    // path = Cbi.Core.UserDataDir.ToString() + Instrument.FullName + ".txt";
    path = "D:\\ForexData\\Ninja" + Instrument.FullName + ".txt";
    CalculateOnBarClose =
    true;
    }

    #2
    Hello,

    This works for me:
    privatestring path2 = "C:\\AFolderName\\MyTestFile.txt";

    Try starting over with the SampleStreamWriter file and just changing the one line above and this line (of course use a patht that will work on your computer):
    sw = File.AppendText(path2);

    Can you get that to work?
    DenNinjaTrader Customer Service

    Comment


      #3
      Thankyou Ben for your reply.
      I was missing two "\\" at the end of my path string. Its working now.
      Thanks a lot.

      Cheers,

      Comment


        #4
        How do I encapsulate an output sw.WriteLine(" This is Close Price "25" ");

        it is reading it to behaving 2 quotation marks at "25"

        there fore an error occurs during compile of the indicator.

        Comment


          #5
          For the streamwriter, it seems to be writing the the next line below,

          Is it possible to write on the line above?

          Is it possible to overwrite the existing file with the new entry? By deleting the previous line?

          Comment


            #6
            Oil_Trader, yes these are possible: to write something with quotes, please try putting an @ symbol in front of the string. As for how to overwrite the existing file, you'll have to review the MSDN documents on StreamWriter because I'm not intimately familiar with the process.
            AustinNinjaTrader Customer Service

            Comment


              #7
              Can you give a specific example?

              This is what I am writing and yet is is saying ------> ) expected

              this is my code

              sw.WriteLine(@" SP500 ="1225.0" + NQ ");

              as you can see, there are quotation marks within the parameter

              Comment


                #8
                Hello OilTrader,

                You may have to use escape characters for the quotation marks. See the reference sample below for help with this:
                Indicator: Manipulating string objects
                Ryan M.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                566 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                330 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                547 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                548 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X