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

"OnBarUpdate"... Bar1 Array Error

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

    "OnBarUpdate"... Bar1 Array Error

    Hello,

    I get the following error when I run the strategy:

    Strategy '....': Error calling 'OnBarUpdate' Method at bar 1: The index was outside the array area.

    I created the strategy with the Strategy Builder

    Thank you for your help

    #2
    Hello Yannick,

    What version of NinjaTrader 8 are you using? (Help > About)

    Are there other errors appearing in the Log tab of the Control Center? (Is the FBOdown indicator experiencing an error?)
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      It is the version: 8.0.20.1 64-bit

      I also tested the indicator again in the chart. But I didn't get an error message.

      I only get the error message when I want to run a backtest

      Comment


        #4
        Hello Yannick,

        Thanks for that information.

        Is the indicator something you have the code for?

        Also do you still see the error if you form the condition to use a standard indicator like the SMA in place of your indicator? That would just help to confirm the problem is specifically the indicator and not another part of your script.

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

        Comment


          #5
          In the appendix you will find the code of the indicator. The code is actually very short. The indicator only calculates the Fibo value.

          With the other strategies / indicators I do not get an error message.
          What did I do wrong in the Strategy Builder?

          Comment


            #6
            Hello Yannick,

            Thank you for the details.

            From the image I don't see anything specifically wrong with how you used in indicator.

            In the code of the indicator it may be that it is not setting a value each bar, you might try this as a test to see if that is the case.

            Add the following to the indicator and then compile:

            Code:
            protected override void OnBarUpdate()
            {
            
            PreisTief[0] = 0;
            
            // existing code

            Otherwise if you can export the strategy and indicator and attach them I could review that further to see what may be happening.

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

            Comment


              #7
              First of all thank you for your effort and help! I hope we can solve the problem,

              I uploaded the files

              Best Regards

              Comment


                #8
                Have you had a chance to check it out?

                I thought maybe this could be the problem: https://ninjatrader.com/support/help...getvalueat.htm

                But unfortunately that didn't help either or I did it wrong ...

                Best Regards

                Comment


                  #9
                  Hello Yannick,

                  Thank you for the reply.

                  I was able to take a look into the situation, it looks like this is caused by the indicator. The way the indicator is programmed does not expose a plot which is how the strategy is trying to access the data, this causes an error.

                  The indicator just needs to use a Plot instead of a Series<double>, you can find an example in the following page: https://ninjatrader.com/support/help...ghtsub=addplot

                  After adding a plot you would replace:

                  PreisTief[0] = Price1;

                  with

                  Value[0] = Price1;

                  You will also need to remove my prior comment of: PreisTief[0] = 0;


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

                  Comment


                    #10
                    I really thank you very much! The error message is gone for now!

                    Could I set it up in Strategy Builder to save the value? I want , that the strategy
                    goes long, when touching or falling below the price

                    Would be grateful for any tip and help!

                    Best Regards!

                    Comment


                      #11
                      Hello Yannick,

                      It looks like that indicator only sets a value when the condition is true, you would need to have the indicator do this type of saving or more specifically plotting of a value.

                      You can likely add the following to the indicator to do that:

                      Code:
                      if(CurrentBar < 1 ) return;  // < -- this is already in the file
                      Value[0] = Value[1];  // <- add this line below the above line in the file
                      You can otherwise store values in the builder by using a variable and setting it to the value you wanted.


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

                      Comment


                        #12
                        Thank you very much. It works now!
                        Thanks again

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by dustydbayer, Today, 01:59 AM
                        0 responses
                        1 view
                        0 likes
                        Last Post dustydbayer  
                        Started by inanazsocial, Today, 01:15 AM
                        0 responses
                        3 views
                        0 likes
                        Last Post inanazsocial  
                        Started by trilliantrader, 04-18-2024, 08:16 AM
                        5 responses
                        22 views
                        0 likes
                        Last Post trilliantrader  
                        Started by Davidtowleii, Today, 12:15 AM
                        0 responses
                        3 views
                        0 likes
                        Last Post Davidtowleii  
                        Started by guillembm, Yesterday, 11:25 AM
                        2 responses
                        10 views
                        0 likes
                        Last Post guillembm  
                        Working...
                        X