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

reset variable by time

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

    reset variable by time

    Hello everyone, help to reset variable by time

    using the code for day reset:

    if (Bars.IsFirstBarOfSession)
    {
    Reset_Volume = 0;
    }

    How to make the variable reset, for example, every 60 minutes.

    Specific example with syntax

    #2
    You can use ToTime(Times[0][0]) to track and set condition on it.
    ** ToTime(Times[0][0]) is just a guide for you, you can explore more about it.

    Comment


      #3
      Hi memonolog,
      if (Times[1][0].Hour != Times[1][1].Hour)
      {
      Do something // Provides updates at the turn of the FULL hour (03.00, 04.00, 05.00).
      }
      Watch-out If trading hours do not start at the full hour (e.g. 2.15 a.m for FDAX), you will have to use/add a data series small enough to ensure one bar ends at the FULL hour (e.g. 1 min, 5 min, 15 min) and then apply the above code to that time series, if you wanted to grab some data points at the turn of the full hour.
      NT-Roland

      Comment


        #4
        Originally posted by cincai View Post
        You can use ToTime(Times[0][0]) to track and set condition on it.
        ** ToTime(Times[0][0]) is just a guide for you, you can explore more about it.
        Hi memonolog,
        if (Times[1][0].Hour != Times[1][1].Hour)
        {
        Do something // Provides updates at the turn of the FULL hour (03.00, 04.00, 05.00).
        }
        Watch-out If trading hours do not start at the full hour (e.g. 2.15 a.m for FDAX), you will have to use/add a data series small enough to ensure one bar ends at the FULL hour (e.g. 1 min, 5 min, 15 min) and then apply the above code to that time series, if you wanted to grab some data points at the turn of the full hour.
        NT-Roland
        Thank you friends I will try your options

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by GwFutures1988, Today, 02:48 PM
        0 responses
        1 view
        0 likes
        Last Post GwFutures1988  
        Started by mmenigma, Today, 02:22 PM
        1 response
        3 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by frankthearm, Today, 09:08 AM
        9 responses
        35 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by NRITV, Today, 01:15 PM
        2 responses
        9 views
        0 likes
        Last Post NRITV
        by NRITV
         
        Started by maybeimnotrader, Yesterday, 05:46 PM
        5 responses
        28 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X