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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        67 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        36 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        60 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        62 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        53 views
        0 likes
        Last Post CarlTrading  
        Working...
        X