Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to calculate Bid/Ask volume from Last volume + Bid/Ask Offers

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

    How to calculate Bid/Ask volume from Last volume + Bid/Ask Offers

    Hey,

    I am trying to figure out what the process would be to calculate what the Bid/Ask volume traded at each price. We have the following snippet of code which will update whenever the number of available Bids or Offers updates or some quantity of contracts was traded at the Last price. When the Bid or the Ask volume change, this does not necessarily mean any quantity was traded at those prices, it could just be that more Bids or Offers were added or taken away from those prices. :

    protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
    {
    // Print some data to the Output window
    if (marketDataUpdate.MarketDataType == MarketDataType.Last)
    Print(string.Format("Last = {0} {1} ", marketDataUpdate.Price, marketDataUpdate.Volume));
    else if (marketDataUpdate.MarketDataType == MarketDataType.Ask)
    Print(string.Format("Ask = {0} {1} ", marketDataUpdate.Price, marketDataUpdate.Volume));
    else if (marketDataUpdate.MarketDataType == MarketDataType.Bid)
    Print(string.Format("Bid = {0} {1}", marketDataUpdate.Price, marketDataUpdate.Volume));
    }

    If you were to take the above code and add up for the volume for each bar and run it on a 200 tick chart you will notice that the Last quantity broadly adds up to 200 and the Bid and Ask volume is in the thousands. So I am guessing you have to infer the Bid and Ask by perhaps tracking the Delta between consecutive Last updates?

    My question is how do these market footprint indicators infer the numbers at the various levels for the Bid and Ask volume traded?
    Last edited by Nice-Spread; 02-22-2020, 02:05 AM.

    #2
    Hi Nice-Spread, thanks for your post.

    Please see this help guide section on how to access bid and ask prices historically:

    "An example below shows how to access historical Bid and Ask prices with Tick Replay"
    https://ninjatrader.com/support/help...ick_replay.htm

    The standard Volume Profile indicator also shows how to access bid and ask values from OnMarketData when Tick Replay is on.

    Please let me know if I can assist any further.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thank you! I remember seeing this page some time ago but must have forgotten about it. I’ll give this a try and see if the accuracy of my volume calculations improve.

      Comment


        #4
        Hi, I'm really grateful for the help provided in this post, my doubt is about this method : "else" about "if (marketDataUpdate.MarketDataType == MarketDataType.Last)". which information does it give me?

        My code is attach.

        Once again thank you very much .
        Regards
        Attached Files
        Last edited by fcamargo; 09-25-2020, 04:19 PM.

        Comment


          #5
          Hi fcamargo, thanks for posting.

          When MarketDataType is Last the OnMarketData call is updating the last traded price. You can confirm this by using the Print method and printing out any necessary data.

          Kind regards.
          Chris L.NinjaTrader Customer Service

          Comment


            #6
            Thanks again... but, when not "MarketDataType is Last" , what traded data is giving me? what are all this trades that OnMarketData is giving me when isn't last prices traded....

            Comment


              #7
              Hello fcamargo, thanks for your reply.

              The Bid and Ask prices will update because they are the first level of the level 2 data. The Last data type will be a trade that happened at either the bid or ask. If you compare the last bid or ask price to the last price traded, the last price will equal either the last bid price or the last ask price reported.

              Please let me know if I can assist any further.
              Chris L.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by qm trader, Yesterday, 05:51 PM
              2 responses
              22 views
              0 likes
              Last Post NinjaTrader_ChrisL  
              Started by pdennis, Today, 07:43 AM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by NinjaTrader_Brandon, Today, 07:49 AM
              0 responses
              9 views
              0 likes
              Last Post NinjaTrader_Brandon  
              Started by b16_aln, Today, 05:15 AM
              1 response
              7 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by Negustrader, Today, 01:01 AM
              1 response
              17 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Working...
              X