Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Why not exiting on this code?

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

    Why not exiting on this code?

    Hi,

    This bit of code is in place, running COBC=false, to effect a user defined end of trading time.

    Code:
    if((ToTime(Time[0])>=endTime)&& (ToTime(Time[0])<=endTime + 100))
    	{
    	if(Position.MarketPosition == MarketPosition.Long)
    			{
    			ExitLong();
    			}
    	else if(Position.MarketPosition == MarketPosition.Short)
    			{
    			ExitShort();
    			}
    	}
    This morning I was running the strategy on 6E and 6J, using the exact same parameters. The 6E exited perfectly, as it usually does. The 6J did not. I thought maybe there was a remote possiblity that the 6J did not have a trade during the period for which the code effects the exit, which would of course not allow the code to execute. That was not the case however. I inspected the log file and Ninja did not send out any order to close the 6J position.

    Any ideas?

    #2
    Hi coolmoss,

    Unfortunately it's difficult for us to say why a given code did or did not execute. If you recorded this as market replay you could play it back and add debug statements like Print() and TraceOrders to check all values and view messages related to strategy orders. Using these debug tools is really the only way to tell if the code is functioning as expected.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hi Ryan,

      That's more or less what I thought, but figured I'd give a shot if anything popped out at anyone.

      Thanks!

      Comment


        #4
        I see. The areas I would look at here are:
        Timestamp on 6J chart matches what you expect.
        Strategy was in position at the time code should have executed.
        endTime variable matches what you expect.
        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        668 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