Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnMarketData

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

    OnMarketData

    I am trying to understand how to extract bid and ask volume data.

    Here is what I am trying to do :


    Code:
    protected override void OnMarketData(MarketDataEventArgs e)
    {			
    			
        if ((e.MarketDataType == MarketDataType.Ask))
        {
    				
                  int vol;
                  if(AskOrderBook.TryGetValue(time, out vol))
                 {
    	    vol += e.Volume;
                  }
                  else
    	          AskOrderBook.Add(time, e.Volume);
    				
    			
    	}			
    	else
    	if ((e.MarketDataType == MarketDataType.Bid))
    	{
    	      int vol;
    	       if(BidOrderBook.TryGetValue(time, out vol))
    	       {
    		vol += e.Volume;
    	        }
    	        else
    	        BidOrderBook.Add(time, adjvolume);
    
    	}	
    }
    The problem is that I am counting the volume twice.
    For example 19 volume on bid.

    When I print the result on the output windown I get :
    19
    19
    added to the the BidOrderBook !
    Last edited by blar58; 11-30-2015, 07:19 AM.

    #2
    Originally posted by blar58 View Post
    I am trying to understand how to extract bid and ask volume data.

    The problem is that I am counting the volume twice.
    For example 19 volume on bid.

    When I print the result on the output windown I get :
    19
    19
    added to the the BidOrderBook !
    In the OnMarketData you are computing the BestAsk and BestBid prices.

    However in the OnMarketDepth are computed the AskOrderBook[0] and BidOrderBook[0] prices. This data must match with BestAsk y BestBid received before or after (unfortunately the order is unpredictable) by OnMarketData method.

    They are the same repeated data. This is the reason why you see duplicated them ((I guess you add the same data inside OnMarketDepth method).
    Last edited by cls71; 11-30-2015, 12:14 PM.

    Comment


      #3
      cls71 is correct -- I would recommend trying to capture market depth data in OnMarketDepth() rather than OnMarketData(). If you continue to see the same issue, can you please provide a complete sample script which will reproduce the issue, so that I can investigate further into exactly how your code is structured?
      Dave I.NinjaTrader Product Management

      Comment


        #4
        Thank you guys,


        I will rework this with On Market Depth !

        Will post my results

        Thanks !

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        672 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        379 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        111 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        575 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        582 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X