Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

State == State.Terminated

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

    State == State.Terminated

    In Ninja Trader 7 we are using the following method

    protected override void OnTermination()
    {

    ////code for closing all running objects

    }

    and this method automatically call on when my chat is closing or strategy is removed from chart.

    In Ninja Trader 8 Instead of this method we need to use
    protected override void OnStateChange()
    {

    if (State == State.Terminated)
    {
    ////code for closing all running objects
    }
    }


    Am i Correct..?

    If My logic is correct then i am facing some issue.
    1. This method will execute when a new chart open
    2. This method will execute when a new Indicator/Strategy insert into chart.
    3. So my problem is that, my all object will close when a new chart open or a strategy is inserting into chart
    4. I think this method will execute frequently when my strategy is running.
    5. This method is not same like NT 7 OnTermination() method.Some issues still there.Please check it.

    #2
    This state will not be called when you open a new chart.

    State.SetDefaults and State.Terminated will be called globally for indicators and strategies when bringing up the list of indicators or strategies. However it is only called for an instance of the object used to generate that list. If you have your strategy running and configured, State.Terminated is not called for that instance of the strategy, but rather the instance that is generated to populate the list of the strategies. This should have no effect any the custom resources you may be disposing in State.Terminated for the configured and running instance of your strategy.

    This State is not an apples to apples rework of OnTermination, although is similar. There is some work being done around State.Terminated for B3 due out soon.

    I'm not sure exactly what you mean by "all object will close". Can you please specify the exact scenario you're facing so I can look into that further? What exactly are you doing in State.Terminated that is causing issues for you?
    MatthewNinjaTrader Product Management

    Comment


      #3
      Originally posted by NinjaTrader_Matthew View Post
      This state will not be called when you open a new chart.
      I see from another thread you're working with BarsTypes-> in that case, you would see State.Terminated called globally when you create a new chart with that bar type.
      MatthewNinjaTrader Product Management

      Comment


        #4
        State == State.Terminated

        I have attached a screen shot of my code from NT 7.

        These stream objects are used for writing some details.
        So these objects are Declared/Initialized one time when the Strategy is insert into a chart.
        On each tick this will collect and write some details into our local file. This Process will continue up to the chart is closed or strategy is removed from the chart.

        When strategy is removing from the chart , then the OnTermination method will execute and clear/close all these stream objects.

        I need to rewrite these functionalities into NT 8.
        So i rewrite these functionalities inside if(State == State.Terminated ) { }.

        But what will happened is that some times in between the tick or when the time of Strategy/Indicator insertion, this method will execute. So our all running File stream objects are cleared.Using this I need to collect the data up to my chart is closed or removed the strategy from the chart.So kindly please make sure any issues are in this area.
        Attached Files

        Comment


          #5
          In NinjaTrader 8, where are you initializing/setting up the I/O objects (which State?) If you are setting them up in the strategy constructor, or State.Defaults those objects may be created/destroyed during the process of bringing up the .Name of the strategy (i.e., when you right click and select "Strategy"). That is only one instance created/destroyed to generate that list.

          To ensure that your resources are not created under the strategy instance is actually configured and running, you should do this in State.Historical to setup any class level variables. This should ensure that the objects do not exist until the strategy has reached the historical point for that instance. Doing so should also ensure your running instance objects are only released in State.Terminated after the object resources are actually running.

          Happy to run a use case by development if there is a potential issue, but need a solid full complete picture of a bug to do so. Please give me something reproducible if you feel there is an issue, but I suspect the behavior is expected in the NinjaTrader 8 framework and the suggestion above should help.
          MatthewNinjaTrader Product Management

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by martin70, 03-24-2023, 04:58 AM
          15 responses
          114 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by The_Sec, Today, 02:29 PM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by jeronymite, 04-12-2024, 04:26 PM
          2 responses
          31 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by Mindset, 05-06-2023, 09:03 PM
          10 responses
          265 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by michi08, 10-05-2018, 09:31 AM
          5 responses
          743 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X