Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy time to exit all L and S positions inside strategy (not with NT system)...

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

    Strategy time to exit all L and S positions inside strategy (not with NT system)...

    Hey folks,

    In a Strategy I will like for it to exit any open positions in that Strategy only at a particular time during the day while keeping the Strategy running. I already have the time frames to actually take trades set, but just need it to exit all positions at a particular time and then let the next trade happen per the time frames I set. I already have used your thread on timefilters so thanks for that...however, it does not seem to address exiting all positions at x time.

    I don't want to flatten all positions totally with other trades I may be in with other Strategies or manual trades within the Options>Data>Misc. Flatten all in NT...it should be in each Strategy that is deployed.

    What I have it doing per the timefilters thread is:

    Take any trades that may develop per the Strategy beginning on Sunday after 190000 (7pm est) to 115900 (midnight 11:59 pm est), then on Monday-Friday 000100 (one min passed midnight) til 153000 (3:30 pm est) and it then takes a break from taking trades til 190000 (7pm est) Monday-Friday and so on. So, there is a gap between 153000 (3:30 pm est) and 190000 (7 pm est) daily Mon-Friday that I do not want the strategy to actually taking any trades or in any trades either.

    There is 29 +/- min (between 153000 3:30 pm est - 155900 4 pm est) where I tell it to stop actually entering any new trades after that time but it has 29 +/- extra min. for any establish trade positions to finish developing before it needs to exit all long and short positions for that particular Strategy until after 190000 (7 pm est) later that day.

    Can you send me over some code that I can plug into the Strategy that tells it to exit all long and short positions (if any) for this Strategy at 155900 3:59 pm est?

    and

    Where would I put the code (beginning, middle, or end)? If you could take a basic simple strategy code and highlight the code you would have me put in to exit all positions in the Strategy at >= 155900 (3:59 pm est) and <= 185900 (6:59 pm est) that would be absolutely wonderful. I have some ideas, but can not get the code just right yet on exiting all long and short positions in the Strategy between those particular time frames.

    P.S. By the way, I can not use the Flatten function in NT (Options>Data>Misc) because I need the Strategy to stay on at all times daily for the week without restarting it, don't want for it to Flatten any other separate Strategies I may have going, and lastly don't want it to Flatten any manual trades I may be in at the time (among other reasons). Therefore, that is why I need it to be put into each individual Strategy independent of NT).

    Thank NT...great customer support by the way...

    Anyone else who can reply, please do...maybe it will also help others...




    Greg
    Last edited by birdog; 10-13-2012, 04:11 PM. Reason: clarify

    #2
    Hello,

    We have a lot of reference samples you can piece together here : http://www.ninjatrader.com/support/f...splay.php?f=30

    Code is executed line by line. It's a bit more complicated in OOP frameworks but you can just think of anything inside your Initialize() or OnBarUpdate() as executing line by line starting at the first line after the opening bracket { .

    if ( ToTime(Time[0]) >= 155900 && Position.MarketPosition != MarketPosition.Flat)
    {

    if ( Position.MarketPosition == MarketPosition.Long )
    {
    ExitLong();
    }
    else
    {
    ExitShort();
    }
    }
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_AdamP View Post
      Hello,

      We have a lot of reference samples you can piece together here : http://www.ninjatrader.com/support/f...splay.php?f=30

      Code is executed line by line. It's a bit more complicated in OOP frameworks but you can just think of anything inside your Initialize() or OnBarUpdate() as executing line by line starting at the first line after the opening bracket { .

      if ( ToTime(Time[0]) >= 155900 && Position.MarketPosition != MarketPosition.Flat)
      {

      if ( Position.MarketPosition == MarketPosition.Long )
      {
      ExitLong();
      }
      else
      {
      ExitShort();
      }
      }
      Adam:

      I just noticed this when adding a new Strategy in the Strategies tab that there are options for Exit on close (True or False) and Exit on close seconds (one can choose how many seconds before close to exit). Does the exit on close True automatically look at the time of session close on each instrument in EST and use that for the session close? How can I see and tell what time is being used for this? Both of these options are in the Order Handling section for Edit Strategy.

      Comment


        #4
        Hello,

        Here is an outline of how ExitOnClose works :



        It can be used to cancel positions and its based on the session template as you have correctly guessed.
        Adam P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        666 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        377 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        110 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        575 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        580 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X