Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get current time Hour and Minutes, onEachTick Real, Simulation and Playback

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

    Get current time Hour and Minutes, onEachTick Real, Simulation and Playback

    Hello Devs!

    I have a strategy that runs within the OnBarUpdate method and Calculate OnEachTick. I want to know how to obtain the current time each time the OnBarUpdate is executed. I know that by using DateTime.Now I can get the current time of the machine, which is perfect, but I need an equivalent for when the connection is Playback. I have tried using Time[0], but it only shows the date and time when the current candle will close.

    Any ideas on how to do this?

    #2
    Hello Quanto,

    Thank you for your post.

    Although it is not documented in the help guide, the following code is used in the BarTimer indicator to obtain the current time depending on whether it is playback or not:
    Code:
    now = (Cbi.Connection.PlaybackConnection != null ? Cbi.Connection.PlaybackConnection.Now : Core.Globals.Now);
    If the connection is Playback, the current time would be Cbi.Connection.PlaybackConnection.Now. If you are not in playback, you could use Core.Globals.Now.

    Please let us know if we may be of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    32 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    124 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    64 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    41 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X