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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        567 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        330 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        548 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        548 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X