Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnMarketData - multi time stamp

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

    OnMarketData - multi time stamp

    Hi there,

    I believe I know the answer to this (because I just ran a small test)... but I wanted to repeat my thoughts, and get a nod from the NT guys, make sure I'm not missing anything.

    - I add multiple symbols/timeframes in my strategy... sometimes, I even add the same symbol multiple times. (I do this in case I start tracking multiple positions in the same stock, but at different starting points.)

    Add("GOOG", PeriodType.Minute, 30); // barsinprogress = 1
    Add("GOOG", PeriodType.Minute, 30); // barsinprogress = 2

    - OnBarUpdate() is called for every bar. In the above case, barsinprogress = 1 and 2 on 30.

    - All of the other order events all track correctly to the barsinprogress it belongs to. (Really impressive how well/cleanly that works, guys.)

    - Now here's the question/tricky part. It looks to me like OnMarketData() does *not* work this way. I only get one OnMarketData() call per *symbol*, regardless of the number of times it's added in the strategy.

    The barsinprogress value that comes back is = the first bar with matching symbol.

    I can see why the behavior would look like that, and I think I can work around it. I just wanted to make sure I wasn't missing anything
    Last edited by heech; 03-13-2009, 11:11 AM.

    #2
    Hi heech, your understanding is correct - OnMarketData is called for each unique instrument in the strategy. You can use the BarsInProgress check to filter which one you want to access for your logic.

    Comment


      #3
      If the instrument is the same, but different time period, then OnMarketData is called with BarsInProgress == 0 every time for every instrument you've added.

      Using ES 5 minute as the primary

      in the Initialize method, you add a 1 minute period, then OnMarketData gets called twice, one time for each instrument, but BarsInProgress is always 0, because it matches the first instrument. OnMarketData is not time specific, it is data specific, so when it finds a match, it returns BarsInProgress of 0.


      Only way to fix it (that I know of) is to have a counter and mod it with the BarsArray.Length and ignore anything above 0.

      Comment


        #4
        Thank you for your note -- that is definitely a good point to make about adding multiple data series of the same instrument. Thanks for sharing your solution, as well.
        Dave I.NinjaTrader Product Management

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        77 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        40 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        63 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        63 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        53 views
        0 likes
        Last Post CarlTrading  
        Working...
        X