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

Access to Volumetric Bars - Bar Statistics

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

    Access to Volumetric Bars - Bar Statistics

    Someone know how to call/ have access to a previous value of order flow volumetric bars - bar statistics? --- I tried to use what it is showed in NinjaTrader 8 HelpGuide
    barsType.Volumes[CurrentBar].GetAskVolumeForPrice(Close[0])
    When I try to modify CurrentBar value don't give me access of a previous value of current bar, having same behavior of an Index in C#.
    Someone know how to have access to previous value of CurrentBar or two bars before currentBar?
    Already tried setting [CurrentBar -1]
    Thanks for support.

    #2
    Hello Andrea Sinsin,

    Welcome to the support forums.

    CurrentBar - 1 would be the index minus one bar so that is correct, did you see an error or what specifically happened when you did that?

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

    Comment


      #3
      Jesse thanks for support.
      The problem when I set <CurrentBar - 1> is the do not print no value.
      Draw.Text(this, CurrentBar.ToString(), false, "" + Convert.ToString(barsType.Volumes[CurrentBar].TotalBuyingVolume) , 0, (High[0] + (5 * TickSize)), 5, Brushes.PaleVioletRed, myFont, TextAlignment.Center, Brushes.Transparent, null, 1);
      Using that code I can access to current bar Buying Volume for been printed, but when I use <CurrentBar - 1> do not print no value. What problem would be?

      Comment


        #4
        Hello Andrea Sinsin,

        Are you doing this from the Volumetric BarsInProgress?

        I tried this from an indicator that just uses the primary Volumetric series like our sample here: https://ninjatrader.com/support/help...sub=volumetric

        I modified it to use the following print:
        Code:
        Print("=========================================================================");
        Print("Bar: " + CurrentBar);
        Print("Total Buying Volume: " + barsType.Volumes[CurrentBar].TotalBuyingVolume);
        
        Print("=========================================================================");
        Print("Bar: " + (CurrentBar - 1));
        Print("Total Buying Volume: " + barsType.Volumes[CurrentBar - 1].TotalBuyingVolume);
        and this was the output:

        Bar: 3707
        Total Buying Volume: 1264
        ================================================== =======================
        Bar: 3706
        Total Buying Volume: 1289

        If you are not executing it from the volumetric BarsInProgress the CurrentBar won't represent the correct index in the volumetric Volumes collection. The CurrentBar that needs to be referenced is that of the Volumetric series.


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

        Comment


          #5
          Not sure.
          I used code you sent and appear this output:
          Indicator 'aTest1': Error on calling 'OnBarUpdate' method on bar 0: Index was outside the bounds of the array.

          Where do I have to use barsInProgress? I've been using the code showed:
          if (Bars == null)
          return;

          NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = Bars.BarsSeries.BarsType as
          NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;

          if (barsType == null)
          return;

          Comment


            #6
            Hello Andrea Sinsin,

            Are you using Volumetric as the primary series on the chart?

            The error means that on the first bar you are checking for data which is not available yet. You would get that if you tried to check the CurrentBar - 1 on bar 0, that would equal -1 which is not a bar.

            You would need to wait at least one bar before trying to retrieve 1 BarsAgo worth of data or 1 index ago in this case.

            Code:
            if(CurrentBar < 1) return;
            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Already solved it.
              Jesse thanks for support.
              Have one more question. How can I make a summarize of values? same logic as CumulativeDelta that summarize every new value of other bar statistics values from Volumetric Bars
              from Bar 300 till CurrentBar for example.
              Thanks for assistance.

              Comment


                #8
                Hello Andrea Sinsin,

                Thank you for the reply.

                I want to clarify, are you asking how to do a calculation over the bars index 300 till the current bar, or for the last 300 bars?


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

                Comment


                  #9
                  Jesse.
                  Exactly over the bars index.
                  Starting from bar 300 (for example) start adding to a int or var the new values from forward Bars
                  I tried a While Loop and a For Loop but doesn't work.
                  How can I do?
                  Thanks for your assistance.

                  Comment


                    #10
                    Hello Andrea Sinsin,

                    Thanks for the clarification.

                    Just as a heads up, you don't want to use any blocking loops like a while loop in NinjaScript that might get stuck. In this case you would want to use a for loop, you just need the right syntax.

                    A for loop will only be able to be used once you get past bar 300, if you want to use it before that point you would need more logic to make a safe value to use.

                    Code:
                    if(CurrentBar < 300) return; 
                    
                    for(int i = CurrentBar; i > 300; i--)
                    This would start at the current bar and work its way backwards. 305, 304, 303, 302, 301, 300

                    Code:
                    for(int i = 300; i < CurrentBar; i++)
                    This would start at 300 and go to the CurrentBar. 300, 301, 302, 303, 304, 305

                    I look forward to being of further assistance.

                    JesseNinjaTrader Customer Service

                    Comment


                      #11
                      Jesse.
                      Is cumulativeDelta using the logic of a for loop? or what type of logic?
                      Thanks for assistance.

                      Comment


                        #12
                        Hello Andrea Sinsin,

                        I wouldnt be able to say, that is an internal tool which is not exposed in the NinjaScript editor.

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

                        Comment


                          #13
                          Jesse.
                          Thanks for support.
                          What I been trying to understand how to plot was to print values like the image, using that logic
                          Starting with value of bar0 and cumulating every sum how it is explained in the image.
                          Attached Files

                          Comment


                            #14
                            Hello Andrea Sinsin,

                            Are you asking how you would do the math to add/subtract or otherwise accumulate a value? What you have displayed could be created by using a Series or a Plot. The previous calculated data could be used and new data can be added/subtracted to that to make a new current value.

                            There is some information about how series work and some examples here: https://ninjatrader.com/support/help...t8/seriest.htm

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

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by thumper57, Today, 04:30 PM
                            0 responses
                            1 view
                            0 likes
                            Last Post thumper57  
                            Started by OllieFeraher, 05-09-2024, 11:14 AM
                            5 responses
                            16 views
                            0 likes
                            Last Post MisterTee  
                            Started by jackiegils, Yesterday, 11:05 PM
                            1 response
                            10 views
                            0 likes
                            Last Post marcus2300  
                            Started by Skifree, Today, 02:50 PM
                            0 responses
                            8 views
                            0 likes
                            Last Post Skifree
                            by Skifree
                             
                            Started by owen5819, Today, 02:24 PM
                            1 response
                            12 views
                            0 likes
                            Last Post owen5819  
                            Working...
                            X