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

High/Low of custom time period

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

    High/Low of custom time period

    Dear support,

    I have an indicator that calculates and plots high/low starting at time A all the way until time B. It works great as long as both time points are in the same day. Once A is 11 PM and B is 1 AM of the other day, Ninja thinks that I'm traveling backwards and that 1 AM is meant to be at the very same day as the first point and plots nothing. Would you please assist? How to tell Ninja that point B is actually the day after?

    Code:
    if((ToTime(Time[0]) >= time_from) && (ToTime(Time[0]) <= time_to)) {
                    if(High[0] > new_high)     new_high = High[0];
                    if(Low[0] < new_low)    new_low = Low[0];
                    }
    Thanks!

    #2
    Originally posted by pepino31 View Post
    Dear support,

    I have an indicator that calculates and plots high/low starting at time A all the way until time B. It works great as long as both time points are in the same day. Once A is 11 PM and B is 1 AM of the other day, Ninja thinks that I'm traveling backwards and that 1 AM is meant to be at the very same day as the first point and plots nothing. Would you please assist? How to tell Ninja that point B is actually the day after?

    Code:
    if((ToTime(Time[0]) >= time_from) && (ToTime(Time[0]) <= time_to)) {
                    if(High[0] > new_high)     new_high = High[0];
                    if(Low[0] < new_low)    new_low = Low[0];
                    }
    Thanks!
    Use the c# Time class itself, and instead of start and end time, use start time and interval length, so that end time is start time plus interval length. That way you get the correct date and time.

    Comment


      #3
      Hello pepino31,
      If you try the below code then are you able to get the correct values.

      Code:
      if ((ToTime(Time[0]) >= 110000 && ToTime(Time[0]) <= 24000) || (ToTime(Time[0]) >= 0 && ToTime(Time[0]) <= 10000))
      {
         //do something
      }
      JoydeepNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Kaledus, Today, 01:29 PM
      0 responses
      3 views
      0 likes
      Last Post Kaledus
      by Kaledus
       
      Started by PaulMohn, Today, 12:36 PM
      1 response
      16 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by yertle, Yesterday, 08:38 AM
      8 responses
      37 views
      0 likes
      Last Post ryjoga
      by ryjoga
       
      Started by rdtdale, Today, 01:02 PM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by alifarahani, Today, 09:40 AM
      3 responses
      19 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X