Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Intrabar time

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

    Intrabar time

    Hi,

    Is there any way to find out intrabar time natively?

    E.g., a minute bar 13:01:00 opens at 13:00:00 and closes at 13:00:59.

    Assume there are 5 intra bar ticks in between, occurring at 13:00:10/20/30/40/50

    I would like to find out the time of each tick for both realtime and replay modes.

    P.S. There is a way to calc that for real-time mode by using local time but I would prefer to have a solution that works a) for Replay mode too b) that is more or less native, i.e. involving minimum of code

    Thanks!

    #2
    Originally posted by alex.nt View Post
    Hi,

    Is there any way to find out intrabar time natively?

    E.g., a minute bar 13:01:00 opens at 13:00:00 and closes at 13:00:59.

    Assume there are 5 intra bar ticks in between, occurring at 13:00:10/20/30/40/50

    I would like to find out the time of each tick for both realtime and replay modes.

    P.S. There is a way to calc that for real-time mode by using local time but I would prefer to have a solution that works a) for Replay mode too b) that is more or less native, i.e. involving minimum of code

    Thanks!
    This will create a property called Now, which you can query.
    Code:
    [FONT=Courier New]
    [/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]private[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] DateTime Now
    {
    [/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]get[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] 
    { 
    DateTime now = (Bars.MarketData.Connection.Options.Provider == Cbi.Provider.Replay ? Bars.MarketData.Connection.Now : DateTime.Now); 
    [/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]if[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] (now.Millisecond > [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New])
    now = Cbi.Globals.MinDate.AddSeconds(([/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]long[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]) System.Math.Floor(now.Subtract(Cbi.Globals.MinDate).TotalSeconds));
    [/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]return[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] now;
    }
    }
    [/FONT]

    Comment


      #3
      Good one, thanks!

      Could you please explain the point behind removing milliseconds?

      Comment


        #4
        Originally posted by alex.nt View Post
        Good one, thanks!

        Could you please explain the point behind removing milliseconds?
        By using the Math.Floor() function, we force the granularity to the same as the barData.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        633 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        364 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        567 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        568 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X