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

Multi time frame BarsSinceNewTradingDay

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

    Multi time frame BarsSinceNewTradingDay

    I am creating an indicator using multi time frames. I want to access the BarsSinceNewTradingDay for each time series. How do I do that?

    Thanks,
    Dana

    #2
    Hello,

    Thank you for the post.

    It is important to understand that the majority of properties will belong to the series that calls OnBarUpdate in a muilti instrument script.

    In this case when the primary calls OnBarUpdate, you could call BarsSinceNewTradingDay to find out the value for the primary. When the secondary series calls OnBarUpdate, this property now reflects the secondary series.

    Assuming the instruments have different session hours, this can be seen by using the following print:

    Code:
    protected override void OnBarUpdate()
    {
    	Print("BarsInProgress: " + BarsInProgress + " Bars.BarsSinceNewTradingDay: " + Bars.BarsSinceNewTradingDay);
    }
    I am unaware of any way to call this in a cross series case, such as if you wanted the value for the Primary series when BarsInProgress 1 is called. You would instead need to store the last seen value to a variable and then use the private variable from the other BarsInProgress.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      How do I know which series called OnBarUpdate?

      Comment


        #4
        Hello,

        Thank you for the reply.

        In the prior example, this is shown, the BarsInProgress will determine which series called OnBarUpdate. As noted you would need to use two instruments that have different sessions for the example print to differentiate them. BarsInProgress will change in that example, but if the session is the same the BarsSinceNewTradingDay will likely be the same.

        Please let me know if I may be of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Thanks,

          Dana

          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