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

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, 03: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"


    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, 05: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 kujista, Today, 06:23 AM
              5 responses
              15 views
              0 likes
              Last Post kujista
              by kujista
               
              Started by f.saeidi, Today, 10:19 AM
              0 responses
              2 views
              0 likes
              Last Post f.saeidi  
              Started by traderqz, Yesterday, 09:06 AM
              2 responses
              16 views
              0 likes
              Last Post traderqz  
              Started by traderqz, Today, 12:06 AM
              3 responses
              6 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by RideMe, 04-07-2024, 04:54 PM
              5 responses
              28 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Working...
              X