Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Where did the volume go?

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

    Where did the volume go?

    The screenshot is of 100t chart, which means that both red (DownCount) and green (UpCount) bars should add up to 100 (or close to it). Yet, today (I've been using the indicator for a few weeks) there are spots where buy and sell volume is not detected. Today is also the first time I'm connected to three different accounts (two Rithmic and one Ninja Live), if that makes a difference.

    TLDR: why marketDataUpdate.Price >= marketDataUpdate.Ask and marketDataUpdate.Price <= marketDataUpdate.Bid are not picking up all the volume?

    Click image for larger version

Name:	image.png
Views:	145
Size:	2.6 KB
ID:	1342372

    My code that detects buy and sell ticks:
    PHP Code:
            protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
            {
                if (marketDataUpdate.MarketDataType != MarketDataType.Last)
                    return;
    
                if (marketDataUpdate.Price >= marketDataUpdate.Ask)
                {
                    UpCount = UpCount + 1;
                }
                else if (marketDataUpdate.Price <= marketDataUpdate.Bid)
                {
                    DownCount = DownCount + 1;
                }
                
                TotalCount = UpCount + DownCount;
                
    
            }&#8203; 
    

    #2
    Hello MiCe1999,

    The code you have shown is intended to be used with tick replay, are you using tick replay? If so that won't show all of the ask and bid volume, that only will be the ask and bid at the time of the last event which excludes most ask and bid events.

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello MiCe1999,

      The code you have shown is intended to be used with tick replay, are you using tick replay? If so that won't show all of the ask and bid volume, that only will be the ask and bid at the time of the last event which excludes most ask and bid events.
      Hi Jesse. The indicator is processing live market data, updating on each tick. Should I be using 1t secondary data series?

      protected override void OnBarUpdate()
      {
      if(State == State.Historical)
      return;​

      Comment


        #4
        Hello MiCe1999,

        In realtime you would use different code for that, the code you are using is specifically used for historical processing while using tick replay. If you don't want to use historical processing you can skip to the link at the bottom of this reply. If you do want to use historical processing I would suggest looking at how the OnMarketData override is used in the VolumeProfile indicator, that separates the tick replay logic and realtime logic. To do both you need a condition:

        if (Bars.IsTickReplay)
        {

        }
        else
        {

        }

        The else would be where the normal realtime OnMarketData logic goes. You can see a sample of filtering the realtime events in the following page. That will give you the full granularity of the incoming data events to drive your logic in realtime.

        Comment


          #5
          Ok, implemented bid/ask volume counting as described in Volume Profile indicator...and the result is exactly* the same as my original code. After few fours of debugging I figured out what my problem is: today I added a tab to the window. When I switch to the other tab, OnMarketData does not update for the tab that is not active! Is there a way to keep it updating?

          EDIT: * to within a few ticks.

          I figured it out: IsSuspendedWhileInactive​ was set to true. Anyhow, thanks for pointing out the proper bid/ask accounting.
          Last edited by MiCe1999; 05-06-2025, 11:58 AM.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          558 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          324 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          545 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X