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

When Calling GetCurrentBid() what is happening?

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

    When Calling GetCurrentBid() what is happening?

    Hi,

    What is happening (behind the scenes) when I call GetCurrentBid()/GetCurrentBidVolume()?
    Does it actively check the market or just check a parameter that was updated in the last market update?

    One more question if I Add Add(xxx, PeriodType.Second, 1, MarketDataType.Bid);
    Can I check GetCurrentBid()/GetCurrentAsk() the same as for MarketDataType.Last?

    Thanks!

    #2
    freewind, the GetCurrentBid / Ask functions are tied to the bar updates processing, so it would not be the exact same event as working for example from OnMarketData, solely updating when the Level 1 change event is seen.

    I don't fully follow the second question, you can add Last / Bid / Ask data with this add series call and if your dataprovider supports it, you can access historical series data then (in contrast to the GetCurrent functions that would see the Close price substituted in here).
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi Bertrand,

      So what is the best way to get the most accurate Bid/Ask Prices and quantity? Keeping it within OMarketData or using GeCurrentBid() ?

      My second question is if I add a bid barseries for example BIP == 1 can I use GetCurrentAsk(1) ?

      TX!

      Comment


        #4
        Accurate is relative, it depends on which events you would want to act / calculate.

        All true level 1 data updating events would be best handled in OnMarketData directly, as the Get functions will only be tied to the bar updates.

        You can call the Get functions with an index passed in, however for any tries to align trades with bid / ask you would need to keep in mind the timestamp granularity is limited to a second (which is considered for enhancement to millisecond for our next major update).
        BertrandNinjaTrader Customer Service

        Comment


          #5
          If I add two bid/ask series of the same product
          Add(ES 09-13, PeriodType.Second, 1, MarketDataType.Bid);
          Add(ES 09-13, PeriodType.Second, 1, MarketDataType.Ask);

          and in OnMarketUpdate:

          Code:
          protected override void OnMarketData(MarketDataEventArgs e)
                  {
                    
                       if(BarsInProgress == ESAskIndex)
          
          {
                          if (e.MarketDataType == MarketDataType.Last)
                              Print("Last = " + e.Price + " " + e.Volume);
                          else if (e.MarketDataType == MarketDataType.Ask)
                              Print("Ask = " + e.Price + " " + e.Volume);
                          else if (e.MarketDataType == MarketDataType.Bid)
                              Print("Bid = " + e.Price + " " + e.Volume);
          }
                      }
          Do I need to check also for the BIP ESBidIndex, or using ESAskIndex I'll get also bid updates?

          Comment


            #6
            You would not need to add those series in to have access to bid / ask events in OnMarketData() for the ES. The adding in would be strictly done for historical access of those series in OnBarUpdate().

            For BIP filters in OnMarketData, with multi-time frame and instrument strategies, OnMarketData() will be called for all unique instruments in your strategy. Use the BarsInProgress to filter the OnMarketData() method for a specific instrument. (BarsInProgress will return the first BarsInProgress series that matches the instrument for the event)
            BertrandNinjaTrader Customer Service

            Comment


              #7
              I didn't fully understand the second paragraph.
              If I have multi-time frame for a signal instrument which BIP should I check for in the OnMarketData, or it is not matter because all of them will be triggered one after the other?

              Comment


                #8
                It would only be important if you added more than one instrument, so you can differentiate between those. If you have only one instrument > the events would be triggered whenever they trigger / report.
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  OK, but and if I have multi-frame multi instrument which BIP should I check for in the OnMarketData to separate the different instruments?

                  Thanks again for the great support!

                  Comment


                    #10
                    Just use the first one that would be for a different instrument. Let's say you add 4 frames besides the primary in and then a series on another instrument > that would be then BIP 6 (primary + 4 adds + 1)
                    BertrandNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by michi08, 10-05-2018, 09:31 AM
                    5 responses
                    741 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by The_Sec, Today, 02:29 PM
                    0 responses
                    1 view
                    0 likes
                    Last Post The_Sec
                    by The_Sec
                     
                    Started by tsantospinto, 04-12-2024, 07:04 PM
                    4 responses
                    62 views
                    0 likes
                    Last Post aligator  
                    Started by sightcareclickhere, Today, 01:55 PM
                    0 responses
                    1 view
                    0 likes
                    Last Post sightcareclickhere  
                    Started by Mindset, 05-06-2023, 09:03 PM
                    9 responses
                    259 views
                    0 likes
                    Last Post ender_wiggum  
                    Working...
                    X