Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dispose() behavior when going from Historical to Live

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

    Dispose() behavior when going from Historical to Live

    Hi, what exactly is the behavior when a strategy moves from Historical=True to Historical=False? Does it get called at all?

    When is Dispose() called when live?

    Thanks. W2

    #2
    Hello,

    Thanks for your note.

    There are some internal behaiviors the occur when this happens that is undocumented.

    What I would need here is what are you trying to do specifically?

    I look forward to assisting you further.
    BrettNinjaTrader Product Management

    Comment


      #3
      Hi Brett, as I'm not setup to go live right now so I can see for myself, I'm just trying to get a feel for what will happen. Another thought is when writing to files when live, how will the streamwriters get flushed and closed. In OnOrderUpdate() I am appending a file with order.ToString(). at the end of the run, dispose() is called and the writer is flush/closed, so I don't ahve to touch it. This is fine when Historical=true.

      What will happen when Historical=false? I still want to write order.ToString() to file. I will write my own app with FileSystemWatcher, which will need to read this file once it is written to, , I am assuming that I will have issues on trying to open or copy the file as it will still be opened in NT.

      While I still need to know if/when disposed() is called during historical=false, could you point me in the proper direction of having a custom application having immediate access to files which are written in NT ?

      Thanks. W2

      Comment


        #4
        Hello,

        Essentially. There is a dispose function that is called during the termination of the strategy(Disable the strategy) and other locations that is not documented, however really for any called custom c# functions you use in your strategy. What we recommend is that you always do your own Dispose() on custom objects instantiated. Therefor you will want to dispose these custom objects yourself in

        OnTermination()



        Let me know if I can be of further assistance.
        BrettNinjaTrader Product Management

        Comment


          #5
          Thanks Brett, so my other Q is that I have taken the WriteToFile method example from you refrence files..

          will using

          using (System.IO.StreamWriter writer = new System.IO.StreamWriter

          make my file available to my outside application immediately after it is written? As I'm not live, i really can't test this behavior myself right now.

          Thanks. W2

          Comment


            #6
            Hello,

            This gets into some more advanced c# programming. You would most likely want to take a look at what we use to allow NinjaTrader to do this internally in our application:

            A synchronization primitive that can also be used for interprocess synchronization.


            Let me know if I can be of further assistance.
            BrettNinjaTrader Product Management

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Hwop38, 05-04-2026, 07:02 PM
            0 responses
            177 views
            0 likes
            Last Post Hwop38
            by Hwop38
             
            Started by CaptainJack, 04-24-2026, 11:07 PM
            0 responses
            332 views
            0 likes
            Last Post CaptainJack  
            Started by Mindset, 04-21-2026, 06:46 AM
            0 responses
            254 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            356 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            184 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Working...
            X