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

Retrieving Last Bid and Ask size

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

    Retrieving Last Bid and Ask size

    Can you help me with some simple code to get the last bid size, and ask size (market depth 1st level). Not the bid/ask volume or bid/ask value.

    I looked a the sample level II book and it looks very complex. I just want the 1st level sizes.

    Many thanks



    a sample I copied from the sample maket depth book

    /// <summary>
    /// Called on each incoming real time market depth event
    /// </summary>
    protected override void OnMarketDepth(MarketDepthEventArgs e)
    {
    List<LadderRow> rows = null;

    // Checks to see if the Market Data is of the Ask type
    if (e.MarketDataType == MarketDataType.Ask)
    rows = askRows;

    // Checks to see if the Market Data is of the Bid type
    else if (e.MarketDataType == MarketDataType.Bid)
    rows = bidRows;

    if (rows == null)
    return;

    #2
    Hi Brutus,

    Welcome to the NinjaTrader Support Forums.

    For Level I data please use OnMarketData() instead of OnMarketDepth(). The data you are looking for can be very easily accessed from the code sample shown in this article: http://www.ninjatrader-support.com/H...tDataEventArgs

    Hope that helps.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Hi Josh

      Thank you for the welcome

      What I need is code to get the last bid size and ask size (market depth 1st level size displayed at bid or ask). Not the bid/ask volume or bid/ask value.

      From what you provided I can get the last bid and ask values, and calculate the trade volume at bid or trade volume at ask, but not get displayed size.

      R/
      B

      Comment


        #4
        Hi Brutus,

        I am not sure what you mean by bid size then. How is that any different then accessing bid volume?
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Hi Josh

          Its the size of the actual bid, shown in the DOM. For the Es the Dom shows 5 bid levels -

          1st level 200 contracts bid at 954 *** i want to get the 1st bid level value (200)
          2nd level 300 contracts bid at 953.75
          3rd level 400 contracts bid at 953.5
          4th level 1200 contracts bid at 953.25
          5th level 700 contracts bid at 953


          So the 1st level, or inside bid/ask, size of bid and size of ask.

          Thanks

          Comment


            #6
            Ah. Then Brutus, you will have to use the reference sample. Instead of cycling through the whole array you could print the first row.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Josh View Post
              Ah. Then Brutus, you will have to use the reference sample. Instead of cycling through the whole array you could print the first row.
              Hi Josh

              Could you help me out with the code to pull the first row data. Just the size of bid and size of ask

              Thanks

              Comment


                #8
                I believe you want to print the first [] from the ask book and the last [] on the bid book.

                Code:
                askRows[0].Price + askRows[0].Volume
                Code:
                bidRows[bidRows.Count - 1].Price + bidRows[bidRows.Count - 1].Volume
                You will need to play with it. Use the reference sample and look at the printed books. Then work from there to get what you want.

                If you feel you just don't want to deal with this level of programming you can try contacting one of the 3rd party NinjaScript Consultants here: http://www.ninjatrader.com/webnew/pa...injaScript.htm
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  OK thanks Josh, I think I got enought to work with.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Kaledus, Today, 01:29 PM
                  0 responses
                  3 views
                  0 likes
                  Last Post Kaledus
                  by Kaledus
                   
                  Started by PaulMohn, Today, 12:36 PM
                  1 response
                  16 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by yertle, Yesterday, 08:38 AM
                  8 responses
                  37 views
                  0 likes
                  Last Post ryjoga
                  by ryjoga
                   
                  Started by rdtdale, Today, 01:02 PM
                  1 response
                  6 views
                  0 likes
                  Last Post NinjaTrader_LuisH  
                  Started by alifarahani, Today, 09:40 AM
                  3 responses
                  19 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Working...
                  X