Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Accessing Total Levels in a Volumetric Bar

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

    Accessing Total Levels in a Volumetric Bar

    Hi,

    I'm trying to access the total levels in a Volumetric Bar by but it's giving me an error.

    Code:
    int priceLevels = barData.GetPriceLevelCount(CurrentBar);
    Also, would I be able to access the Ask and previous Bid by the following:

    Code:
    double askVolCurrent = barData.GetAskVolumeForPrice(CurrentBar, i);
    
    double bidVolBelow = barData.GetBidVolumeForPrice(CurrentBar, i - 1);​
    Below is the entire code:

    Code:
    long currentBarLong = CurrentBar;
    
    var barData = barsType.Volumes[currentBarLong];
    
        if (barData == null)
    
            return;
    
    
                int priceLevels = barData.GetPriceLevelCount(CurrentBar);
    
    
                for (int i = 1; i < priceLevels; i++)
    
                {
    
                    double askVolCurrent = barData.GetAskVolumeForPrice(CurrentBar, i);
    
                    double bidVolBelow = barData.GetBidVolumeForPrice(CurrentBar, i - 1);
    
    
    
    
                    if (bidVolBelow > 0 && askVolCurrent / bidVolBelow >= ImbalanceRatio)
    
                    {
    
                        Draw.Text(this, $"BuyImb_{CurrentBar}_{i}", "⬆", 0, barData.GetPriceForPriceLevel(CurrentBar, i), Brushes.Lime);
    
                    }
    
    
    
    
                    double bidVolCurrent = barData.GetBidVolumeForPrice(CurrentBar, i);
    
                    double askVolAbove = barData.GetAskVolumeForPrice(CurrentBar, i - 1);
    
    
    
    
                    if (askVolAbove > 0 && bidVolCurrent / askVolAbove >= ImbalanceRatio)
    
                    {
    
                        Draw.Text(this, $"SellImb_{CurrentBar}_{i}", "⬇", 0, barData.GetPriceForPriceLevel(CurrentBar, i), Brushes.Red);
    
                    }
    
                }
    ​

    #2
    Hello AgriTrdr,

    What error are you running into? We would need that info in order to assist here.

    To get previous values you need to subtract the number of bars from CurrentBar, CurrentBar is the index of the bar being used in your code.

    Comment


      #3
      Hi,

      It's a CS1061 error.. Volumetric Bars does not contain a definition for GetPriceLevelCount

      Thanks

      Comment


        #4
        Hello AgriTrdr,

        That error is correct, that is not a method. If you are using external tools like AI we do not suggest that as they often provide invalid code. You can see how to use volumetric bars here:

        Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.

        Comment


          #5
          Ok understood.

          So would this be a good way to access the levels in a bar or is there another way?

          int priceLevels = barsType.Volumes[CurrentBar];

          Comment


            #6
            Hello AgriTrdr,

            CurrentBar is the bar that is processing in OnBarUpdate, that will increment as the bars progress. That is the index which is being used for the volumetric data. For example if you wanted 1 bars ago it would be CurrentBar - 1.

            The Volumes collection has various properties which you can see in the following link. The code you provided is not enough, you need to use one of the properties.

            Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            558 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            324 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            545 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            547 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X