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


Build Volume Ladder for Bid/Ask Volumne of current bar

  • Filter
  • Time
  • Show
Clear All
new posts

    Build Volume Ladder for Bid/Ask Volumne of current bar

    Hi Ninjatrader team,

    I am trying to build a strategy using Bid/Ask Volume per bar (basically the same thing as Volumetric Bars, but used in a strategy). I saw this as an example of what I am looking for, but this is for Order Book data. Is there a way to gather the actual bid/ask volume for each price in a bar in the same way and put it into a price ladder?

    Any help is greatly appreciated.

    Hello Deterministic J, thanks for your post.

    You would want to use the OnMarketData method to accomplish this. OnMarketData will give you a stream of current bid, ask, and last prices along with their volume.

    Best regards.
    Last edited by NinjaTrader_ChrisL; 06-20-2019, 10:57 AM.
    Chris L.NinjaTrader Customer Service


      Thanks for the reply, Chris.

      Am I able to aggregate this in the same way the sample in my post does? Would it not be easier to create a price ladder and use barsType.Volumes[CurrentBar].GetAskVolumeForPrice and barsType.Volumes[CurrentBar].GetBidVolumeForPrice for each price in the bar?


        Hello Deterministic J, thanks for your reply.

        The volumetric bars do not take level 2 data into consideration, only the trades filled at either bid or ask price i.e. level 1 data. You will build your bar on that incoming data. OnMarketData will stream updates and the price type will either be of type bid, ask, or last. You will notice that when a "last" price update comes through, it is either equal to previous bid update or the previous ask update, and the volume of that "last" update will be subtracted from the volume of the respective bid or ask level.

        Since you need to sum and store the volume values at each tick level, you would need to implement something similar to the level2 book sample. You would need to make a custom series, and that series would hold a complex object that can hold A. price data and B. volume data for every bar. The list would hold every tick level that the bar saw while it was being built.

        Please let me know if you have any additional questions.
        Chris L.NinjaTrader Customer Service


          Hi Chris,

          Thanks for the idea. Maybe we are misunderstanding each other. I just want to make sure we are on the same page. I only want level 1 data for each tick in a bar. Exactly the same thing that the Volumetric bars output so I can use it in a strategy.

          So for example in the picture below I want to capture:

          2947.25 Bid Volume = 0
          2947.25 Ask Volume = 18
          2947 Bid Volume = 71
          2947 Ask Volume = 221
          2946.75 Bid Volume = 113
          2946.75 Ask Volume = 62

          All bid/ask volume aggregated together on each tick in price then after that bar is closed, reset.

          Would OnMarketData stream still be what I am looking for in order to do this?
          Attached Files
          Last edited by Deterministic J; 06-20-2019, 10:26 AM.


            Hello, thanks for your reply.

            I apologize, it turns out the example I gave does not implement OnMarketData. I will edit that post accordingly.

            One good example of gathering bid-ask volume would be the BuySellVolume indicator. If the last price >= e.ask price, that would be a buy. If the last price <= price, that would be a sell. The basic overview would be "When I receive a call to OnMarketData, note the price, check if it is a buy or sell, then place the volume of that price level into the series of lists, sort the list by price, repeat the procedure", or something along those lines.

            Also, note that you can add a Volumetric bars type to your strategy right now with AddVolumetric(). Or your primary series on the chart can be Volumetric bars and you can use the example from this page on how to access the data:
            Chris L.NinjaTrader Customer Service


            Latest Posts


            Topics Statistics Last Post
            Started by trader3000a, Today, 06:41 AM
            1 response
            Last Post NinjaTrader_Jesse  
            Started by slimcactus, Today, 10:26 AM
            0 responses
            Last Post slimcactus  
            Started by d122y, Today, 10:20 AM
            0 responses
            Last Post d122y
            by d122y
            Started by trader3000a, Today, 09:23 AM
            2 responses
            Last Post trader3000a  
            Started by CharlieBoy, Today, 08:37 AM
            1 response
            Last Post NinjaTrader_JustinD