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

When last bar is charged?

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

    When last bar is charged?

    Hi everybody!

    I need to do some calculations with dataseries but only once and when the last bar is charged. I suppose it is something like backtesting...

    The question is how I can know when is the last bar charged?

    Thanks in advance, Raymomd (from Spain!).

    #2
    I solved. I don't know why but I access the last OnBarUpdate() when:

    if (CurrentBar >= (Count - 2))

    Regards!

    Comment


      #3
      Raymond, another approach would be something like this:
      Code:
      int prevBar;
      
      OnBarUpdate()
      {
          if (CurrentBar != prevBar)
          {
              prevBar = currentBar;
              // run your once per bar calculation.
          }
      }
      Also, there is FirstTickOfBar.
      AustinNinjaTrader Customer Service

      Comment


        #4
        Thanks Austin!

        But I want to do the calculation only once, exactly when all the bars are charged on the screen. Not a calculation per bar.

        Comment


          #5
          Raymond,

          Not sure I follow. Bars are processed sequentially from the most left bar to the most right bar. There is no such processing of "once when all bars are done".
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            I agree that "Bars are processed sequentially from the most left bar to the most right bar".

            But I want to do "something" only once. I don't need to do the same "something" everytime OnBarUpdate() is called.

            Only when the most right bar is calling OnBarUpdate() I will do "something". And one way could be:

            if (CurrentBar >= (Count - 2))

            It's not very elegant because in my opinion it should be:

            if (CurrentBar >= (Count - 1))

            But I have tested and it works.

            Another question, perhaps I should open a new thread but anyway:
            I am using Ninja Trader with Yahoo free datafeed for Spain market Ibex35 values. The problem is that data is different from the real market. For example today BBVA has closed in 9,88 € but Ninja Trader Close[0] supplied by Yahoo is telling me 10,15 €. The market closed here exactly 2 hours ago because here are 19:34, so the historical data should be OK.

            I have configured Instrument manager with "Exchange" = mc (I don't know what it exactly means but I supposed that was 'Mercado Continuo', the name in Spain has the market) and "Ticker" = BBVA.MC.

            Thanks in advance again!

            Comment


              #7
              Raymond,

              Where are you getting the 9,88 value from? NinjaTrader just passes whatever information Yahoo is providing onto the charts you see. I suggest you go to Yahoo and check out their prices as shown from there to make a comparison.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                I compare data from Yahoo web page and NinjaTrader. I am not configuring well Yahoo datafeed for Spanish market, that is the problem.

                Do you know how to configure Ninja with Yahoo to obtain correct data?

                Best regards, Raymond.

                Comment


                  #9
                  Raymond,

                  This is the information on setting up the Yahoo connection. http://www.ninjatrader.com/webnew/support_Yahoo.htm

                  Once setup we are literally just taking whatever values Yahoo pushes our way.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    I have already configured in this way but my problem comes in next step:I am configuring wrong Instrument Manager.

                    Could you go deeper?

                    Thanks!

                    Comment


                      #11
                      I have the same problem. The solution with:
                      Code:
                      if(CurrentBar<BarsRequired||CurrentBar<Count-1-(CalculateOnBarClose?1:0))
                          return;
                      work only, if all bars are represented resp. the horizontal bar of the chart window is right. That's because the Count property contains the total bars but the CurrentBar property is only incremented until last represented bar. I can't find a property which contains only the total represented bars and not the total bars, have anyone a solution for this problem?

                      Comment


                        #12
                        I have found a solution .
                        It's not documented but the following code work:
                        Code:
                        if(CurrentBar<BarsRequired||CurrentBar<Count-(CalculateOnBarClose?1:0)-(LastVisibleBar<0?0:LastVisibleBar)+(CalculateOnBarClose&&LastVisibleBar>0?1:0)-1)
                            return;
                        The key is the LastVisibleBar, which contains a value with the number of bars which are not visibled .
                        Last edited by Burns; 02-20-2010, 11:36 PM. Reason: Update

                        Comment


                          #13
                          Raymond, the ticker BBVA is the ticker for the company's shares listed on the NYSE. This is the ADR version of the stock you'd like to view. I have a feeling the difference is due to looking at the wrong instrument (the NYSE ticker vs the Spanish market's ticker).
                          Attached Files
                          AustinNinjaTrader Customer Service

                          Comment


                            #14
                            The ticker I think is OK, because it's name is BBVA.MC and is the same I can see in Yahoo web for Spanihs shares. But perhaps the exchange option is wrong configured at Instrument Manager.

                            Do you know which is the exchange for Spanish shares?

                            Thanks!!

                            Comment


                              #15
                              Unfortunately we would not know which exchange to use for your particular instrument.
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Javierw.ok, Today, 04:12 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post Javierw.ok  
                              Started by timmbbo, Today, 08:59 AM
                              2 responses
                              10 views
                              0 likes
                              Last Post bltdavid  
                              Started by alifarahani, Today, 09:40 AM
                              6 responses
                              40 views
                              0 likes
                              Last Post alifarahani  
                              Started by Waxavi, Today, 02:10 AM
                              1 response
                              18 views
                              0 likes
                              Last Post NinjaTrader_LuisH  
                              Started by Kaledus, Today, 01:29 PM
                              5 responses
                              15 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Working...
                              X