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 cre8able, Yesterday, 01:16 PM
    3 responses
    11 views
    0 likes
    Last Post cre8able  
    Started by ChartTourist, Today, 08:22 AM
    0 responses
    5 views
    0 likes
    Last Post ChartTourist  
    Started by LiamTwine, Today, 08:10 AM
    0 responses
    2 views
    0 likes
    Last Post LiamTwine  
    Started by Balage0922, Today, 07:38 AM
    0 responses
    5 views
    0 likes
    Last Post Balage0922  
    Started by JoMoon2024, Today, 06:56 AM
    0 responses
    6 views
    0 likes
    Last Post JoMoon2024  
    Working...
    X