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 SuneSorgenfrei, Today, 04:47 AM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_ChrisSch  
              Started by lju45, Today, 04:54 AM
              0 responses
              6 views
              0 likes
              Last Post lju45
              by lju45
               
              Started by lakman184, Today, 03:09 AM
              4 responses
              14 views
              0 likes
              Last Post NinjaTrader_Jason  
              Started by romintrio, Today, 02:16 AM
              1 response
              4 views
              0 likes
              Last Post NinjaTrader_Jason  
              Started by SCC74, Today, 01:32 AM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_Jason  
              Working...
              X