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 Hwop38, 05-04-2026, 07:02 PM
      0 responses
      163 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      313 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      245 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      350 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      179 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Working...
      X