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

OnMarketData vs OnBarUpdate

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

    OnMarketData vs OnBarUpdate

    Hi NT,

    I have seen indicators where OnMarketData precedes OnBarUpdate in the code and I have seen indicators where OnBarUpdate precedes OnMarketData.

    I have seen the same for indicators using OnMarketDepth and OnBarUpdate.

    My question is are there any advantages to the sequencing of these methods in the programming???

    Thanks,

    RJay
    RJay
    NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

    #2
    Hi rt6176,

    OnMarketData is described here:

    Which is called for every change in level one market data (bid, ask, last price and volume)

    Whereas OnBarUpdate:

    Which is called for each change in a bar, or on every tick (every transaction)

    Depending on what you are attempting, or the values you need to access, you will use these as needed. This sample shows how OnMarketDepth can be used - http://www.ninjatrader.com/support/f...ead.php?t=3478
    TimNinjaTrader Customer Service

    Comment


      #3
      OnMarketData() plotting

      Maybe slightly related to this discussion, would it be impossible to enable consistent plotting ability within OnMarketData() since OnBarUpdate() is too laggy by comparison when using calculations from OnMarketData()? Many bar types allow good plotting outside OnBarUpdate() but some really need to have their plots called in the correct area. Volume bars are a particular problem as are some custom bar types. I know it is not supported but the question is can it be fixed and become supported?

      Dan
      eDanny
      NinjaTrader Ecosystem Vendor - Integrity Traders

      Comment


        #4
        Hi eDanny,

        I will submit your suggestion of supporting the ability to plot from the OnMarketData() handler to our development team, for future consideration.
        TimNinjaTrader Customer Service

        Comment


          #5
          Thanks for that Tim.
          eDanny
          NinjaTrader Ecosystem Vendor - Integrity Traders

          Comment


            #6
            Originally posted by eDanny View Post
            Maybe slightly related to this discussion, would it be impossible to enable consistent plotting ability within OnMarketData() since OnBarUpdate() is too laggy by comparison when using calculations from OnMarketData()? Many bar types allow good plotting outside OnBarUpdate() but some really need to have their plots called in the correct area. Volume bars are a particular problem as are some custom bar types. I know it is not supported but the question is can it be fixed and become supported?

            Dan
            Hi Dan,

            I began my research into volume a year ago this month. Its a shame NT treats price and volume differently. I have seen NT users post complaints about how data providers are sending order information in batches. If a volume indicator plots from OnBarUpdate, it is NT that is collecting the data and holding it until there until a price change takes place before NT updates the volume indicators.

            I have seen volume data showing up late to the charts or not at all. I have also seen volume being removed from the indicators moments after being displayed.

            I was forced to develop a way to more accurately record volume.

            All of my many custom volume indicators now utilize a dual/ tandem updating system utilizing both OnBarUpdate() and OnMarketData().

            This configuration allows for real time updates to eliminate the lag issue and also uses end of bar programming to lock in the most recent volume updates to prevent them from being "Lost" at bar close.

            Without the dual updating system, NT's ability to plot bid ask volume data really sucks.

            Indicators on fast charts have gaps in data where bid/ ask volume data never makes it to the charts when the bar closes not at a price update.

            NT posted they will look into your request. For everyone here who uses volume, I hope they do.

            RJay
            RJay
            NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

            Comment


              #7
              RJay, are you meaning have the same Plots in both OnBarUpdate() and OnMarketData() simultaneously so no matter which fires off there will be plotting? I have done that before. I have also tried to plot the prior bar data one bar back at FirstTickOfBar with no success on a Volume chart.

              if(FirstTickOfBar)
              Values[0].Set(1, lastBarData);

              It would also be handy to plot in the OnMarketDepth() section too. This causes problems also.

              Dan
              Last edited by eDanny; 07-21-2010, 05:48 PM.
              eDanny
              NinjaTrader Ecosystem Vendor - Integrity Traders

              Comment


                #8
                Dan,

                Glad to know I'm not the only one.

                I'm struggling to get my latest volume indicator creations up and running.

                "Volume Force" and "Volume Pivots".

                RJay
                RJay
                NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

                Comment


                  #9
                  Yes it is nice to get an indicator done and tweaked and then start running through all bar types + custom types just to see it break! I would really like to see these suggestions implemented eventually.

                  Dan
                  eDanny
                  NinjaTrader Ecosystem Vendor - Integrity Traders

                  Comment


                    #10
                    LOL !!!!

                    I have to go through my indicators every couple months and remove the rejects and old versions of my projects.

                    When the compiler gets so slow, I take it anymore, Its time for a cleaning !!!

                    RJay
                    RJay
                    NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

                    Comment


                      #11
                      NT,

                      If you are unfamiliar with the problem we are discussing, let me try to explain.

                      Using the Print function, I have determined that during times when no volume indicator bar is formed, NT did not query OnMarketData() or OnMarketDepth() , depending on the kind of volume indicator being used.

                      The chart bars open, update, and close without OnMarketData() or OnMarketDepth() being accessed.

                      The problem with indicators using OnMarketData() occurs during large price moves at low volume.

                      The problem with indicators using OnMarketDepth() occurs much more often.

                      Attached is a 15 tick chart. The bottom indicator uses OnMarketDepth().

                      The missing bars are clearly evident. Since OnMarketDepth(). was not accessed during the timeframe for that bar, the indicator output was wrongly displayed as zero.

                      I have taken the time today to research this, I hope a solution will be available soon.

                      While waiting for a better solution, I would like to use FirstTickofBar to force an update from either OnMarketDepth() or OnMarketData() .

                      Can you suggest how to do this????

                      Thanks,

                      RJay
                      Attached Files
                      RJay
                      NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

                      Comment


                        #12
                        Hi rt6176,

                        To clarify, what are you plotting for each of these? The volume? The volume of what?
                        TimNinjaTrader Customer Service

                        Comment


                          #13
                          Bottom indicator is plotting level 2 book orders 1 tick above and 1 tick below bid and ask.
                          RJay
                          NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

                          Comment


                            #14
                            Hi rt6176,

                            Can you clarify "book orders"? Some type of volume?

                            What are you comparing this to? What behavior do you expect to see and what discrepancy do you see instead?
                            TimNinjaTrader Customer Service

                            Comment


                              #15
                              Book orders are limit orders placed above the ask and below the bid.

                              You know, Level2 orders. The DOM displays these orders.

                              I'm attaching an indicator that also displays level2 orders. (Book Orders)
                              Attached Files
                              RJay
                              NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Max238, Today, 01:28 AM
                              4 responses
                              35 views
                              0 likes
                              Last Post Max238
                              by Max238
                               
                              Started by r68cervera, Today, 05:29 AM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by geddyisodin, Today, 05:20 AM
                              1 response
                              11 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by timko, Today, 06:45 AM
                              2 responses
                              14 views
                              0 likes
                              Last Post NinjaTrader_ChristopherJ  
                              Started by habeebft, Today, 07:27 AM
                              0 responses
                              7 views
                              0 likes
                              Last Post habeebft  
                              Working...
                              X