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

Syncing OnMarketData with OnMarketDepth

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

    Syncing OnMarketData with OnMarketDepth

    Hi,

    I am trying to build a data model where I can see the following for a new price level created in the inside bid / ask once the price moves into the new price level:

    1. Starting volume
    2. Total Transacted volume
    3. Ending Volume

    I can pick up the starting volume and ending volume from OnMarketDepth with something like.

    if (marketDepthUpdate.MarketDataType == MarketDataType.Ask &&( marketDepthUpdate.Operation == Operation.Update || marketDepthUpdate.Operation == Operation.Add)&& GetCurrentAsk() == marketDepthUpdate.Price)

    Then I can filter for price level changes by setting a variable to the old GetCurrentAsk() and when the new GetCurrentAsk() != to my variable I know that the price level has changed.

    For the transacted volume: I can run something like this from OnMarketData:

    if (marketDataUpdate.MarketDataType == MarketDataType.Last)
    {
    if (marketDataUpdate.Price >= marketDataUpdate.Ask)
    {
    Print( "Transacted Volume" + marketDataUpdate.Volume);

    }

    This is just some flavor of: https://ninjatrader.com/support/help...marketdata.htm

    Both of these methods work fairly well independently and give me the data that I need. However they are not in sync together as far as the timing. For example, when the OnMarketDepth event handler is switching from price level x to price level y, the OnMarketData event handler is more often than not lagging and still stuck on price level x.

    So getting these two to sync up is a bit of a challenge. I am sure I am not the first guy out there trying to get information from both event handlers at the same time concerning the same price level event. After searching this forum, I haven't found any information on this topic, so I figured I would post the question.

    Can someone from NT point me toward the best practice for how someone can get data for a single bid or ask price from these two event handlers in sync?

    Thanks,

    Ian

    #2
    Hello iantg,

    Thanks for your question.

    I'll work on a demonstration script for this task, and I'll update this post when it is prepared.

    Please allow a few days for me to work on this item. Thanks in advance for your patience.
    JimNinjaTrader Customer Service

    Comment


      #3
      Hi Jim,

      Thanks for offering to help me on this. I have built a few methods that kind of sort of work, but I just keep getting out of sequence somehow, so any help you can provide would be greatly appreciated.

      Thanks,

      Ian


      Originally posted by NinjaTrader_Jim View Post
      Hello iantg,

      Thanks for your question.

      I'll work on a demonstration script for this task, and I'll update this post when it is prepared.

      Please allow a few days for me to work on this item. Thanks in advance for your patience.

      Comment


        #4
        Hello iantg,

        I have had a discussion with Product Management on this particular item. They had informed me that there is not a guarantee of the sequence of events between OnMarketData and OnMarketDepth, so you will want to use one or the other depending on your requirements.

        If there is another matter you would like us to look into, I'll be more than happy to assist you further.
        Last edited by NinjaTrader_Brett; 03-19-2018, 03:53 PM.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Aviram Y, Today, 05:29 AM
        0 responses
        1 view
        0 likes
        Last Post Aviram Y  
        Started by quantismo, 04-17-2024, 05:13 PM
        3 responses
        25 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by ScottWalsh, 04-16-2024, 04:29 PM
        7 responses
        34 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by cls71, Today, 04:45 AM
        0 responses
        6 views
        0 likes
        Last Post cls71
        by cls71
         
        Started by mjairg, 07-20-2023, 11:57 PM
        3 responses
        216 views
        1 like
        Last Post PaulMohn  
        Working...
        X