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 judysamnt7, 03-13-2023, 09:11 AM
        4 responses
        57 views
        0 likes
        Last Post DynamicTest  
        Started by ScottWalsh, Today, 06:52 PM
        4 responses
        36 views
        0 likes
        Last Post ScottWalsh  
        Started by olisav57, Today, 07:39 PM
        0 responses
        7 views
        0 likes
        Last Post olisav57  
        Started by trilliantrader, Today, 03:01 PM
        2 responses
        20 views
        0 likes
        Last Post helpwanted  
        Started by cre8able, Today, 07:24 PM
        0 responses
        9 views
        0 likes
        Last Post cre8able  
        Working...
        X