Announcement

Collapse
No announcement yet.

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 CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      175 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      91 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      130 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      210 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      186 views
      0 likes
      Last Post CarlTrading  
      Working...
      X