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

Inconsistent Bars.BarsSinceNewTradingDay

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

    Inconsistent Bars.BarsSinceNewTradingDay

    Hello,

    If I print the Bars.BarsSinceNewTradingDay at Bars.IsLastBarOfSession I can see the number of bars are not consistent. Even if the Session Close Time is the same, the # of bars per session are not consistent. I see this with Second based bars. So why is this happening? Thanks for your help.

    #2
    I'm seeing the same thing , bar closed and open not same point. all of a sudden new bar appears and its Simms to be a complete mess.

    Comment


      #3
      Hello roblogic,

      That would depend on the available market data for the instrument. At 1 second granularity you may have times where there was no trades during that 1 second so that would cause a varied number of bars per session. You wont see bars when there are no trades as there would be no volume to or prices to plot. I would suggest trying a much larger timeframe like 5 minute bars to see if that is more consistent as you would generally see that there is always some trades happening during each 5 minutes of time so a bar would be generated.

      JesseNinjaTrader Customer Service

      Comment


        #4
        Thanks Jesse. That makes sense and increasing the granularity it does indeed reduce the inconsistency. I would like however a bar type that it calls OnBarUpdate every X seconds (or unit of time) irrespective of the market data. So if there was no new market data it will still call and create the bar with the exact High Open Low Close of the previous bar, so there will be always the same number of bars per session as long as the session closing time remains consistent. Are you aware of a bar type with these characteristics, or could any of the built-in time bars be modified to achieve such functionality? Thank you!.

        Comment


          #5
          Hello roblogic,

          Unfortunately that wouldn't be possible because of how bars types work. If there is physically no data for a time period then the bars type core method OnDataPoint is not called so there is no bar for that time period. When the OnDataPoint is called it uses the time from the data point to assign it to either a new bar or an existing bar depending on the timestamp. If a new bar is generated then the new data point timestamp is used and if there is time between the last bar there will be a gap between bar times.

          The only way to achieve that would be to modify the historical data and re import it. You could generate data that has a timestamp for every second and 1 volume for that timestamp if not already existing so it makes a bar but the realtime bars won't work like that.

          JesseNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by llanqui, Today, 10:32 AM
          0 responses
          1 view
          0 likes
          Last Post llanqui
          by llanqui
           
          Started by StockTrader88, 03-06-2021, 08:58 AM
          45 responses
          3,992 views
          3 likes
          Last Post johntraderuser2  
          Started by TAJTrades, Today, 09:46 AM
          0 responses
          7 views
          0 likes
          Last Post TAJTrades  
          Started by rhyminkevin, Yesterday, 04:58 PM
          5 responses
          62 views
          0 likes
          Last Post dp8282
          by dp8282
           
          Started by realblubb, Today, 09:28 AM
          0 responses
          8 views
          0 likes
          Last Post realblubb  
          Working...
          X