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 AttiM, 02-14-2024, 05:20 PM
        12 responses
        213 views
        0 likes
        Last Post DrakeiJosh  
        Started by cre8able, 02-11-2023, 05:43 PM
        3 responses
        237 views
        0 likes
        Last Post rhubear
        by rhubear
         
        Started by frslvr, 04-11-2024, 07:26 AM
        8 responses
        116 views
        1 like
        Last Post NinjaTrader_BrandonH  
        Started by stafe, 04-15-2024, 08:34 PM
        10 responses
        47 views
        0 likes
        Last Post stafe
        by stafe
         
        Started by rocketman7, Today, 09:41 AM
        3 responses
        11 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X