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 info from NinjaScript

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

    Session info from NinjaScript

    Hello,

    Can I access the actual session begin and start time through NinjaScript code

    I know I can get these from Session.GetNextBeginEnd but I would like to this information on start up and only once. In reality I would like to get the info about opening and ending session time from the Session Manager through code.

    Is is possible ?



    Thanks

    #2
    Hello blar58,

    There would not be a supported method to return a the Session Time beside the GetNextBeginEnd. You may use the OnStartUp() method and check for the Session TemplateName to be able to define a template hours only once inside of NinjaScript.
    JCNinjaTrader Customer Service

    Comment


      #3
      Thank you very much for your answer even if it is unsupported.

      How do I get to TemplateName property.
      I tried Session.TemplateName ... not working.

      What is the method I need to use

      Many thanks...

      Comment


        #4
        Hello blar58,

        Code:
        Print("Session Template Name is: "+Bars.Session.TemplateName);
        The bolded TemplateName is a link to our Help Guide from my previous post, or you may click on the following link to our Help Guide that will give you an example of this as well.
        JCNinjaTrader Customer Service

        Comment


          #5
          I can get the Session name but how do I access the different session properties
          like day start time end time etc ....

          Comment


            #6
            Hello blar58,

            That would be something that would have to setup after checking the TemplateName. The TemplateName is a supported method and can be used to help show which Session Template is being used. For Example:

            Code:
            #Variable
            private DateTime sessionBegin;
            private DateTime sessionEnd;
            
            protected override void OnStartUp()
            {
                    if(Bars.Session.TemplateName == "CME US Index Futures RTH")
                    {
                             sessionBegin = new DateTime(DateTime.Today.Year,DateTime.Today.Month, DateTime.Today.Day, 8, 30,00 );
                             sessionEnd = new DateTime(DateTime.Today.Year,DateTime.Today.Month, DateTime.Today.Day, 15, 15,00 );
                    }
            }
            JCNinjaTrader Customer Service

            Comment


              #7
              Hello JC,

              Thank you for trying to help but I am looking for is GETTING the session info from the session template used ( session begin and end time ) and not setting it.

              Comment


                #8
                Hello blar58,

                The only supported method to get times for the Session Template would be to use the "Bars.Session.GetNextBeginEnd" like you have been using. What values would you like to be seeing when you get the session template on the startup of a NinjaScript so that I can submit a suggestion to our Development team?
                JCNinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by blar58 View Post
                  Hello JC,

                  Thank you for trying to help but I am looking for is GETTING the session info from the session template used ( session begin and end time ) and not setting it.
                  GetNextBeginEnd() is for getting those values. You simply need to declare variables to hold the values and make sure that that method passes to the variables by reference, per the method signature.
                  Last edited by koganam; 03-15-2013, 11:11 AM.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by futtrader, 04-21-2024, 01:50 AM
                  4 responses
                  41 views
                  0 likes
                  Last Post futtrader  
                  Started by Option Whisperer, Today, 09:55 AM
                  1 response
                  11 views
                  0 likes
                  Last Post bltdavid  
                  Started by port119, Today, 02:43 PM
                  0 responses
                  3 views
                  0 likes
                  Last Post port119
                  by port119
                   
                  Started by Philippe56140, Today, 02:35 PM
                  0 responses
                  4 views
                  0 likes
                  Last Post Philippe56140  
                  Started by 00nevest, Today, 02:27 PM
                  0 responses
                  2 views
                  0 likes
                  Last Post 00nevest  
                  Working...
                  X