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

strategy using two bars series

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

    strategy using two bars series



    Think about a strategy that is using two bar series, main series is 5-minute bars and secondary series is 1-tick bar.

    As far as I understand, OnBarUpdate will be called on each tick of the secondary series, as well as every 5 minutes of the first series. At the moment there is a bar close of the main series, the method will be called twice, first for the 5-minute series and then for the 1-tick series.

    Please correct me if I'm wrong.

    Now the question:

    How often will OnMarketData be called?

    Thanks so much for your help.

    BR
    Juan
    Last edited by NinjaTrader_Gaby; 02-15-2024, 12:47 PM.

    #2
    Hello jzaba1968,

    Thank you for your post.

    I've moved your post into a separate topic as it was unrelated to the previous thread. Please note, any time you reply to a post, this will go to the person you are working with. Reply instead of creating a new post when you would like to continue investigating an existing inquiry.

    Create a new post instead of a reply when you have a new question that is unrelated to a previous inquiry. This will allow us to properly track each issue. Thanks for your cooperation.


    From the Help Guide:

    "Let’s assume we have two series (primary and secondary) in our script, which is representing the same instrument, yet different intervals. During historical data processing, NinjaTrader updates the two series strictly according to their timestamps, calling the primary bar series of the corresponding timestamps first, and then calling the secondary series."



    So yes, per the Help Guide, OnBarUpdate() is called for every bar update event for each Bars object added to the script.




    From the Help Guide on OnMarketData:

    "With multi-time frame and instrument strategies, a subscription will be created on all bars series added in your indicator or strategy strategy (even if the instrument is the same). The market data subscription behavior occurs both in real-time and during TickReplay historical​."



    Please let me know if you have any further questions.
    Gaby V.NinjaTrader Customer Service

    Comment


      #3
      I'll keep in mind to open a new thread when topic changes. Sorry for that.

      Now, going to my question, I don't understand the meaning of "a subscription will be created on all bar series".

      Can you please give me a more detailed explanation on this?

      Thank you
      Juan

      Comment


        #4
        It means a new Bars object is added to BarsArray each time you
        call AddDataSeries -- and each Bars object in BarsArray means
        that OnBarUpdate gets called for that Bars object (as dictated
        by Calculate, which defaults to OnBarClose).

        The idea of a 'subscription' is to mean that you are 'subscribing'
        to a specific data series, which drives the OnBarUpdate events,
        because a data series always has bars associated with it.

        Remember, all data series (aka Bars objects) created via a call
        to AddDataSeries are invisible to your chart, but the bars are still
        created and those bars still generate OnBarUpdate events.

        AddDataSeries is an API for NinjaScript programmers as a way to
        get to (aka 'subscribe to') the bars of an additional data series.

        Just my 2˘.

        Comment


          #5
          Whether the subscription created by AddDataSeries
          includes events that generate calls to OnMarketData,
          well, that depends if you define the OnMarketData
          callback.

          The word 'subscription' is probably being used to
          describe real-time data events that OnMarketData
          is designed to see.

          I see it as a very general way of 'subscribing to data'
          via AddDataSeries, but it also can be used to mean
          something more specific, such as you are 'subscribing
          to real-time data events' when you define OnMarketData.

          -=o=-

          In the help guide, this statement is very telling,

          "Do not leave an unused OnMarketData() method
          declared in your NinjaScript object. This will unnecessarily
          attach a data stream to your strategy which uses
          unnecessary CPU cycles.​"

          The 'attach a data stream' is part of the subscription.

          Make sense?



          Comment


            #6
            Absolutely. Great explanation.

            Thanks so much indeed

            ​​​​​​

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by halgo_boulder, 04-20-2024, 08:44 AM
            2 responses
            21 views
            0 likes
            Last Post halgo_boulder  
            Started by mishhh, 05-25-2010, 08:54 AM
            19 responses
            6,189 views
            0 likes
            Last Post rene69851  
            Started by gwenael, Today, 09:29 AM
            0 responses
            5 views
            0 likes
            Last Post gwenael
            by gwenael
             
            Started by Karado58, 11-26-2012, 02:57 PM
            8 responses
            14,830 views
            0 likes
            Last Post Option Whisperer  
            Started by Option Whisperer, Today, 09:05 AM
            0 responses
            2 views
            0 likes
            Last Post Option Whisperer  
            Working...
            X