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

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.

    BertrandNinjaTrader Customer Service

    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 judysamnt7, 03-13-2023, 09:11 AM
        4 responses
        59 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
        21 views
        0 likes
        Last Post helpwanted  
        Started by cre8able, Today, 07:24 PM
        0 responses
        10 views
        0 likes
        Last Post cre8able  
        Working...
        X