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

MaxBars in incoming Chart

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

    MaxBars in incoming Chart

    I understand that the CurrentBar cycles through the bars in the data series, but is there a variable that lets you know the total number of bars in the data series?

    #2
    ohtrader, CurrentBar would hold this number bars available - http://www.ninjatrader-support.com/H...urrentBar.html

    Just do something like this in indicator -

    Code:
     
    if (Historical) return;
    
    Plot0.Set(CurrentBar);
    This would plot number of bars on the chart when you load this live.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Suggestion for identifying the most recent historical bar

      I understand the use of the CurentBar / Historical to ensure that you're working on live data. The use of Historical for a 1-3 minute chart is OK for what I want to do, because in a relatively short timeframe the live data comes in and my analysis code will be run. I am not intending to plot anything based on this data, I am printing out the range of values for between the incoming interval for between 1 hr and several months ago (depending on the size of the interval).

      My challenge comes when I need to get information on expected ranges of upcoming bars for a longer timeframe, e.g. 30 min - 120 min. In these cases, if I rely on Historical, I may have to wait ~30 minutes up to over 1 hour to get the data. So, in the case of the longer timeframes, I would like to be able to run my code on the last completed bar. Any suggestions on how to do this??

      Thanks,

      Jackie

      Comment


        #4
        Jackie,

        Unfortunately I am not following you. The code processes from the very first bar moving forward. After each bar is processed it is considered "historical".
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          How to identify last Historical Bar

          OK - so on a one minute chart that has 15 bars back that is executing at 4:30 PM, the first bar is at 4:15 PM. Then on the next bar Open[0] refers to the 4:16 PM bar, and the prior bar is accessible via Open[1], etc. . I want to begin processing on the last completed bar relative to the current time and am having difficulty doing that. In other programming paradigms I have used a MAXBARS strategy to know when I am at the end of the intervals, and in this case I'd take a version of 'is this bar w/in 1 interval of the current-working interval' - but have not been able to find a way to code this (as data is either Historical, or Live). If I could easily compare/subtract time I could possibly go that route as well, but haven't found enough programming input on the web to do that.

          Your suggestions would be appreciated.

          Jackie
          Attached Files
          Last edited by ohtrader; 10-15-2009, 03:47 PM.

          Comment


            #6
            Bertrand's suggestion would be the way to do just that.

            Code:
            if (Historical)
                return;
            Prevents processing of any bars prior to when you started the strategy. Then with CalculateOnBarClose = true, you wait for the first real-time bar to close before you start process your script once.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Josh:

              For intervals of 5 min or less, Bertrand's suggestion works. If, however, I am on a 120-min chart - I don't want to wait up to 119 minutes to have the OnBarUpdate execute.

              Comment


                #8
                ohtrader,

                Then use CalculateOnBarClose = false and you will get updates every single tick in real-time.
                Josh P.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by mattbsea, Today, 05:44 PM
                0 responses
                3 views
                0 likes
                Last Post mattbsea  
                Started by RideMe, 04-07-2024, 04:54 PM
                6 responses
                31 views
                0 likes
                Last Post RideMe
                by RideMe
                 
                Started by tkaboris, Today, 05:13 PM
                0 responses
                2 views
                0 likes
                Last Post tkaboris  
                Started by GussJ, 03-04-2020, 03:11 PM
                16 responses
                3,282 views
                0 likes
                Last Post Leafcutter  
                Started by WHICKED, Today, 12:45 PM
                2 responses
                20 views
                0 likes
                Last Post WHICKED
                by WHICKED
                 
                Working...
                X