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 Irukandji, Today, 04:58 AM
          0 responses
          2 views
          0 likes
          Last Post Irukandji  
          Started by fitspressoburnfat, Today, 04:25 AM
          0 responses
          2 views
          0 likes
          Last Post fitspressoburnfat  
          Started by Skifree, Today, 03:41 AM
          1 response
          4 views
          0 likes
          Last Post Skifree
          by Skifree
           
          Started by usazencort, Today, 01:16 AM
          0 responses
          1 view
          0 likes
          Last Post usazencort  
          Started by kaywai, 09-01-2023, 08:44 PM
          5 responses
          604 views
          0 likes
          Last Post NinjaTrader_Jason  
          Working...
          X