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 set Session Start & Session End via strategy parameters?

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

    #16
    Originally posted by NinjaTrader_Joydeep View Post
    Hello 35trader,

    To assist you further may I know,
    1. What code you are using
    2. What results you are getting
    3. What result you are expecting.

    I look forward to assisting you further.
    1. I'm using the code you posted at 7:40 am
    2. At that time (7:45 am) I was getting a session time printing in the out box saying 9:30 to 4:00 and this is correct as that was the session I choose.
    3. Its not what I'm expecting, its a question:

    At 7:45 am it kept posting new session time lines constantly saying 9:30 to 4:00 but yet its only 7:45 am so as I asked is there a internal system checking the time? and when 9:30 does come in real time, it then knows session is open? if so can you control this checking process by a time function or what ever?

    Comment


      #17
      Hello 35trader,
      The prints you are witnessing is being generated by the historical bars.

      Can you get the prints if you use the below code
      Code:
      protected override void OnBarUpdate()
      {
      [B]if (Historical) return;[/B]
      DateTime sd;
      DateTime ed;
      Bars.Session.GetNextBeginEnd(Bars, 0, out sd, out ed);
      Print("Start Date = " + sd.ToString("HH:mm:ss") + " End Date= "   + ed.ToString("HH:mm:ss"));
      }
      To know when the actual session has opened you have to use the code FirstBarOfSession
      Please refer to our help guide to know more on it


      Code:
      if (Bars.FirstBarOfSession && FirstTickOfBar)
      	Print("Session started");
      Please let me know if I can assist you any further.
      JoydeepNinjaTrader Customer Service

      Comment


        #18
        Sorry, perhaps I did not express myself properly.

        What I mean was how can I utilize the functionality of Exit On Close and Exit On Close Seconds parameters of a strategy for any given Session Close Time?

        E.g. I would like to trade certain symbol from 10AM till 2PM. I also would like to have Exit On Close (= TRUE) and Exit On Close Seconds (= 30 seconds) functionality for this time frame so if I have an open position then it should start closing right after 1:59:30.

        Is it possible?

        Comment


          #19
          Exit On Close will work from the session template you are using on the chart or the strategy.

          For example if you use the US Equities RTH session template, exit on close would operate within X number of seconds to the US Equities close at 2:00PM.

          Code:
          protected override void Initialize()
          {
              // this code would trigger the exit within 30 seconds of the session template end time
              ExitOnClose = true;
              ExitOnCloseSeconds = 30;
          }
          MatthewNinjaTrader Product Management

          Comment


            #20
            In the Data series parameters, it is using a Session Template from the Session Manager so to help applications run best. Yepi......!

            Comment


              #21
              Originally posted by gameslove57 View Post
              In the Data series parameters, it is using a Session Template from the Session Manager so to help applications run best. Yepi......!
              These spammers are almost understanding NT. Thats kind of scary!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by kempotrader, Today, 08:56 AM
              0 responses
              7 views
              0 likes
              Last Post kempotrader  
              Started by kempotrader, Today, 08:54 AM
              0 responses
              4 views
              0 likes
              Last Post kempotrader  
              Started by mmenigma, Today, 08:54 AM
              0 responses
              2 views
              0 likes
              Last Post mmenigma  
              Started by halgo_boulder, Today, 08:44 AM
              0 responses
              1 view
              0 likes
              Last Post halgo_boulder  
              Started by drewski1980, Today, 08:24 AM
              0 responses
              4 views
              0 likes
              Last Post drewski1980  
              Working...
              X