Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Most recent Bid/Ask

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

    Most recent Bid/Ask

    Hi, I am facing the following problem:

    I submit orders (in MarketReplay mode) at Bid or Ask price (they are taken via functions GetCurrentBid/GetCurrentAsk) and sometimes I get a rejection due to price.

    Could I fix this if I get Bid/Ask values from OnMarketData handler?

    In other words, may GetCurrentBid/GetCurrentAsk use an "old" Bid/Ask value?


    Or, the described situation is valid?

    #2
    Hi Alex.nt,

    Thank you for posting.

    Yes, you can use an old bid/ask value.

    You will need to store any local variables with the older values by a tracking method and to compare against the relevant variables in your calculations.

    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Hi Cal,

      Sorry, I must have poorly described the issue.

      I am not looking for old values of Bid/Ask, I am wondering if GetCurrentBid/GetCurrentAsk may return old values comparing to Bid/Ask in OnMarketData handler?

      I am looking for the most recent Bid/Ask values. GetCurrentBid/GetCurrentAsk does not appear to provide the latest Bid/Ask value because an stop order based on GetCurrentBid/GetCurrentAsk can be immediately rejected (meaning GetCurrentBid/GetCurrentAsk returned non-actual Bid/Ask)

      Comment


        #4
        Alex.nt,

        GetCurrentAsk() or Bid() will return the current bid or ask price, however when used in the context of OnBarUpdate() will only get called on a bar update.

        You can try using OnMarketData() to test for Bid and Ask prices and use those for your values.
        Here is a link on OnMarketData() -
        http://www.ninjatrader.com/support/h...marketdata.htm
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          What would be NinjaTrader's recommendation:
          Rely upon GetCurrentBid/GetCurrentAsk OR always prefer the ones from OnMarketData?

          Comment


            #6
            Alex.nt,

            It depends on the context and how you want your strategy to use. Both are useful but have their own purposes for scripting.
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              OK, which method gives the most recent bid/ask?

              Comment


                #8
                Alex.nt,

                Again depends on the context.

                Let me give you two scenarios -

                The first is using GetCurrentAsk() with the OnBarUpdate() method. If you have calculate on bar close(COBC) set to false, the OnBarUpdate() will get called with each incoming tick of data and thus almost constantly updating your GetCurrentAsk().

                However, using OnMarketData() will allow you to filter out the Ask and Bid data only when it comes in.

                Both get the same results but differ on when the On() method gets called.
                Cal H.NinjaTrader Customer Service

                Comment


                  #9
                  Sorry, this is not the answer to my question.

                  Let me re-phrase it again: Is bid/ask data coming through OnMarketData the latest for a script?

                  And what is the source of data for GetCurrentBid/GetCurrentAsk? Is it different than OnMarketData?

                  Comment


                    #10
                    Originally posted by alex.nt View Post
                    Sorry, this is not the answer to my question.

                    Let me re-phrase it again: Is bid/ask data coming through OnMarketData the latest for a script?

                    And what is the source of data for GetCurrentBid/GetCurrentAsk? Is it different than OnMarketData?
                    What is your calculate on bar close set to?

                    Comment


                      #11
                      COBC = False

                      However, keep in mind that script may get a control not only via OnBarUpdate/OnMarketData handlers but also via Custom Events.

                      Comment


                        #12
                        Alex.nt,

                        Both will give you the same info.

                        As I stated before, they will be different based on when they are getting called. OnMarketData() will get called when bid and ask prices are coming on.

                        OnBarUpdate() will get called when -

                        A. You have COBC - true, when the bar closes.
                        B. On every incoming tick of data.


                        All your data is coming from your market data connection.
                        Cal H.NinjaTrader Customer Service

                        Comment


                          #13
                          Thanks,

                          The last question: could that be that the last Bid/Ask taken from OnMarketData is not equal to Bid/Ask taken from GetCurrentBid/GetCurrentAsk if COBC = False?

                          Comment


                            #14
                            Alex.nt,

                            From that standpoint they would be the same.

                            However, with COBC set to true I would see GetCurrentAsk/Bid being different than OnMarketData();
                            Cal H.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                            0 responses
                            650 views
                            0 likes
                            Last Post Geovanny Suaza  
                            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                            0 responses
                            370 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by Mindset, 02-09-2026, 11:44 AM
                            0 responses
                            109 views
                            0 likes
                            Last Post Mindset
                            by Mindset
                             
                            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                            0 responses
                            574 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by RFrosty, 01-28-2026, 06:49 PM
                            0 responses
                            577 views
                            1 like
                            Last Post RFrosty
                            by RFrosty
                             
                            Working...
                            X