Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi-time frame when BarsInProgress do not overlap

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

    Multi-time frame when BarsInProgress do not overlap

    Primary data series: 60min
    AddDataSeries: 15min

    I have code that should execute on BarsInProgress == 0
    and code that should execute on BarsInProgress ==1 unless the the 60minute bar is closing.

    In theory this means execute on 3 consecutive 15min bars within the 60min bar and then skip one 15min bar.
    but have to initiate the timing and align it regularly to ensure its acurate.
    What can i use to achieve this in code?
    thanks


    #2
    Hello madb123,

    You would need to use a variable and logic for that. If the timeframe will always be the same you could use a counter and count 3 bars on the secondary series and set a variable each time that is called. if the count is 3 the next time that logic is called you would no execute your code and instead reset the counter on that pass. If the timeframes will be variable that will make the problem more complex.

    Comment


      #3
      fixed to these time frames only for understanding the solution for now.
      so:

      if(BarsInProgress ==1)
      if( i !=3 )
      {i++ and do stuff}
      else i = 0;

      but the problem with this is i am unable to check that they are in sync. Are they going to be always in sync regardless of changes in market open or close or daylight savings?


      Comment


        #4
        Hello madb123,

        There is a specific order of processing in NinjaScript so that should stay in sync as long as there are always many 15 minute bars. You would have to test to make sure that works with the instrument being used. You could also use the series Time to make time conditions if that does not work as you wanted.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        111 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        59 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        38 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        41 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        78 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X