Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Status Message

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

    Status Message

    I have a procedure in my custom Add On that takes a while to run, so I'd like to present and update a status message of some sort while the procedure is running. My preference is to use the NinjaScript Output window for this, but rather than write a new line, I'd like to update/overwrite the last line in the window each time I update the status message.

    Is it possible to update/overwrite the last line in the Output window? If yes, then what NinjaScript code would I use for this? If no, then might you offer a suggestion for another way to present a status message?

    Thank you in advance for any guidance you might provide.

    #2
    Hi NtFan, thanks for your post.

    You can use the ClearOutputWindow() method to do this.

    Please let me know if I can assist any further.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your suggestion, ChrisL. Keeping in mind that my objective is to _update_ the Output window, though, I need to do more than just clear it. The following example might help to explain my objective more fully.

      Output Window Contents Before Update
      15:07:02.. Step 1 complete
      15:08:10.. Step 2 complete
      15:08:12.. Step 3, Part 1 started

      Output Window Contents After Update
      15:07:02.. Step 1 complete
      15:08:10.. Step 2 complete
      15:09:25.. Step 3, Part 2 started

      In the example above notice that the first two lines in the Output window are the same both before and after the update, and only the last line has changed.

      When I first posted my question I should have asked this: Is it possible to clear the last line (and only the last line) in the output window and, if yes, then how? If this is possible, then clearing the last line and writing a new line would update the window. So...

      [Q1] Is it possible to clear only the last line in the output window and, if yes, then how?

      Given your suggestion I can think of another way to update the Output window, as follows: (i) Read the current contents of the window, (ii) Clear the window completely, (iii) Update the last line of the contents, and write the updated contents back to the window. For this to work I need to be able to read the current contents of the Output window; so...

      [Q2] is it possible to read the current contents of the Output window and, if yes, then how?

      Thank you for any insight that might be provide re. Q1 or Q2.

      Comment


        #4
        Hello NtFan,

        There is not a supported way to read the output window, and there is not a method to clear only the last line.

        You could consider writing your prints to a separate location, either to static variables in an AddOn, or use a StreamReader/StreamWriter to hold the last X number of output prints. You could then call ClearOutputWindow() and call Print again to display specifically what you want to display.

        An example for writing to static variables in an AddOn can be found here - https://ninjatrader.com/support/foru...ument-backtest

        Examples for using StreamReaders and StreamWriters can be found here - https://ninjatrader.com/support/help...indicator2.htm

        We look forward to assisting.
        JimNinjaTrader Customer Service

        Comment


          #5
          Thank you very much for your response, NT_Jim. While I think it would be useful for NinjaScript to provide a method to read the Output window and a method to clear the last line in the Output window, in the meantime my Add On procedure is storing its Output window messages in a variable, and clearing and rewriting Output window contents as needed. Of course if a message is written to the Output window that didn't originate from my Add On procedure, then that message is lost, but I'll have to live with this limitation for now. Thanks again for your help.

          Comment


            #6
            I am looking at the same issue. Ideally, writing to the Output tabs should support "\r" or CR (Carriage Return character) to enable the current line to be "rewritten". Other than the suggested approach above, which although technically feasible is rather impractical, is there any possibility for supporting this usage to be considered? It should, I believe, be possible to use any of the ASCII control characters that affect character output to be used as they are in many applications; e.g. BS (BackSpace) would allow updating an incremental value "in situ". These would need to be facilitated using the ability to write a line that does not automatically append a LF (LineFeed) or CR at the end of the write. Essentially, the ability to use the equivalent of Console.Write and Console.WriteLine in an Output Tab.

            Thanks.

            Comment


              #7
              Hello jeronymite, thanks for your post.

              I submitted a feature request to our development team for consideration in a future update.

              Kind regards.
              Chris L.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by wooofad, Today, 02:18 PM
              1 response
              4 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by JTizz, Today, 02:29 PM
              1 response
              6 views
              0 likes
              Last Post JTizz
              by JTizz
               
              Started by geotabs, Today, 01:34 PM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_PaulH  
              Started by sidlercom80, Today, 11:52 AM
              1 response
              7 views
              0 likes
              Last Post NinjaTrader_Kate  
              Started by pmallya.nt, Today, 12:28 PM
              2 responses
              18 views
              0 likes
              Last Post pmallya.nt  
              Working...
              X