• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exit before session close

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

    Exit before session close

    Hello,
    How do I use ToTime() or other logic in my strategy to exit all open positions at session close? Using:
    Code:
    if ((ToTime(Time[0]) == 155500) && Position.MarketPosition == MarketPosition.Long)
    			{
    				Draw.ArrowDown(this, @"MyStratArrow down", false, 0, 0, Brushes.Red);
    				ExitLong(Convert.ToInt32(orderqty), @"ExitLong", @"Buy");
    			}
    to exit at 3:55pm is being ignored by the strategy, which continues to execute the running strategy and I still have to manually close the running position. I would like to exit at 3:55pm each day.
    Many thanks.

    #2
    Originally posted by aaadetos View Post
    Hello,
    How do I use ToTime() or other logic in my strategy to exit all open positions at session close? Using:
    Code:
    if ((ToTime(Time[0]) == 155500) && Position.MarketPosition == MarketPosition.Long)
    			{
    				Draw.ArrowDown(this, @"MyStratArrow down", false, 0, 0, Brushes.Red);
    				ExitLong(Convert.ToInt32(orderqty), @"ExitLong", @"Buy");
    			}
    to exit at 3:55pm is being ignored by the strategy, which continues to execute the running strategy and I still have to manually close the running position. I would like to exit at 3:55pm each day.
    Many thanks.
    There would have to be data at 155500 exactly for that code to hit.

    I'm a little more forgiving, 20 minutes, in case of disconnects or internet issues or whatever.


    Code:
    			if (   ToTime(Time[0]) >= ToTime( 15, 50, 00)
    				&& ToTime(Time[0]) <= ToTime( 16, 10, 00) )
                    { 
                            // EXIT
    
    			{

    Comment


      #3
      Thanks sledge,
      What about using the order handling strategy property and setting the Exit on session close seconds to say 300 or whatever number? This would work too right? Haven't tested it yet.

      Comment


        #4
        Hello aaadetos,

        Thanks for your post.

        Member sledge has provided sage advice to use a time range to ensure you get multiple opportunities.

        Using ExitOnClose will provide the same functionality.

        A 3rd option to consider is the use of the "Auto Close" function (Not available for Direct License users). This can be found in Tools>options>Trading. Please see: http://ninjatrader.com/support/helpG...ns_trading.htm
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Thanks a lot Paul. I'll definitely try the Auto Close function. But wouldn't ExitOnClose exit at session close?

          Comment


            #6
            Hello aaadetos,

            Thanks for your reply.

            Correct, that is the intent of ExitOnClose order handling. Please see the helpguide here: http://ninjatrader.com/support/helpG...t_strategy.htm
            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by frankduc, Today, 09:00 AM
            0 responses
            1 view
            0 likes
            Last Post frankduc  
            Started by Kabua, Yesterday, 11:24 PM
            1 response
            6 views
            0 likes
            Last Post koganam
            by koganam
             
            Started by KandI, Today, 08:03 AM
            2 responses
            7 views
            0 likes
            Last Post KandI
            by KandI
             
            Started by kujista, Yesterday, 10:33 PM
            5 responses
            14 views
            0 likes
            Last Post NinjaTrader_ChrisL  
            Started by tonynt, Today, 07:27 AM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_PatrickG  
            Working...
            X