Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to Access Time in OnMarketData()

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

    How to Access Time in OnMarketData()

    Hello Ninja staff,

    I have a strategy running on a Renko chart. The Renko chart has a limited timeframe, as defined by the trading hours template. The OnBarUpdate() logic is not being called during the hours that the Renko chart is not printing any new bars. However, OnMarketData() is still being called in the strategy. When I use the ToTime(Time[0]) in OnMarketData(), it is referencing the timestamp of the most recently printed bar of the Renko chart. This is not the current time. How can I access the true current time in OnMarketData(), irrelevant of the bars on the Renko chart?

    Thank you in advance for your reply, I look forward to your response!

    #2
    Hello GLFX005,

    Thank you for your post.

    You could use DateTime.Now to get the current PC clock time. Further information regarding DateTime.Now may be found in Microsoft's publicly available documentation here::

    Gets a DateTime object that is set to the current date and time on this computer, expressed as the local time.


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

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    93 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    138 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    123 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    73 views
    0 likes
    Last Post PaulMohn  
    Working...
    X