Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How get info from the latest non-completed Volumetric bar?

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

    How get info from the latest non-completed Volumetric bar?

    Hello.
    I am creating an indicator with two series: a primary and Volumetric (BarsPeriodType is the same as primary).
    Calculate set to OnEachTick.

    The last bar in volumeric volume series is last completed bar.
    Volumetrics bars series contains one bar less than primary bars:

    CurrentBars[0] == CurrentBars[1] -1
    BarsArray[0].Count == BarsArray[1].Count -1

    This is screenshot from the Visual Studio:

    Click image for larger version

Name:	image.png
Views:	117
Size:	35.8 KB
ID:	1333171​​​

    The absent volumetric bar is exactly the last developing bar.
    How to access its info?
    fx.practic
    NinjaTrader Ecosystem Vendor - fx.practic

    #2
    Hello fx.practic,

    Are you using the correct index when accessing the data? I just tried this code and can see the building bar values using the methods from the volumetric series. The script is using AddVolumetric and adding the same volumetric series that I added to a chart. Im using a 1 minute series as the primary and a 1 minute volumetric as the secondary series then adding a 1 minute volumetric to the chart to view the comparison.

    Code:
    protected override void OnBarUpdate()
    {
        if (Bars == null)return;
        if(State == State.Historical) return;
    
        NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType barsType = BarsArray[1].BarsType as NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType;
    
        if (barsType == null)
          return;
    
        if(BarsInProgress == 0)
        {
             Print("Ask for Close: " + barsType.Volumes[CurrentBars[1]].GetAskVolumeForPrice(Close[0]));
        }
    }​
    The values that print are for the volume at price for the building bar and not a previous bar.

    Comment


      #3
      Hello Jesse.
      Thanks for the prompt reply.

      How are you adding the Volumetric dataseries?

      This is my way:

      PHP Code:
      volBarsPeriodType = BarsPeriod.BarsPeriodType;
      volBarsPeriodValue = BarsPeriod.Value;
      
      AddVolumetric(Instrument.FullName, BarsPeriod.BarsPeriodType, BarsPeriod.Value, volDeltaType, volTicks); 
      
      fx.practic
      NinjaTrader Ecosystem Vendor - fx.practic

      Comment


        #4
        Hello fx.practic,

        For the purpose of testing I just used the same as the chart series. I added a 1 minute ES chart to apply the indicator to. I also added a 1 minute base volumetric with the same settings as shown below in AddVolumetric just for comparison, the indicator is not using that series but the values match.

        Code:
        {
            AddVolumetric("ES 03-25", BarsPeriodType.Minute, 1, VolumetricDeltaType.BidAsk, 1);
        }


        Keep in mind that adding series the way you have with variables can fail to load correctly which may be why there is a difference. I attached the script I was testing with.
        Attached Files
        Last edited by NinjaTrader_Jesse; 01-31-2025, 04:03 PM.

        Comment


          #5
          Your script works fine.
          So, fulfilled with the confidence, I played around and found that the issue was in PlayBack connection. On Simulated Data Feed it works fine.

          Thanks a lot, Jesse!
          fx.practic
          NinjaTrader Ecosystem Vendor - fx.practic

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          557 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