View Full Version : A possible bug with exit on close?
cunparis
05-12-2009, 08:22 AM
I run a strategy that does exit on close. Last night it exited before the close. This morning I stopped my strategy and reran it. Before the open it had a "virtual" open position which never got closed. Now my strategy thinks it has an open position so it won't enter any new positions. I have wait until flat set to be true but I'm not sure that matters. It seems I'm stuck until my strategy will stop out.
Any ideas?
NinjaTrader_Bertrand
05-12-2009, 08:57 AM
Hi cunparis, thanks for your post - at which time was the exit order submitted? To debug this it would be best to use TraceOrders = true in the Initialize() - http://www.ninjatrader-support.com/HelpGuideV6/TraceOrders.html
cunparis
05-12-2009, 09:18 AM
Hi cunparis, thanks for your post - at which time was the exit order submitted? To debug this it would be best to use TraceOrders = true in the Initialize() - http://www.ninjatrader-support.com/HelpGuideV6/TraceOrders.html
The order was exited yesterday 30 seconds before close. That works.
The problem is the strategy thinks it hasn't exited when I rerun it. I presume this is because the last bar of yesterday isn't closed until the first bar of today. Something like that.
NinjaTrader_Bertrand
05-12-2009, 10:04 AM
Hi cunparis, on which instrument and session times are you running this?
cunparis
05-12-2009, 10:52 AM
Hi cunparis, on which instrument and session times are you running this?
ES using RTH (9:30 - 4:00 EST)
NinjaTrader_Bertrand
05-12-2009, 11:54 AM
Thanks, I also suspect you see this because as you restarted this morning the last bar from yesterday was still open, thus leaving you with a virtual position if the MarketOnClose did not trigger. So to debug this you would need to rerun this with the TradeOrders enabled and check the output window if it triggered again as you did the reload.
cunparis
05-12-2009, 12:32 PM
Thanks, I also suspect you see this because as you restarted this morning the last bar from yesterday was still open, thus leaving you with a virtual position if the MarketOnClose did not trigger. So to debug this you would need to rerun this with the TradeOrders enabled and check the output window if it triggered again as you did the reload.
I'm not sure what you mean by rerun, this happened with live trading with real money.
Fortunately my strategy didn't trigger today so I didn't miss a trade but I'm quite sure this is a bug.
NinjaTrader_Josh
05-12-2009, 02:04 PM
cunparis,
You need to reproduce this with TraceOrders or else we have no information to advise you on.
As you rerun your strategy in the you will likely not receive an Exit on Close order because your closing bar has not closed. Only TraceOrders will reveal what is happening.
cunparis
05-12-2009, 02:24 PM
cunparis,
You need to reproduce this with TraceOrders or else we have no information to advise you on.
As you rerun your strategy in the you will likely not receive an Exit on Close order because your closing bar has not closed. Only TraceOrders will reveal what is happening.
It didn't close tonight either. It's never going to close. The only solution I can think of is to save the strategy to a new name and run it.
Have you tried reproducing it? It should be pretty easy. Just enter on open and let it close on exit. Then stop the strategy after hours and run it again and see it has the virtual position that doesn't close.
You don't even have to wait until 4pm just use a session time from 9:30 to 10:00.
NinjaTrader_Josh
05-12-2009, 02:36 PM
cunparis,
Please run with TraceOrders = true. As stated, when you stop your strategy and restart you are now in backtest mode. This is NOT the same as real-time. The last bar has not closed and as such you will likely NOT receive any Exit on Close till that bar closes. Only with TraceOrders = true will you know what is going on. Please use it.