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 get multi-series current bar data

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

    How to get multi-series current bar data

    I want to know what the high and low of the current bar on a multi-series chart is. I thought I could get it with this code, for example if I'm trying to test to see if the previous bar's high is greater than the high (so far) of the currently-drawing bar on the chart, for bar series index 4:

    if (BarsInProgress == 4)
    {
    if (Highs[4][1] > Highs[4][0]) ...

    But this seems to be comparing the two bars before the currently-drawing bar. If I had Calculate on Bar Close = true, would that affect which bar the Highs[4][0] is referencing? Maybe I need to set that to false?

    Or, another idea, maybe create a fifth bar series as a 1-tick series and then:

    if (BarsInProgress == 5)
    {
    if (Highs[4][1] > Highs[4][0]) ...


    I guess my problem is that I want this Highs[4][0] value to be updated on each tick, but only for the Bars index 4. Hmmm... but would Calculate on Bar Close = false do the same thing? Would it make the indicator extremely slow though because I have 5 bars series on it?

    Thanks!
    Bryan
    cassb
    NinjaTrader Ecosystem Vendor - Logical Forex

    #2
    Hi Bryan,

    Yes it depends on whether you're using real time with COBC = false or historical. If you access historically or when COBC = true, you are not able to access values where the time stamp of the bar you're accessing is in advance of the time stamp of other series.

    This is detailed further here in the section How Bar Data is Referenced


    If you want to save resources combining COBC = false logic with COBC = true, this reference sample can help:
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Never mind -- sorry. I set Calculate on Bar Close = false and it works beautifully.
      cassb
      NinjaTrader Ecosystem Vendor - Logical Forex

      Comment


        #4
        Originally posted by NinjaTrader_RyanM View Post
        Hi Bryan,

        Yes it depends on whether you're using real time with COBC = false or historical. If you access historically or when COBC = true, you are not able to access values where the time stamp of the bar you're accessing is in advance of the time stamp of other series.

        This is detailed further here in the section How Bar Data is Referenced


        If you want to save resources combining COBC = false logic with COBC = true, this reference sample can help:
        http://www.ninjatrader.com/support/f...ad.php?t=19387
        Thanks Ryan -- you are too fast! :-)
        cassb
        NinjaTrader Ecosystem Vendor - Logical Forex

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by bortz, 11-06-2023, 08:04 AM
        47 responses
        1,610 views
        0 likes
        Last Post aligator  
        Started by jaybedreamin, Today, 05:56 PM
        0 responses
        9 views
        0 likes
        Last Post jaybedreamin  
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        19 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        6 views
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        16 views
        0 likes
        Last Post Javierw.ok  
        Working...
        X