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

Volume bar timer

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

    Volume bar timer

    I'm plotting volume bars and writing a simple indicator to show the amount of time elapsed from the prev bar to the current bar:

    protectedoverridevoid OnBarUpdate()
    {
    if (CurrentBar < 2)
    return;
    int TimeVar =(ToTime(Time[0]))/100 -(ToTime(Time[1]))/100 ;
    Plot0.Set(TimeVar);
    }

    I divided by 100 because I am not interested in resolution beyond a minute. This works fine unless the previous bar is before an hour rollover, ie bar[1]'s time =11:50 and bar[0]'s time = 12:04. I seem to get a 40 minute offset added to the plot for those bars. I could work around this if I could compare the left two digits of the ToTime values. Is there a way to truncate those values to the left 2 digits?

    #2
    What you could try is use TimeSpan objects instead.
    Code:
    TimeSpan timer = Time[0] - Time[1];
    Plot0.Set((int)timer.Minutes);
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thanks Josh

      That worked first crack out of the bag. Thanks much.

      Max

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by rbeckmann05, Yesterday, 06:48 PM
      1 response
      12 views
      0 likes
      Last Post bltdavid  
      Started by llanqui, Today, 03:53 AM
      0 responses
      6 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by burtoninlondon, Today, 12:38 AM
      0 responses
      10 views
      0 likes
      Last Post burtoninlondon  
      Started by AaronKoRn, Yesterday, 09:49 PM
      0 responses
      15 views
      0 likes
      Last Post AaronKoRn  
      Started by carnitron, Yesterday, 08:42 PM
      0 responses
      11 views
      0 likes
      Last Post carnitron  
      Working...
      X