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

sometimes get a wrong end of session with SessionIterator

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

    sometimes get a wrong end of session with SessionIterator

    I am using the SessionIterator to calculate the 5 min before end of session.

    sessionIterator.ActualSessionEnd.TimeOfDay.Subtrac t(new TimeSpan(00, 05, 00))

    most of the time it work but sometimes I suddenly get an end of session even BEFORE the actual time. and consequently my position is closed. immediately following this event the strategy is recalculating itself as this is a new session and it goes on to trade "a new day"

    I attached the skeleton of my strategy without the trading logic. hopping maybe you can see what I am doing wrong .
    Attached Files

    #2
    hi
    I'm sorry I didn't look at your code. time is short.
    but may be you:.
    1. are trying to trade holiday sessions and they do not end at 23:00
    2. are using tick data, they are have not to round numbers. the time of such bars can fluctuate and depends on the bar tick filled.
    i.e. the first bar is at 22:13:02 and the next one is at 23:10:26. and they will pass your end-of-session trigger
    Last edited by Danila; 08-12-2021, 06:43 AM.

    Comment


      #3
      Danila
      I had this occurrence day before yesterday. No holidays there
      and it happened at around 13:00 CET so, not close to end of session . (my region trade time is 16:30 till 23:00 and it happened around 20:00) it simply printed out that the session closed and the position is closed.

      I truly dont know what is the issue. it doesnt happen all the time . thats why I cant see any errors or LOG entries. its normal working until its not

      Comment


        #4
        sorry, I thought you were writing for testing the strategy on historical data.
        if you are in real trade: create hooks in the form of slices and output to a file the data (triggers) on which you expect the unscheduled closing of the session depends.

        Comment


          #5
          Hi dadarara, thanks for posting.

          The session iterator reads from the Session Template that is being used in the Data Series menu. The default session template being used by the instrument can be found through Tools>Instruments. The best way to debug something like this is to use prints to print out the values you are working with e.g.

          Print(Time[0]);
          Print(sessionIterator.ActualSessionEnd.TimeOfDay.S ubtract(new TimeSpan(00, 05, 00)));

          There is a lot of code in this reduced example that doesn't have anything to deal with the session iterator. Consider making a new strategy that solely focuses on the session iterator to get this correct and then re-introduce the session iterator code back into this script.

          Kind regards,
          -ChrisL
          Chris L.NinjaTrader Customer Service

          Comment


            #6
            thank you Chris
            unfortunately the the strategy is working fine most of the time . so printing to log and also making a simple strategy is not helpful.
            today I had the same issue . see the log:
            Click image for larger version

Name:	Screenshot 2021-08-13 220909.png
Views:	157
Size:	7.1 KB
ID:	1167827

            suddenly at 20:00:24 a session close handling started.
            maybe its not the session iterator at all.
            its the ninjatrader decided to close the session . it also happened at 22:00:28
            Click image for larger version

Name:	Screenshot 2021-08-13 221241.png
Views:	133
Size:	14.7 KB
ID:	1167828


            any suggestions ?
            Attached Files

            Comment


              #7
              Hi dadarara,

              Do you get this problem using the SampleMACrossover strategy? If not I will need you to reduce an example as must as possible that still reproduces this issue. Can you also confirm what your Exit On Session Close Seconds is set to? The default is 30 seconds before the session close.

              Kind regards,
              -ChrisL
              Chris L.NinjaTrader Customer Service

              Comment


                #8
                I am operating the SampleMACrossover strategy for a few day since last message.
                I didnot yet get the situation of session close in either of my strategies in mid day trading.
                What I did get yesterday was that the SampleMACrossover strategy DID NOT EXIT on session close at 22:59 like it was supposed to do.
                see attached evidence. So I was left with a position open till now.,

                What should I look for and where to understand whats going on?
                Attached Files
                Last edited by dadarara; 08-18-2021, 12:03 AM.

                Comment


                  #9
                  Hi dadarara,
                  Please change the color of your session break line e.g.:


                  This will show you exactly where the session template is reading the session end.
                  Chris L.NinjaTrader Customer Service

                  Comment


                    #10
                    very nice
                    but it doesnt explain the situation and also it doesnt show the end of session ahead of time (in advance).

                    Comment


                      #11
                      Hi dadarara,

                      I will need to read your log files to see if the end of session order is being ignored.

                      You can do this by going to the Control Center-> Help-> Email Support

                      Ensuring 'Log and Trace Files' is checked will include these files. This is checked by default.

                      Please reference the following ticket number in the body of the email: 3219566 ATTN ChrisL
                      Chris L.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by burtoninlondon, Today, 12:38 AM
                      0 responses
                      2 views
                      0 likes
                      Last Post burtoninlondon  
                      Started by AaronKoRn, Yesterday, 09:49 PM
                      0 responses
                      11 views
                      0 likes
                      Last Post AaronKoRn  
                      Started by carnitron, Yesterday, 08:42 PM
                      0 responses
                      10 views
                      0 likes
                      Last Post carnitron  
                      Started by strategist007, Yesterday, 07:51 PM
                      0 responses
                      12 views
                      0 likes
                      Last Post strategist007  
                      Started by StockTrader88, 03-06-2021, 08:58 AM
                      44 responses
                      3,982 views
                      3 likes
                      Last Post jhudas88  
                      Working...
                      X