Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

(CurrentBar == 0)

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

    (CurrentBar == 0)

    Hallo,

    What does (CurrentBar == 0) mean?. In the MACD indicator, it says:

    if (CurrentBar == 0)
    {
    fastEma.Set(Input[0]);
    slowEma.Set(Input[0]);
    }

    I though the CurrentBar index started from 1.

    /Juan Rivera

    #2
    >> I though the CurrentBar index started from 1
    Incorrect, starts at 0.

    Comment


      #3
      But in The NinjaTrader Help it says_
      CurrentBar
      Definition
      A number representing the current bar in a Bars object that the OnBarUpdate() method in an indicator, Market Analyzer column or strategy is currently
      processing. For example, if a chart has 100 bars of data, the very first bar of the chart (left most bar) will be number 1 (one) and each subsequent bar from
      left to right is incremented by 1.

      I am getting confused with something here: In the MACD, when it says:
      if (CurrentBar == 0)
      Is it refering to th every first bar of the chart, or is it refering to the last bar available (the very last bar)??


      Comment


        #4
        Not sure which docs you are looking at. I have latest 6.5.1000.2 installed and see this: http://www.ninjatrader-support.com/H...urrentBar.html

        Comment


          #5
          Ok, I see. there was a mistake in the older version of the Help.

          Talking about mistakes, in the tutorial Level 4 for indicators, when entering the Calculation Logic and it says:

          // Calculate the range of the current bar and set the value
          Plot0.Set(SMA(SMAPeriod)[0] + myDataSeries[0]);

          is that expression correct??

          Thanks!

          Comment


            #6
            What's wrong there?

            Comment


              #7
              Should it not be?

              Plot0.Set(SMA(myDataSeries,SMAPeriod)[0];

              Comment


                #8
                Not sure I follow. Statement below is syntactically incorrect.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                566 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                330 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                547 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                548 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X