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 NullPointStrategies, Today, 05:17 AM
    0 responses
    53 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    130 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    70 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    44 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X