NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 11-26-2008, 02:31 PM   #1
heech
Senior Member
 
Join Date: Nov 2008
Posts: 576
Thanks: 0
Thanked 1 time in 1 post
Default OnExecution question...

Hi,

I believe I know the answer to this question, but just wanted to double check.

If OnExecution is called on a partial fill of an order... then the IOrder.token will match my initial token returned from the original order call, correct? For every "partial fill" going into OnExecution?
heech is offline  
Reply With Quote
Old 11-26-2008, 02:40 PM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Yes. Watching underlying IOrder object from the OnExecution can pose race conditions as well. For instance, if you have partial fills and are receiving OnExecution events. Let us say you had 3 part fills. On your second execution if you checked IOrder for order status you can easily get a returned state of Filled even though you have not received all 3 of the execution events yet.
NinjaTrader_Josh is offline  
Reply With Quote
Old 11-26-2008, 03:03 PM   #3
heech
Senior Member
 
Join Date: Nov 2008
Posts: 576
Thanks: 0
Thanked 1 time in 1 post
Default

Quote:
Originally Posted by NinjaTrader_Josh View Post
Yes. Watching underlying IOrder object from the OnExecution can pose race conditions as well. For instance, if you have partial fills and are receiving OnExecution events. Let us say you had 3 part fills. On your second execution if you checked IOrder for order status you can easily get a returned state of Filled even though you have not received all 3 of the execution events yet.
Josh,

As always, appreciate the quick response.

In your example, I'm still guaranteed to get all 3 calls into OnExecution... correct? I just can't rely on IOrder having the right status? If so, I'll just calculate the number of shares actually sold/bought based on the field in IExecution, which I assume is always correct...

And in the case of TDAmeritrade (as discussed in the autotrading forum)... it doesn't matter, because IOrder returns filled for partial fills in any case.
heech is offline  
Reply With Quote
Old 11-26-2008, 03:09 PM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

That would be the way to go.
NinjaTrader_Josh is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OnExecution(IExecution execution) stop loss Czarek Strategy Development 25 08-26-2008 12:14 PM
OnExecution Method mjuviler Strategy Development 6 08-06-2008 11:32 PM
OnExecution Ref Sample Not Working mjuviler Strategy Development 8 05-19-2008 07:37 AM
Strategy: Using OnOrderUpdate() and OnExecution() methods to submit protective orders NinjaTrader_Josh Reference Samples 0 05-08-2008 01:42 AM


All times are GMT -6. The time now is 01:09 PM.