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

Last TimeStamp Of Session?

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

    Last TimeStamp Of Session?

    I'm interested in code that will figure out the last timestamp of the session. At the absolute last second of the session it will look for the last timestamp using the OnMarketData method.
    Let's say the session ends at 14:00. Then at 13:59:59 it executes. I will be a simple loop that checks if there's a timestamp at a particular time value, if there is, the variable lasttimestamp is assigned that value, otherwise it checks for the next last second, on, and on, until it finds one. I understand the logic, but I'm not sure about the syntax.
    Last edited by Srgtroy; 08-09-2012, 08:06 AM.

    #2
    Hello Srgtroy,
    You can use the GetNextbeginEnd method to get the session start and end time. Please refer to our help guide to know more about it


    You can further custom code it to suit your need.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      This give me the "official" beginning and end times of a session, no? Not when the last trade actually executed.

      Comment


        #4
        Hello Srgtroy,
        Thanks for the clarification.

        You can simply get/store the value from the OnExecution event. A sample code will be like:

        in variable
        Code:
        DateTime lastTrade;
        in OnExecution event
        Code:
        protected override void OnExecution(IExecution execution)
        {
        	lastTrade = execution.Time;
        }

        JoydeepNinjaTrader Customer Service

        Comment


          #5
          I think you misunderstand me. I'm not executing anything. I want the timestamp of the absolute last trade in a bar. Not my trade. Anyone's trade. The absolute last trade. The way ninja works, minute bars always end at 00. But this is not necessarily when the actual last trade occurred. That is what I am trying to determine and access!

          Comment


            #6
            Hello
            You can then use the OnMarketData event to get the time. A sample code will be
            Code:
            protected override void OnMarketData(MarketDataEventArgs e)
            {
            	if (e.MarketDataType == MarketDataType.Last)
            		lastTrade = e.Time;
            }


            Please let me know if I can assist you any further.
            JoydeepNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by devatechnologies, 04-14-2024, 02:58 PM
            3 responses
            19 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by tkaboris, Today, 08:01 AM
            0 responses
            3 views
            0 likes
            Last Post tkaboris  
            Started by BarzTrading, Today, 07:25 AM
            2 responses
            12 views
            1 like
            Last Post BarzTrading  
            Started by EB Worx, 04-04-2023, 02:34 AM
            7 responses
            161 views
            0 likes
            Last Post VFI26
            by VFI26
             
            Started by Mizzouman1, Today, 07:35 AM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X