Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

exit on close exit >> open position next day pre open

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

    exit on close exit >> open position next day pre open

    hi

    i have problem with exit on close exits leading to open positions showing in startegies that i enable before their chart opening time.

    this a problem if i want to enable strategy before chart period start time + leave it running.

    problem is strategy still thinks it has open position + sets profit target + stop loss orders (i want to leave the immediately submit historical orders option on).
    it does not seem to realise in this situation that the position actually closed on exit until the start of the opening time period bar.

    exit on close works ok at end of day but the knock on of the assumed open position when restarting strategy the next day before chart session begins is a problem.

    #2
    alexgg, I'm not sure I understand why you would need the immediately submit option, if you're starting out flat anyways with the strategy then on the next trading day - why not use WaitUntilFlat and trade the next live signal after the chart open time?

    Thanks,
    BertrandNinjaTrader Customer Service

    Comment


      #3
      hi bertrand

      thanks for response

      i dont want to submit these orders , nt is doing that automatically

      but i would like to keep sumbit live historical working orders switched on for other reasons

      i guess i could make the change to wait till flat , but usually i have the historical orders setting on for use on restarting strategies + thought it would be nice if nt recognized exit on close orders had closed previous day positions before opening bar.

      alex

      Comment


        #4
        Correct, if you have a historical strategy position and then time of enabling and the 'immediately submit' option on the protective orders would be send by NT - if you at the historical chart portion is the backtest then exiting at close as well?
        BertrandNinjaTrader Customer Service

        Comment


          #5
          hi bertrand

          everything is ok with backtesting

          i will just start strategies with wait till flat option on + switch to submit historical live orders if i need to restart strategies mid session later on.

          thanks

          alex

          Comment


            #6
            Ok sounds good - please let me know if you run into any issues then.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              hi bertrand

              further problems have occured for me with this issue !!!

              using strategy with exit on close over 1 week ago (+ no trades since then), i start this strategy before session open + daily it re-submits live the buy order from the day when this entry exited on close .

              i have enter orders only when flat option set.

              i'm pretty sure right now that this is what it is doing.

              alex

              Comment


                #8
                Alex, that's strange - would you mind contacting us via Help > Mail to Support so we could have access to your trace / log files for review of the sequence of events?
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  hi bertrand

                  try this inside a strategy :

                  protectedoverridevoid Initialize()
                  {
                  CalculateOnBarClose =
                  true;
                  Add(PeriodType.Day ,
                  1);
                  date =
                  new DateTime(2011 , 7 , 28 , 11 , 0 , 0);
                  }
                  DateTime date;

                  ///<summary>
                  /// Called on each bar update event (incoming tick)
                  ///</summary>
                  protectedoverridevoid OnBarUpdate()
                  {
                  if (
                  BarsInProgress ==
                  0 &&
                  Position.MarketPosition == MarketPosition.Flat &&
                  Time[
                  0].Date == date.Date &&
                  Time[
                  0].TimeOfDay > date.TimeOfDay
                  )
                  EnterLongLimit(Close[
                  0]);
                  }


                  then run strategy on , say , an instrument default session.

                  this produces the same behaviour on my nt7 if run for today.

                  basically, when strategy enabled it creates an entry order from the entry yesterday, you can name entry limit order to prove this. if below the market it cancels immediately or if limit above the current market on enabling, as happened for me today, it will execute.

                  alex




                  Comment


                    #10
                    ah , i forgot to mention , when testing with this i noticed the following :

                    the non desirable behaviour does not occur if you do not have the Add(PeriodType.Day, 1) statement.

                    you can prove this by commenting it out.

                    so somehow the multi timeframe day period is creating the bad behaviour following exit on close.

                    Comment


                      #11
                      oh, and maybe not obviously need to run on a minute based time frame ..

                      Comment


                        #12
                        Hi there, thanks for the update. We will look into this.
                        AustinNinjaTrader Customer Service

                        Comment


                          #13
                          I just tested this on ES 09-11 1 min instrument defaults, and no stray order was placed. Perhaps it is due to the markets being closed. Can you please clarify the exact steps necessary to reproduce this issue?
                          AustinNinjaTrader Customer Service

                          Comment


                            #14
                            hi austin

                            i just did a few more tests myself + found that behaviour is not limited to exit on close,
                            or even to starting strategy before session starts.

                            it is limited to sessions with session end time on or after the global daily close for particular market. ie i am testing on 6B futures contract = find that if i use session that ends on or after 5pm est (globex close) then i get the spurious order.

                            order is not limited to exit on close. it seems any order, even obviously exited order, from any day prior will create spurious order.

                            try this in test code previous post, immediately after the entry order :

                            if (BarsInProgress == 0 && Position.MarketPosition == MarketPosition.Flat && Time[0].Date == date.Date && Time[0].TimeOfDay > date.AddMinutes(60).TimeOfDay)
                            ExitLong();

                            now (only if using session with end time on or after market daily close time) you will always get spurious order when starting strategy. it will cancel immediately if not above the market price at the time.

                            Comment


                              #15
                              i also noticed that the spurious order mimics the first order posted on graph when starting strategy ie if you set to make orders on earlier dates , the earliest order made chronologically will reappear when starting strategy.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by AveryFlynn, Today, 04:57 AM
                              0 responses
                              0 views
                              0 likes
                              Last Post AveryFlynn  
                              Started by RubenCazorla, 08-30-2022, 06:36 AM
                              3 responses
                              77 views
                              0 likes
                              Last Post PaulMohn  
                              Started by f.saeidi, Yesterday, 12:14 PM
                              9 responses
                              23 views
                              0 likes
                              Last Post f.saeidi  
                              Started by Tim-c, Today, 03:54 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post Tim-c
                              by Tim-c
                               
                              Started by FrancisMorro, Today, 03:24 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post FrancisMorro  
                              Working...
                              X