NinjaTrader Support Forum  

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 09-09-2009, 12:23 PM   #1
clfield
Member
 
Join Date: Sep 2008
Posts: 68
Thanks: 0
Thanked 0 times in 0 posts
Default Life of unfilled orders

I am working on a multi-Time frame strategy which places both Stop and Market entry orders. The orders are placed from the BarsInProgress==0 region but are indexed to the lower time frame.
My question is reagrding the "life" of the order. I know that the order is cancelled at the end of the current bar and must be resubmitted. Does this have to be done in the lower timeframe or will the order be "live" until the next onbarupdate call from the primary time frame?
clfield is offline  
Reply With Quote
Old 09-09-2009, 12:55 PM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

clfield,

I believe it will need to be kept alive on all BarsInProgresses. An easy way to work with this would be to just use liveUntilCancelled = true for the orders and then you won't need to worry about resubmissions.
NinjaTrader_Josh is offline  
Reply With Quote
Old 09-09-2009, 02:58 PM   #3
clfield
Member
 
Join Date: Sep 2008
Posts: 68
Thanks: 0
Thanked 0 times in 0 posts
Default

If I set it up as you suggest would I need to actually cancel each order if it did not fill and my entry condition was not met on the next bar? Also what about updating the Stop price in the StopEntry entry?
clfield is offline  
Reply With Quote
Old 09-09-2009, 02:59 PM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

You would indeed need to cancel the order when your condition is no longer true. This can be done through a simple call to CancelOrder().

Updating stop prices works like how it does before. If you want to modify the order, call the order again to make the change.
NinjaTrader_Josh is offline  
Reply With Quote
Old 09-09-2009, 04:46 PM   #5
clfield
Member
 
Join Date: Sep 2008
Posts: 68
Thanks: 0
Thanked 0 times in 0 posts
Default

Thank you for your replies.

I was thinking could I put the order placement in at the end of the OnBarUpDate after all the BarsInProgress calls so it would be run every time OnBarUpDate was called regardless of which Bars Object initiated the update?
clfield is offline  
Reply With Quote
Old 09-10-2009, 04:52 AM   #6
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
Default

clfield, this is also an option (don't filter OnBarUpdate calls), but it may be easier to submit it as liveUntilCancelled and then cancel if needed.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 09-10-2009, 05:41 AM   #7
clfield
Member
 
Join Date: Sep 2008
Posts: 68
Thanks: 0
Thanked 0 times in 0 posts
Default

Thank you for the confirmation.

Can the StopEntry price be undated each bar without first canceling the existing StopEntry order?
clfield is offline  
Reply With Quote
Old 09-10-2009, 05:58 AM   #8
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
Default

Not sure I follow what you mean by 'undated', if you want to move the stop price to a new leve, just resubmit the order with the new stop price to make the modification.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 09-10-2009, 06:03 AM   #9
clfield
Member
 
Join Date: Sep 2008
Posts: 68
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks for the clarification. So if I am staying with the same type of Entry order IE Stop or Limit or StopLimit I do not need to cancel the previous roder than submit a new one with the new Entry Price? But if I am going to change the type of Entry then I would need to cancel the previous order before submitting the new one.
clfield is offline  
Reply With Quote
Old 09-10-2009, 06:59 AM   #10
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
Default

Correct, for a new price, just resubmit the order to change it.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 09-10-2009, 10:37 AM   #11
clfield
Member
 
Join Date: Sep 2008
Posts: 68
Thanks: 0
Thanked 0 times in 0 posts
Default

When using the technique where the order is placed each OnBarUpdate and not kept live until canceled and I change from a StopEntry to a Market or Limit Entry Order and I want to use the same IOrder entry name I won't I have to wait for confirmation of the canceled order in the OnOrderUpdate method before submitting the the new order to avoid losing the order info?
I am trying to avoid having to manage stops and targets for two seperate IOrder objects.
clfield is offline  
Reply With Quote
Old 09-10-2009, 11:24 AM   #12
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

I do not recommend using the same IOrder object for separate orders. If you do you should wait for confirmation on a terminal state of the original order before replacing the object with the new order. If you don't wait for confirmation you run the risk of the order not going terminal and you lose all ability to control it after you overwrite the references.
NinjaTrader_Josh is offline  
Reply With Quote
Old 09-10-2009, 12:20 PM   #13
clfield
Member
 
Join Date: Sep 2008
Posts: 68
Thanks: 0
Thanked 0 times in 0 posts
Default

Where would be the best place to check for the Terminal state, OnExecution or OnOrderUpdate? I understand what you are saying about losing control of the order. The problem with seperate IOrder objects for each entry type comes when you place and manage the stop and target orders after the entry order has filled.
clfield is offline  
Reply With Quote
Old 09-10-2009, 01:40 PM   #14
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

clfield,

Best would be OnOrderUpdate().
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
Cancel unfilled Auto order not working ..need help pdawg Strategy Development 21 04-15-2013 05:52 AM
Position.MarketPosition with unfilled limit orders honvl Strategy Development 1 06-05-2009 12:23 PM
How does NJ handles unfilled contracts by default? ninjaq Strategy Development 1 05-28-2009 10:17 AM
Now a happy life-time multi-broker customer heech Suggestions And Feedback 1 12-04-2008 11:17 AM
Multi Broker - Life Time License mapfler Installation and Licensing 1 09-17-2008 09:58 AM


All times are GMT -6. The time now is 06:46 PM.