I need to know the proper way to handle this. I could put code in to catch the condition, and exit on the next bar (the next day), but this feels like a kluge. Is there a better way to handle this? Why is the exit ignored by NT?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Exit lost at End of Day
Collapse
X
-
Exit lost at End of Day
I discovered a problem that is quite dangerous. If you decide to exit a trade on the last bar of the day, the exit is ignored. This is because the last bar of the day is the last time of trading. I expected that the exit would then go into effect on the start of the next day (next bar) when the market is open again (given the trading template). But it does not, so you think you have exited and you have not.
I need to know the proper way to handle this. I could put code in to catch the condition, and exit on the next bar (the next day), but this feels like a kluge. Is there a better way to handle this? Why is the exit ignored by NT?Tags: None
-
This is a swing trading strategy, ie Exit on close = False. I am not looking to exit at end of day, but if I perform an exit by calling ExitLong I expected it to close on the next bar, even if that is the next day.
I do not believe I am using a MultiSeries, just one instrument and one time frame, 60 min.
Comment
-
Thanks tradetree - I would highly suggest running with TraceOrders enabled to really see what happened to your exit order in this case - http://www.ninjatrader.com/support/f...ead.php?t=3627
Comment
-
The TraceOrders output is below, along with a Print when I "EnterLong" etc. so I know what I'm doing in the code at the same point as the TraceOrders output. Note that when I am live trading it does not behave this same way. There is a mismatch between trading and back-testing. In live trading it does not cancel the order at 4PM, but simply executes it at the next bar, the next day. This is a big problem for having confidence that what you test is how it will run.Originally posted by NinjaTrader_Bertrand View PostThanks tradetree - I would highly suggest running with TraceOrders enabled to really see what happened to your exit order in this case - http://www.ninjatrader.com/support/f...ead.php?t=3627
4/9/2013 12:30:00 PM Entered internal PlaceOrder() method at 4/9/2013 12:30:00 PM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='L1' FromEntrySignal=''
EnterLong
4/9/2013 4:00:00 PM Entered internal PlaceOrder() method at 4/9/2013 4:00:00 PM: BarsInProgress=0 Action=Sell OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='EL1' FromEntrySignal='L1'
ExitLong
4/9/2013 4:00:00 PM Cancelled order due to end of session handling: BarsInProgress=0: Order='NT-xxxxxxx' Name='EL1' State=Working Instrument='TF 06-13' Action=Sell Limit price=0 Stop price=0 Quantity=1 Strategy='ThreefoldChannel' Type=Market Tif=Day Oco='' Filled=0 Fill price=0 Token='c87b4f83eddd45f993d787216876d01a' Gtd='12/1/2099 12:00:00 AM'
4/10/2013 10:30:00 AM Entered internal PlaceOrder() method at 4/10/2013 10:30:00 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='L1' FromEntrySignal=''
4/10/2013 10:30:00 AM Ignored PlaceOrder() method at 4/10/2013 10:30:00 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='L1' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
EnterLongLast edited by tradetree; 04-10-2013, 11:20 PM.
Comment
-
Thanks tradetree, so the TraceOrders you posted is from the backtest run then? I would expect the end of session handling to get those as well trading realtime, if the orders are coming from the primary series in the script. Since you stated this would not be a MultiSeries strategy, we would need to reproduce it here ourselves to further look into what's expected in this scenario. Would you mind providing a script to us to test this? You can use the same sceleton you have now, but for sure mask custom IP out if desired before sending it in.
Comment
-
Ok, so I was able to get the Market Replay to perform the same operations as a typical backtest. I changed my code to add a test before doing any Entry or Exit operation:
bool takeTrade = curHour < 16; // test for less than 4PM bar
Only take the trade if( takeTrade ) otherwise ignore it. This has nothing to do with my particular strategy. This should be reproducible simply by buying and selling on every 60 min bar in a day when the Data Series is:
Last, Min, 60, US Equities RTH on instrument TF.
If you run that it will behave differently on backtest and Market Replay. Market Replay will buy and sell more times.
Comment
-
Thanks tradetree, I further looked into matters and unfortunately this would be an expected limitation and a filter like you outlined for not submitting on the last bar of the session should be applied. I will make a note to have this better documented in our official resources going forward.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
649 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
370 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
109 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
573 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
576 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment