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

Using Streamwriter

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

    Using Streamwriter

    Hello,

    from the sampleStreamWriter I understand what its doing and I could add it to a script. But it is always appending when writing.

    I would need it eg simply to write a "1" when its long "2" when its short and a "0" when its flat, so only one value in the file without appending. I was on microsoft dot net api system io but I cant find this. Therefore thank you for helping me by giving me this snippet.

    Thank you!
    Tony

    #2
    Hello tonynt, thanks for your post.

    The StreamWriter has a constructor that takes a boolean, set that to false to overwrite your file.


    This publicly available link also has a solution:
    I am writing a text file and each time i write i want to clear the text file. try { string fileName = "Profile//" + comboboxSelectProfile.SelectedItem.ToString() + ".txt"; using (StreamWr...


    Kind regards.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      thank you for that link, this will help me.

      One more question please: I remember I had issues in NT7 with StreamWriter and StreamReader because I got the message from the script using StreamReader because the file is used by another process (so from the other script that is writing).
      Is there a solution for this problem please so that it can be write and read same time or any workaround?

      Thank you!
      Tony

      Comment


        #4
        Hi tonynt, thanks for the reply.

        See this section of the help guide that demonstrates how to use a dispatcher to write to the file, see the example under "Access Violation Exception":



        Best wishes.
        Chris L.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Segwin, 05-07-2018, 02:15 PM
        14 responses
        1,789 views
        0 likes
        Last Post aligator  
        Started by Jimmyk, 01-26-2018, 05:19 AM
        6 responses
        837 views
        0 likes
        Last Post emuns
        by emuns
         
        Started by jxs_xrj, 01-12-2020, 09:49 AM
        6 responses
        3,293 views
        1 like
        Last Post jgualdronc  
        Started by Touch-Ups, Today, 10:36 AM
        0 responses
        13 views
        0 likes
        Last Post Touch-Ups  
        Started by geddyisodin, 04-25-2024, 05:20 AM
        11 responses
        63 views
        0 likes
        Last Post halgo_boulder  
        Working...
        X