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 helpwanted, Today, 03:06 AM
        0 responses
        3 views
        0 likes
        Last Post helpwanted  
        Started by Brevo, Today, 01:45 AM
        0 responses
        6 views
        0 likes
        Last Post Brevo
        by Brevo
         
        Started by aussugardefender, Today, 01:07 AM
        0 responses
        5 views
        0 likes
        Last Post aussugardefender  
        Started by pvincent, 06-23-2022, 12:53 PM
        14 responses
        242 views
        0 likes
        Last Post Nyman
        by Nyman
         
        Started by TraderG23, 12-08-2023, 07:56 AM
        9 responses
        384 views
        1 like
        Last Post Gavini
        by Gavini
         
        Working...
        X