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

Current Bar Number Being Processed

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

    Current Bar Number Being Processed

    when a script is loaded and it works its way through each historical bar 0 to Count
    can I (should I) reference the current bar being processed?

    e.g.

    if (CurrentBarIndex == 42)
    {

    }

    #2
    Hello,

    Thank you for the question.

    I would like to ask, What are you trying to do with the CurrentBar?

    In general you would use CurrentBar rather than CurrentBarIndex, unless CurrentBarIndex is a variable you have defined.

    Here is more information: http://www.ninjatrader.com/support/h...sub=CurrentBar

    Can you please detail more on what you are trying to do and I will provide a more clear answer.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      ok thanks again (1st class product + 1st class support ... consistently).

      During historical load I have a method that opens trading on specific bars and another method that compare the current bar to this. I can use Time[0] instead of an index but just wanted to know how NT handles this.

      e.g. if chart has 100 bars (Count=100) and a script is loaded, CurrentBar = 0 if 1st bar is being processed and CurrentBar = 99 if last bar is being processed. Count=100 at any time during load.

      Is that correct?

      Comment


        #4
        Hello,

        Thank you for the clarification.

        e.g. if chart has 100 bars (Count=100) and a script is loaded, CurrentBar = 0 if 1st bar is being processed and CurrentBar = 99 if last bar is being processed. Count=100 at any time during load.
        You are correct, the Count is set before the bars start loading so we know when to stop trying to load data.

        If you load a chart, the Count will start as the amount of bars so lets say 100.

        In OnBarUpdate on CurrentBar == 0, Count is equal to 100.
        on CurrentBar == 50, Count is still equal to 100.
        on CurrentBar == 99, Count is still equal to 100.

        Count will increase though if a new bar is generated, so we have Count == 100, a new bar generates and now Count is 101.

        Here is more information on Count http://www.ninjatrader.com/support/h.../nt7/count.htm

        I would recommend taking a look at the Data section in the NinjaScript manual, this is where the help for Count, CurrentBar, CurrentBars and a lot of the other fundamental items in NinjaScript are located.


        Please let me know if I may be of additional assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by funk10101, Today, 09:43 PM
        0 responses
        6 views
        0 likes
        Last Post funk10101  
        Started by pkefal, 04-11-2024, 07:39 AM
        11 responses
        37 views
        0 likes
        Last Post jeronymite  
        Started by bill2023, Yesterday, 08:51 AM
        8 responses
        44 views
        0 likes
        Last Post bill2023  
        Started by yertle, Today, 08:38 AM
        6 responses
        26 views
        0 likes
        Last Post ryjoga
        by ryjoga
         
        Started by algospoke, Yesterday, 06:40 PM
        2 responses
        24 views
        0 likes
        Last Post algospoke  
        Working...
        X