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

Error Message

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

    Error Message

    I am getting an error message while trying to write this sample code. Am trying to compare the Bar Deltas. Any help will be appreciated.
    Thank you.
    Attached Files

    #2
    Hello Trader17,

    Thank you for the post.

    You mentioned sample code, I just wanted to clarify did you take this code from a sample somewhere? If so can you provide detail on which sample for context?

    The error you have displayed seems to indicate that you have an object named BarDelta in your script but you are trying to use it as a Series when it is not a Series.

    Could you provide the whole script as an attachment so I can see the full context of what you are trying to do in the script along with the properties you have defined?


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

    Comment


      #3
      I am trying to do this in Strategy Builder. Trying to learn the Script.
      Thanks.
      Attached Files

      Comment


        #4
        Hello Trader17,

        Thank you for the image that helps.

        Can you tell me, what is the overall goal you are trying to achieve or what BarDelta are you trying to access specifically? Is this the Volumetric Bars and its BarDelta?

        The variable you are using in the script "BarDelta" does not exist in that context, do you have an indicator named BarDelta imported? If you are trying to reference an indicator you likely need to modify the code like the following:

        Code:
        BarDelta( insert any required parameters)[0] < BarDelta ( ... )[1]
        Between the ( and ) would be any parameters the indicator required.


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

        Comment


          #5
          No. I am not using any indicator for the Bar Delta value. Just want to take it off the chart generated values on a volumetric chart. I am basically just wanting to compare the Bar Delta of the last 2 bars as a condition for entry. It is the Bar Delta value from Volumetric Bars.
          Thank you.

          Comment


            #6
            Hello Trader17,

            Thank you for clarifying that you want the Volumetric BarDelta.

            To access the Volumetric information you would need to use specific syntax for that. We have an example of all available Volumetric properties along with the requirements to use them here: https://ninjatrader.com/support/help...htsub=bardelta

            The sample at the bottom shows the correct syntax for the BarDelta property.

            If you are using a muli series script please ensure to read the comments in the sample as the sample referes to the Volumetric being the primary series specifically.

            Also please take note that the CurrentBar is being used rather than a number of BarsAgo. To use 1 BarsAgo you would need to use CurrentBar -1 and also check that you have at least 1 bar of data if(CurrentBar > 0).

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

            Comment


              #7
              Thanks Jesse. So if I want to compare the Bar Delta on the last 2 bars and we are calculating strategy on the close of the bar then is this correct? I will be using volumetric bars on the chart.
              (+ barsType.Volumes[0].BarDelta > + barsType.Volumes[1].BarDelta)

              Comment


                #8
                Hello Trader17,

                No this would not be in line with how the sample is coded. The BarsAgo you have used would be correct for any indicator that uses BarsAgo but this is not an indicator and has specific indexes used instead. I mentioned in the last post that you won't be using a BarsAgo here but you are instead using the CurrentBar.

                Here is the example again on how to do 1 BarsAgo when using the CurrentBar:

                Code:
                CurrentBar - 1
                You will also need to check that there is enough data before trying that:

                Code:
                if(CurrentBar < 1) return;
                The result would look just like the help guide sample except you have added minus one to the CurrentBar where it is used:

                Code:
                Print("Delta for current bar: " + barsType.Volumes[CurrentBar].BarDelta);
                Print("Delta for prior bar: " + barsType.Volumes[CurrentBar[B] - 1[/B]].BarDelta);
                I look forward to being of further assistance.
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  Thank you so much So the bar that just closed and enable the Calculation will be Current Bar, correct? Or in a regular bar would be 0, correct? THANK YOU for all your patience and support!!!

                  Comment


                    #10
                    Hello ​​​​​​​​​​​​​​​​​​​​​​​​​​​​Trader17,

                    Thank you for the reply.

                    I am not certain I understand the way you worded your reply. The CurrentBar would represent the current processing bars Index which would also be the same as 0 BarsAgo, is this what you are asking?

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

                    Comment


                      #11
                      Yes I want to make sure that Current Bar and Bars Ago (0) are one and the same. That is the last bar that just closed. And Current Bar -1 and Bars Ago (1) are the same and so on.
                      Thank you.

                      Comment


                        #12
                        Hello Trader17,

                        These two values are not the same, but for this purpose, they do represent the same position in processing. This is strictly due to how the volumetric bars are created using an Index for the Volumes object instead of a BarsAgo. The CurrentBar would be the current processing index, this is similar to BarsAgo in the sense that it is the reverse of the BarsAgo.



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

                        Comment


                          #13
                          Just making sure I am using the right bar number in the strategy. Thank you once again for all the patience and support!!!

                          Comment


                            #14
                            Originally posted by NinjaTrader_Jesse View Post
                            Hello Trader17,

                            These two values are not the same, but for this purpose, they do represent the same position in processing. This is strictly due to how the volumetric bars are created using an Index for the Volumes object instead of a BarsAgo. The CurrentBar would be the current processing index, this is similar to BarsAgo in the sense that it is the reverse of the BarsAgo.



                            I look forward to being of further assistance.
                            Thank you much.

                            1) So as long as I use Voulumetric Bars on the chart the strategy is running I do not need to add an additional data series, correct?

                            2) And as far as looking for bar lows, highs, opens, other indicators etc. on the same chart, the Bars Ago will work on the same chart along with Current Bar for the Delta logic, correct?

                            Thank you very much for you help and patience Jesse!!

                            Comment


                              #15
                              Hello Trader17,

                              Correct, if you review the help guide sample it notes that the sample is targeted at being the Primary series and gives notes on how to use it in the case it is not the primary.

                              For the second question, are you asking if you use this logic, can you still use BarsAgo with other items in your script? If so, then yes the BarsAgo concept still applies toward other indicators and anything that specifically uses a BarsAgo. The Volumetric BarsType is not an indicator so it does not use a BarsAgo but instead uses Indexing. This item is fairly unique in the way it works, really the only other place you use direct indexing would be with OnRender.


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

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by love2code2trade, Yesterday, 01:45 PM
                              4 responses
                              26 views
                              0 likes
                              Last Post love2code2trade  
                              Started by funk10101, Today, 09:43 PM
                              0 responses
                              7 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
                               
                              Working...
                              X