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

(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 andrewtrades, Today, 04:57 PM
                1 response
                8 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by chbruno, Today, 04:10 PM
                0 responses
                6 views
                0 likes
                Last Post chbruno
                by chbruno
                 
                Started by josh18955, 03-25-2023, 11:16 AM
                6 responses
                436 views
                0 likes
                Last Post Delerium  
                Started by FAQtrader, Today, 03:35 PM
                0 responses
                7 views
                0 likes
                Last Post FAQtrader  
                Started by rocketman7, Today, 09:41 AM
                5 responses
                19 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Working...
                X