![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Dec 2008
Location: Kansas City
Posts: 90
Thanks: 0
Thanked 2 times in 2 posts
|
I'm trying to load a strategy in Market Replay and it gets hung up doing all the calculations before kicking off (the calcs it does to try to determine current strategy position). I get the error trying to call OnExecution in the log.
The line of code I've isolated is Code:
Print("Test1");
if (EntryOrder1 != null && EntryOrder1.Token == execution.Order.Token)
{
Print("Test2");
if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))...
Here is the output just prior to the error. Test1 is right before the line of code above, and Print("test2"); is right after the line of code above, but as you can see Test2 does not print. Code:
5/7/2009 1:14:27 PM Cancelled pending exit order, since associated position is closed: Order='NT-00002/Replay101' ... OnOrderUpdate(): 5/7/2009 1:14:27 PM OnOrderUpdate(): 5/7/2009 1:14:27 PM OnOrderUpdate(): 5/7/2009 1:14:27 PM OnExecution(): 5/7/2009 1:14:27 PM Test1 kc |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
|
Can you check if execution.Order is null?
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Dec 2008
Location: Kansas City
Posts: 90
Thanks: 0
Thanked 2 times in 2 posts
|
|
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
The OnExecution may have been triggering off of a different execution. What were the results from your check?
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 | |
|
Member
Join Date: Dec 2008
Location: Kansas City
Posts: 90
Thanks: 0
Thanked 2 times in 2 posts
|
Quote:
I put Code:
&& execution.Order != null It is getting hung up on the historical data calcs --- almost like there is a historical database problem from 5/7 or something. Any other ideas? |
|
|
|
|
|
|
#6 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
If you feel there is a database concern, please try resetting your database. Tools->Options->Misc->Reset DB.
Please in OnExecution() just print the execution directly without accessing any properties.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#7 | |
|
Member
Join Date: Dec 2008
Location: Kansas City
Posts: 90
Thanks: 0
Thanked 2 times in 2 posts
|
Quote:
However I just added Code:
Print("OnExecution triggered by " + execution.ToString());
HTML Code:
OnExecution(): 5/7/2009 1:30:43 PM OnExecution triggered by Execution='NT-00003' Instrument='AAPL' Account='Replay101' Name='Exit' Exchange=Default Price=128.603937442173 Quantity=100 Market position=Short Commission=1 Order='NT-00005' Time='5/7/2009 2:13:59 PM' |
|
|
|
|
|
|
#8 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
Unfortunately not. You could try closing down the market replay connection and open up anew to see if that helps.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#9 |
|
Member
Join Date: Dec 2008
Location: Kansas City
Posts: 90
Thanks: 0
Thanked 2 times in 2 posts
|
Just figured out what was going on. There was a pause in market data for some reason, or rather a large step change in last traded price as opposed to the normal market movement the strategy normally sees. This caused a profit order to be filled. The profit order execution attempts to cancel a StopOrder --- in this case the StopOrder it expected to be active never got set because the price didn't transition through its trigger point (the step change went well through it and the profit order price). So, I'm now checking all potential stop orders to be != null when the Profit Order gets filled, and this appears to have fixed my issue.
Now, the question is, why is my NT data lagging what I'm seeing in TWS? I noticed this today and was going to post another thread regarding it. Here is what I'm seeing... In NT's data window on the top left of the control center, I see the bid, bid volume, ask, ask volume, and last volume all updating a few times per second. However, the 'last' price becomes frozen for seconds to sometimes minutes at a time (this is what caused my above issue...nevertheless I needed to fix this in case a true market step change occurs). I visually confirmed in TWS at the very same time that the last price WAS changing here. It was always at or in between the bid and ask. However, in NT, the bid and ask would start moving up or down together and the last price just stays frozen. Once the last price data starts filtering in again, my OnBarUpdate begins running again and then has to react to what it sees as somewhat of a price shock when in reality there was none. Do I need to use OnMarketData? Is this just a market data throttling issue? Seems to me if TWS has the updated last trade then NT should be getting the data too. Thanks, kc |
|
|
|
|
|
#10 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
If NT receives a last update event then it will display it. If not then it will not. What you may want to consider is checking with no strategies or charts open. Just one instrument in the Control Center readout.
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Error on running optimizer. Object reference not set to an instance of an object. | vasily20011 | Strategy Analyzer | 5 | 03-09-2009 08:09 AM |
| Object reference not set to an instance of an object | kcsystemtrader | Strategy Development | 6 | 02-09-2009 08:32 AM |
| Error on calling the 'OnOrderUpdate' method for strategy 'maslope': Object reference | scriabinop23 | General Programming | 4 | 01-24-2008 02:20 PM |
| Object not set to an instance of an object | ATI user | Historical NinjaTrader 6.5 Beta Threads | 1 | 12-14-2007 03:35 AM |
| Error: Object reference not set to an instance of an object. | Januson | Market Analyzer | 1 | 05-18-2007 12:12 AM |