Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Missing Updates?

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

    Missing Updates?

    Hi,

    I am using the following code to print changes using OnMarketData and it appears as though it is missing some changes, is this expected or is there something wrong with my code?

    Code:
    protected override void OnMarketData(MarketDataEventArgs e)
            {    
                if (e.MarketDataType == MarketDataType.Ask)askPrice     = e.Price; 
                
                if (e.MarketDataType == MarketDataType.Ask)askVol         = e.Volume; 
                    
                if (e.MarketDataType == MarketDataType.Bid)bidPrice     = e.Price;
            
                if (e.MarketDataType == MarketDataType.Bid)bidVol         = e.Volume;
                    
                if (e.MarketDataType == MarketDataType.Last)lastPrice     = e.Price;
                
                if (e.MarketDataType == MarketDataType.Last)lastVol     = e.Volume;
                
                if (e.MarketDataType != MarketDataType.Last)return;
                    
                {
                    if(storeBid != bidPrice)
                    {
                    storeBid = bidPrice;
                    storeBV = bidVol;
                    }
                    
                    else if(storeBid == bidPrice) 
                    {
                    storeBV = bidVol;
                    Print("StoreBV = " + storeBV + " @ " + bidPrice + " Time " + Time[0]);
                    }
                }    
            }
    Regards,
    suprsnipes

    #2
    Can you please clarify why you feel it is missing some updates? How did you determine this?
    MatthewNinjaTrader Product Management

    Comment


      #3
      Hi, thanks for your response,

      I am referring to the changes in (e.MarketDataType == MarketDataType.Bid)bidVol = e.Volume. When I print directlly under this line of code I can see that the prints reflect the current bid correctly but I'm wondering why my code in the original post does not show the current bid, it seems to miss a great number of changes.

      What I am trying to do is store each change in bid volume when the price has not changed could you please let me know how I can fix this or what I may be doing wrong.

      Regards,
      suprsnipes

      Comment


        #4
        I'm sorry I'm not quite following - when I run your code and compare it to the T&S window, I'm getting the current bid price.

        Where are you comparing the current bid when you determine it is not matching?
        MatthewNinjaTrader Product Management

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by andrewtrades, Today, 04:57 PM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by chbruno, Today, 04:10 PM
        0 responses
        3 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Started by josh18955, 03-25-2023, 11:16 AM
        6 responses
        436 views
        0 likes
        Last Post Delerium  
        Started by FAQtrader, Today, 03:35 PM
        0 responses
        7 views
        0 likes
        Last Post FAQtrader  
        Started by rocketman7, Today, 09:41 AM
        5 responses
        19 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X