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

how to know bars are not current

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

    how to know bars are not current

    what's the best way to know that the current bar is not an updating bar, such as when you scroll the charts right, the top right of the chart shows a black triangle. I'm thinking of checking bar[0]'s time being way older than the current time, but probably there's a much easier and better way to do it?

    #2
    Hello,

    If I understand you, the black triangle is your "signal" that you have scroll off the current bar. The current bar never changes, it only gets hidden when you scroll and it is out of sight.

    If that doesn't help please clarify.
    DenNinjaTrader Customer Service

    Comment


      #3
      Correct, that's the behavior I want, but I don't know how to write a conditional statement for that.

      I need to create a pseudo-code for something like this:

      If the black triangle appears, then do this...
      If the current-bar becomes hidden, then do this...
      If the right-most bar is not a bar that updates in real-time, then do this...

      Each of the three statements above satisfies my need, but what would be the easiest way for me to code something like that? I was considering checking the right-most bar's timestamp with conjunction of the time period (time/volume/tick) to know that it is one bar too old to be a current bar, but that seems kind of complicated. Was hoping there is something trivial.

      Thanks!

      Comment


        #4
        edsfreedom,

        Unfortunately this is not the way indicators are calculated. Indicators (and strategies) process from the oldest bar forward. After it finishes calculating it will sit there on the most recent bar and wait for more data to come in for further processing. As you scroll back in time it does not retrigger calculations.

        Essentially what this boils down to is that every bar processed and every OnBarUpdate() event is always the most recent bar at the time it is processed.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          I've found the easy solution from looking at the VolumeProfile indicator code:

          if (ChartControl.LastBarPainted < Bars.Count - 1)

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Perr0Grande, Today, 08:16 PM
          0 responses
          2 views
          0 likes
          Last Post Perr0Grande  
          Started by elderan, Today, 08:03 PM
          0 responses
          5 views
          0 likes
          Last Post elderan
          by elderan
           
          Started by algospoke, Today, 06:40 PM
          0 responses
          10 views
          0 likes
          Last Post algospoke  
          Started by maybeimnotrader, Today, 05:46 PM
          0 responses
          12 views
          0 likes
          Last Post maybeimnotrader  
          Started by quantismo, Today, 05:13 PM
          0 responses
          7 views
          0 likes
          Last Post quantismo  
          Working...
          X