Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Correction in the Code Breaking Changes Overview

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

    Correction in the Code Breaking Changes Overview

    A small oversight apparently in the documentation:

    NinjaTrader previously used a Historical bool property to notify when an indicator or strategy bar was being processed historically or real-time. The NinjaTrader 8 OnStateChange() method has now introduced a concept of State.Historical or State.Realtime which will allow you to take action depending on the desired state:

    protected override void OnBarUpdate()
    {
    // only process on real-time data
    if (State == State.Historical)
    return;

    else if (State >= State.Realtime)
    // rest of logic
    }

    Shouldn't this say ... in the OnBarUpdate() method...?

    BTW, awesome new capability - this is something I spent months finding work arounds for.

    #2
    I at first read it that way that you are thinking - but if you look up OnStateChange - it makes more sense.

    Historical was tucked away into OnStateChange(), realtime was added.

    OnStateChange I suspect will be called first when historical hits, when realtime hits, etc.. You are just checking the state in OnBarUpdate that was caused by OnSTateChange.

    Comment


      #3
      Originally posted by sledge View Post
      I at first read it that way that you are thinking - but if you look up OnStateChange - it makes more sense.

      Historical was tucked away into OnStateChange(), realtime was added.

      OnStateChange I suspect will be called first when historical hits, when realtime hits, etc.. You are just checking the state in OnBarUpdate that was caused by OnSTateChange.
      The context is what doesn't make sense to me, sorry. By the time OnStateChange() catches it the State object has already been changed. The action happens in the OnBarUpdate() method where you are actually making use of it as in the example. It's not that you *have to* override OnStateChange to make use of that State object.

      Call me a stickler but IMHO that part of the doc should be rewritten a little to make that more clear.

      Comment


        #4
        Originally posted by molecool View Post
        A small oversight apparently in the documentation:

        NinjaTrader previously used a Historical bool property to notify when an indicator or strategy bar was being processed historically or real-time. The NinjaTrader 8 OnStateChange() method has now introduced a concept of State.Historical or State.Realtime which will allow you to take action depending on the desired state:

        protected override void OnBarUpdate()
        {
        // only process on real-time data
        if (State == State.Historical)
        return;

        else if (State >= State.Realtime)
        // rest of logic
        }

        Shouldn't this say ... in the OnBarUpdate() method...?

        BTW, awesome new capability - this is something I spent months finding work arounds for.
        Confusing I agree, until I thought of it this way. The State enum is a different and independent entity from the event handler/method OnStateChange(). We can query the State from anywhere that it is in scope, which pretty much means for all user classes, as the enum is declared way back in the NinjaScript namespace.

        Comment


          #5
          Originally posted by koganam View Post
          Confusing I agree, until I thought of it this way. The State enum is a different and independent entity from the event handler/method OnStateChange(). We can query the State from anywhere that it is in scope, which pretty much means for all user classes, as the enum is declared way back in the NinjaScript namespace.
          Exactly - what he said. Probably part of this should be in the docs.

          Comment


            #6
            Thanks for the feedback and discussion guys. We will review to make that point more clear.
            MatthewNinjaTrader Product Management

            Comment


              #7
              Originally posted by NinjaTrader_Matthew View Post
              Thanks for the feedback and discussion guys. We will review to make that point more clear.
              Thanks Matt - what's important is that you guys implemented this in the first place. I had to jump through a lot of hoops to differentiate between what I considered live and historical in NT7 - I'm sure you remember the pertinent threads. This makes the process rather trivial - assuming it works as expected.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by algospoke, Today, 06:40 PM
              0 responses
              2 views
              0 likes
              Last Post algospoke  
              Started by maybeimnotrader, Today, 05:46 PM
              0 responses
              6 views
              0 likes
              Last Post maybeimnotrader  
              Started by quantismo, Today, 05:13 PM
              0 responses
              6 views
              0 likes
              Last Post quantismo  
              Started by AttiM, 02-14-2024, 05:20 PM
              8 responses
              167 views
              0 likes
              Last Post jeronymite  
              Started by cre8able, Today, 04:22 PM
              0 responses
              8 views
              0 likes
              Last Post cre8able  
              Working...
              X