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

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 algospoke, 04-17-2024, 06:40 PM
      6 responses
      48 views
      0 likes
      Last Post algospoke  
      Started by arvidvanstaey, Today, 02:19 PM
      4 responses
      11 views
      0 likes
      Last Post arvidvanstaey  
      Started by samish18, 04-17-2024, 08:57 AM
      16 responses
      61 views
      0 likes
      Last Post samish18  
      Started by jordanq2, Today, 03:10 PM
      2 responses
      9 views
      0 likes
      Last Post jordanq2  
      Started by traderqz, Today, 12:06 AM
      10 responses
      21 views
      0 likes
      Last Post traderqz  
      Working...
      X