• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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.
    https://docs.microsoft.com/en-us/dot...ystem_Boolean_

    This publicly available link also has a solution:
    https://stackoverflow.com/questions/...before-writing

    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":

        https://ninjatrader.com/support/help...-threading.htm

        Best wishes.
        Chris L.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by bbdjad, Today, 04:36 AM
        0 responses
        4 views
        0 likes
        Last Post bbdjad
        by bbdjad
         
        Started by mittie3, Today, 03:33 AM
        0 responses
        7 views
        0 likes
        Last Post mittie3
        by mittie3
         
        Started by Againmain1, Today, 03:04 AM
        0 responses
        8 views
        0 likes
        Last Post Againmain1  
        Started by tonytimpa, Today, 01:33 AM
        0 responses
        5 views
        0 likes
        Last Post tonytimpa  
        Started by kiwidtrader, Yesterday, 11:49 PM
        0 responses
        5 views
        0 likes
        Last Post kiwidtrader  
        Working...
        X