Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

bid and ask volume

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

    #16
    Originally posted by imalil View Post
    Thank you very much for the information. I'm just going to tell you what we're attempting since we're floundering a bit.

    From the first tick of a new bar, we want to add all the ask volume together at each price level for the entire bar, and add all the bid volume together at each price level for the entire bar. In other words, all asks at price 2000 will be added together over the bar, 2000.25 will be added together, etc. The same for the bids. So every price level will have a grand total of bid and ask volume. We then want to apply our formula comparing the asks at a certain price to the bids at a certain price, at all price levels on the bar so we can get the value we're after. When a new bar starts, the counting resets and starts over again.

    We are having problems 1) resetting at the new bar and 2) working with marketdatatype vs. onbarupdate. We've read all the definitions and are still not 100% sure which to focus on. I do not care if our calculation takes place during the bar or after it closes. I just want to do what's most efficient. If it takes two indicators to make this work--one during the bar totalling all the bids/asks, and one after the bar closes to do the math--I can live with it. We just want to know what to focus our attention on so we don't waste our time trying this and that.

    If anyone can give us feedback on this I'd greatly appreciate it. Thank you again.
    Reset at the new bar: You put this at the first line of OnBarUpdate:

    If (FirstTickOfBar) {
    bidVol = asKVol = ... = 0; // reset anything you want here
    }
    For real time calculation of bidVol and askVol, I definitely recommend OnMarketData. I opened a thread rather similar to yours about the difference between OnMarketData and OnBarUpdate. Finally I choose OnMarketData because it is more accurate.

    Thanks.
    Pi
    ninZa
    NinjaTrader Ecosystem Vendor - ninZa.co

    Comment


      #17
      Thanks, Pi. Can you link your thread? And does my plan sound doable to you?

      Comment


        #18
        Originally posted by imalil View Post
        Thanks, Pi. Can you link your thread? And does my plan sound doable to you?
        Sure your plan sounds doable.
        My thread is http://www.ninjatrader.com/support/f...ad.php?t=71111
        ninZa
        NinjaTrader Ecosystem Vendor - ninZa.co

        Comment


          #19
          So Pi, right after

          protected override void OnBarUpdate()

          but before

          protected override void OnMarketData(MarketDataEventArgs e)

          I should place this code? I've tried bidvol, getcurrentbidvolume, getcurrentbid, everything I can find, I always get errors. Is your quote correct? Thank you.

          Comment


            #20
            Hi imalil,

            Here is my original code in Volume Delta to calculate bid & ask volumes in real time :

            Code:
                    protected override void OnBarUpdate() {
            			if (Historical) return;
            			
                        if (FirstTickOfBar) {
            				askVol = 0;
            				bidVol = 0;
            		}
            				
                    }
            		
            protected override void OnMarketData(MarketDataEventArgs e) {
                        if (e.MarketDataType == MarketDataType.Ask) askPrice = e.Price;
                        else if (e.MarketDataType == MarketDataType.Bid) bidPrice = e.Price;
                        else if (e.MarketDataType == MarketDataType.Last) {
                               if (askPrice > 0 && e.Price >= askPrice) askVol += e.Volume;
                              else if (bidPrice > 0 && e.Price <= bidPrice) bidVol += e.Volume;
                        }    
                    }
            Please feel free to ask me if you are unclear at any points.

            Thanks.
            Pi
            ninZa
            NinjaTrader Ecosystem Vendor - ninZa.co

            Comment


              #21
              Thanks, Pi, for the information. Right now I'm running into a very fundamental problem that I cannot remember how to fix. When I go into 'edit ninjascript' and choose the indicator I just made--which is supposed to be error-free--then hit 'compile', I get around five errors. This isn't right. As a test I opened an indicator that I know works perfectly, looked at the code, made no edits whatsoever, then hit 'compile' just to see what would happen--I get the same five errors. All indicators I open do this.

              Also, the indicator I just made appears in the 'edit ninjascript' but does NOT appear in my indicator list where I pick indicators to place on charts.

              Can someone tell me why this is happening? I know this must be a simple fix, I just need to know what it is.

              Thanks in advance.

              Comment


                #22
                In NT7 , all code must compile.

                You have errors in either this indicator you are working on, or another one.

                Look at the name, and go edit/fix that one (or delete it)

                Comment


                  #23
                  Please double click on the error messages to know which indicators are causing the errors, then fix them.

                  Thanks.
                  Pi
                  ninZa
                  NinjaTrader Ecosystem Vendor - ninZa.co

                  Comment


                    #24
                    Thanks again, this fixed it. The result I'm getting from the indicator is correct, but it shows up in the output window. Is there simple code I can copy to make the result appear directly on the chart, preferably above its appropriate price bar? Thank you.

                    Comment


                      #25
                      Originally posted by imalil View Post
                      Thanks again, this fixed it. The result I'm getting from the indicator is correct, but it shows up in the output window. Is there simple code I can copy to make the result appear directly on the chart, preferably above its appropriate price bar? Thank you.
                      The codes below will display the ask vol at bar top and display the bid vol at bar bottom. Feel free to change it to your preference.

                      Cheers.
                      Pi

                      Code:
                      DrawText("ask vol", AutoScale, askVol.ToString(), 0, High[0], 10, Color.Blue, StringAlignment.Center, Color.Transparent, Color.Transparent, 0);			
                      DrawText("bid vol", AutoScale, bidVol.ToString(), 0, Low[0], -10, Color.Red, StringAlignment.Center, Color.Transparent, Color.Transparent, 0);
                      ninZa
                      NinjaTrader Ecosystem Vendor - ninZa.co

                      Comment


                        #26
                        Thanks for this, but we're not able to get anything to print on the charts. Is there something that was left out? Is there an indicator that has code we can copy and paste? Thanks.

                        Comment


                          #27
                          Originally posted by imalil View Post
                          Thanks for this, but we're not able to get anything to print on the charts. Is there something that was left out? Is there an indicator that has code we can copy and paste? Thanks.
                          You need to set CalculateOnBarClose = false.
                          (you had better put it in OnStartUp()).
                          Last edited by ninZa; 01-29-2015, 01:24 AM.
                          ninZa
                          NinjaTrader Ecosystem Vendor - ninZa.co

                          Comment


                            #28
                            Our indicator works great, and this weekend we're focusing on getting it to print on the charts instead of the output box. This should be the super easy part but we've never done it before and we're not sure of the commands, etc.

                            Is there anything else you can tell me to make the process easier before we dig in and are unable to get timely answers to our questions on this forum? Is there a Ninja indicator from which we can lift code or learn that you recommend? Thank you for all your help.

                            Comment


                              #29
                              Originally posted by imalil View Post

                              Is there anything else you can tell me to make the process easier before we dig in and are unable to get timely answers to our questions on this forum? Is there a Ninja indicator from which we can lift code or learn that you recommend? Thank you for all your help.

                              Well, usually - the first option would be to see something in an indicator that you would want to use, and then look at the code.

                              There is an NT7 indicator download section which should provide more variety/different things than the NT indicators.

                              Comment


                                #30
                                imalil, to get started deeper with the NinjaScript coding aspects, I would recommend stepping through those tutorials, they will cover a lot of the basics.



                                Then there would be also more advanced tips and reference samples available from us under this section - http://www.ninjatrader.com/support/f...splay.php?f=29

                                Generally the point and click strategy wizard interface can also be a powerful assist for getting the syntax right - https://www.ninjatrader.com/support/...egy_wizard.htm

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                651 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