Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

3 indies on chart write to same file simultaneously w/StreamWriter?

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

    3 indies on chart write to same file simultaneously w/StreamWriter?

    Howdy.

    I have been using the output window for most of my data gathering, as I usually don't have much data.

    Currently I am outputting data in the form of rows via one of my indies. Typically, using the output window, I just stack 3 of my indicator on the chart, and it will output them, and I can sort them later in excel.

    I would like to do this with streamwriter. I can output ONE of the indicators fine. But when I try to put all 3 on a chart and run it, I get the error we put in the catch block using this reference sample:


    Is it possible to have 3 instances of an indicator open and writing to the SAME file?

    #2
    Originally posted by forrestang View Post
    Howdy.

    I have been using the output window for most of my data gathering, as I usually don't have much data.

    Currently I am outputting data in the form of rows via one of my indies. Typically, using the output window, I just stack 3 of my indicator on the chart, and it will output them, and I can sort them later in excel.

    I would like to do this with streamwriter. I can output ONE of the indicators fine. But when I try to put all 3 on a chart and run it, I get the error we put in the catch block using this reference sample:


    Is it possible to have 3 instances of an indicator open and writing to the SAME file?

    Comment


      #3
      Hello forrestang,

      Thank you for your post.

      Sledge provides a link to a forum thread were this was answered as well, the post that answers the question can be found at the following link: http://www.ninjatrader.com/support/f...18&postcount=4

      This refers directly to the FileShare Enumeration: http://msdn.microsoft.com/en-us/libr...(v=VS.90).aspx

      Please let me know if you have any questions.

      Comment


        #4
        Originally posted by NinjaTrader_PatrickH View Post
        Hello forrestang,

        Thank you for your post.

        Sledge provides a link to a forum thread were this was answered as well, the post that answers the question can be found at the following link: http://www.ninjatrader.com/support/f...18&postcount=4

        This refers directly to the FileShare Enumeration: http://msdn.microsoft.com/en-us/libr...(v=VS.90).aspx

        Please let me know if you have any questions.
        What needs to be changed in NT to make this work? I'm not sure how to implement that msdn reference sample into NT so that separate indicators will write to the same file?

        Comment


          #5
          Hello forrestang,

          Thank you for your response.

          You would need to add the FileStream() to the following lines of code in the OnBarUpdate() Try Catch:
          Code:
           if (CurrentBar == 0)
          {
          fs = new FileStream(path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
          sw = File.AppendText(path);
          fs would need to be defined as a FileStream in the variables section of the code:
          Code:
           #region Variables
          ...
          // Creates a StreamWriter and a StreamReader object
          private System.IO.StreamWriter sw;
          private FileStream fs;
          #endregion

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          558 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          324 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
          545 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X