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

Session Start Time

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

    Session Start Time

    I am looking for the equivilant to TradeStation's Sess1StartTime reserve word. What is the best method to find the session start time in NinjaTrader?

    #2
    Hello,

    Thank you for your note.

    I am not familiar with TS, however try this:

    Use FirstBarOfSession:


    Then use Time[0] to get the time.
    DenNinjaTrader Customer Service

    Comment


      #3
      How to use FirstBarOfSession

      How can we test FirstBarOfSession in the simulated data feed environment ? Here I always get False.

      If I use Time[0], then it is giving the system time than the session start time.

      If we want to get a specific session like, 1st session or 2nd session how can I achieve the same in NT. In Tradestation we have the functions like SessionStartTime(1,2) means, the second session's start time.

      Comment


        #4
        Hello,

        Yes, the simulated data feed doesn't have sessions. Try connecting to another data feed so the session times will work.

        >>If I use Time[0], then it is giving the system time than the session start time.

        I am sorry I don't understand the above statement. As soon as you get to the first bar of the session Time[0] return the time of the first tick of the first bar of the session, which is what I thought you wanted. You could also use Open[0] of that bar.

        It sounds like you are trying to find the session begin times retroactively. For this you may need to loop backward with a "for" loop through the bars until FirstBarOfSession returns true then use the for loop index like this Open[i] (where "i" is your for loop index) to find the time for that bar and the start of that session. I'm not aware of any easier way. However I will have someone double check this for you.
        DenNinjaTrader Customer Service

        Comment


          #5
          You could also use SessionBreak and store the time stamp then if it returns true - http://www.ninjatrader-support.com/H...sionBreak.html

          Generally sessions can be set from the 'Chart Properties' - http://www.ninjatrader-support.com/H...roperties.html
          BertrandNinjaTrader Customer Service

          Comment


            #6
            Thank you !

            Thank you for the suggestions. I believe Bars.GetSessionBar(1) will give the first bar in the 2nd session information. I am getting the time of Bars.GetSessionBar(1).Time if (Bars.GetSessionBar(1) != null).

            Is this code has any problems to access individual session begin times ?

            Comment


              #7
              Hi Kirannarik, unfortunately this is not supported - you will need debug your custom code and make sure it works as expected, for proper debugging techniques please review this tip - http://www.ninjatrader-support2.com/...ead.php?t=3418
              BertrandNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by usazencort, Today, 01:16 AM
              0 responses
              1 view
              0 likes
              Last Post usazencort  
              Started by kaywai, 09-01-2023, 08:44 PM
              5 responses
              603 views
              0 likes
              Last Post NinjaTrader_Jason  
              Started by xiinteractive, 04-09-2024, 08:08 AM
              6 responses
              23 views
              0 likes
              Last Post xiinteractive  
              Started by Pattontje, Yesterday, 02:10 PM
              2 responses
              22 views
              0 likes
              Last Post Pattontje  
              Started by flybuzz, 04-21-2024, 04:07 PM
              17 responses
              230 views
              0 likes
              Last Post TradingLoss  
              Working...
              X