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

Count Bars on MultiTimeframe

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

    Count Bars on MultiTimeframe

    Hello Dear Friends.
    I have two DateTime value.

    DateTime dateStartTime, dateEndTime.

    On chart open Time Frame Minute 1.

    How I can get count bars range intDeltaBarsFromM5Chart = ???(dateStartTime - dateEndTime) from the chart period Minute 5, Minute 10 and Minute 60 in the indicator?

    Thank you very much.

    #2
    Hello _Roman,

    Thank you for your post.

    If I'm understanding you correctly, you are looking to find out how many bars of each of your additional data series (5 minute, 10 minute and 60 minute) were timestamped between the dateStartTime and the dateEndTime. Is that correct?

    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Kate View Post
      Hello _Roman,
      Is that correct?
      Yes, of course.

      Comment


        #4
        Hello _Roman,

        Thank you for your reply.

        The simplest way would be to set up a time condition in OnBarUpdate() so that if the time is between dateStartTime and dateEndTime that we can then assess which Bars are in progress, and then increment a count variable each time a bar is processed that is timestamped in that period. Once you're outside of that time period, you could then use those counters to see how many bars were processed.

        So, you could start with something like this:

        Code:
                    if ((Times[0][0].TimeOfDay >= DateStartTime.TimeOfDay)
                         && (Times[0][0].TimeOfDay == DateEndTime.TimeOfDay) && BarsInProgress == 1)
                    {
                        Minute5Count++;
                    }
        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Thank you Kate.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by WHICKED, Today, 12:45 PM
          0 responses
          1 view
          0 likes
          Last Post WHICKED
          by WHICKED
           
          Started by FrazMann, Today, 11:21 AM
          2 responses
          6 views
          0 likes
          Last Post NinjaTrader_ChristopherJ  
          Started by rjbtrade1, 11-30-2023, 04:38 PM
          2 responses
          80 views
          0 likes
          Last Post DavidHP
          by DavidHP
           
          Started by Spiderbird, Today, 12:15 PM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_ChristopherJ  
          Started by lorem, Yesterday, 09:18 AM
          5 responses
          18 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X