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

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.
    Kate W.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by pibrew, Today, 06:37 AM
    0 responses
    0 views
    0 likes
    Last Post pibrew
    by pibrew
     
    Started by rbeckmann05, Yesterday, 06:48 PM
    1 response
    12 views
    0 likes
    Last Post bltdavid  
    Started by llanqui, Today, 03:53 AM
    0 responses
    6 views
    0 likes
    Last Post llanqui
    by llanqui
     
    Started by burtoninlondon, Today, 12:38 AM
    0 responses
    10 views
    0 likes
    Last Post burtoninlondon  
    Started by AaronKoRn, Yesterday, 09:49 PM
    0 responses
    15 views
    0 likes
    Last Post AaronKoRn  
    Working...
    X