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

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 Waxavi, 04-19-2024, 02:10 AM
                            3 responses
                            41 views
                            0 likes
                            Last Post gaz0001
                            by gaz0001
                             
                            Started by Max238, Today, 01:28 AM
                            2 responses
                            26 views
                            0 likes
                            Last Post NinjaTrader_ChristopherJ  
                            Started by Shansen, 08-30-2019, 10:18 PM
                            25 responses
                            949 views
                            0 likes
                            Last Post NinjaTrader_BrandonH  
                            Started by JonesJoker, 04-22-2024, 12:23 PM
                            8 responses
                            42 views
                            0 likes
                            Last Post JonesJoker  
                            Started by timko, Today, 06:45 AM
                            0 responses
                            6 views
                            0 likes
                            Last Post timko
                            by timko
                             
                            Working...
                            X