Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Duration of a Volume Bar

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

    Duration of a Volume Bar

    Hello

    I'm trying to include the duration of a volume bar in my custom strategy.
    I've looked into the "time" function, but it seems to only return timestamp values of bars.
    What I'd like to do is to get the duration (in seconds) of a Volume Bar, but I'm at a loss regarding the right syntax and the correct use of the time function:

    if (time Close[0] - time Open[0] < x seconds
    {
    BarDuration= true;
    }
    else
    {
    BarDuration= false;
    }

    I'd very much appreciate if someone could point me in the right direction.

    Thanks & Regards

    #2
    Hi laocoon,

    There is a similar forum post at...


    Which uses the following to calculate bar time length...

    TimeSpan time1 = Time[0] - new DateTime(1970,1,1,0,0,0);
    TimeSpan time2 = Time[1] - new DateTime(1970,1,1,0,0,0);
    int diff=(int)time1.TotalSeconds-(int)time2.TotalSeconds;
    TimNinjaTrader Customer Service

    Comment


      #3
      Hi Tim

      Sorry for the (very) late reply, but this is exactly what I was looking for.

      Thanks a lot.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      574 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      332 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      553 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X