• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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, 07: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
    http://www.ninjatrader.com/support/h...xtbeginend.htm

    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;
        }

        http://www.ninjatrader.com/support/h...nexecution.htm
        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;
            }
            http://www.ninjatrader.com/support/h...arketdata2.htm

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

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by GMiller64, Today, 01:13 PM
            3 responses
            7 views
            0 likes
            Last Post GMiller64  
            Started by itrader46, Today, 12:51 PM
            4 responses
            32 views
            0 likes
            Last Post itrader46  
            Started by hemlock, Today, 11:45 AM
            3 responses
            9 views
            0 likes
            Last Post NinjaTrader_PatrickG  
            Started by gbulle, Today, 11:31 AM
            2 responses
            7 views
            0 likes
            Last Post gbulle
            by gbulle
             
            Started by JPPoulin, Today, 10:43 AM
            6 responses
            23 views
            0 likes
            Last Post JPPoulin  
            Working...
            X