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

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.

    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.

        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.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by cre8able, Today, 01:16 PM
            2 responses
            9 views
            0 likes
            Last Post cre8able  
            Started by chbruno, 04-24-2024, 04:10 PM
            3 responses
            48 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by samish18, Today, 01:01 PM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Started by WHICKED, Today, 12:56 PM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by WHICKED, Today, 12:45 PM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X