NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 03-31-2008, 12:41 PM   #1
phineas
Member
 
Join Date: Jan 2008
Posts: 36
Thanks: 0
Thanked 0 times in 0 posts
Default Closing Open Orders & and any filled Position

I am using OnOrderUpdate() method for confirmation of my EnterLongLimit() entry order, to submit my stop via ExitLongStop() and to submit my profit target via ExitLongLimit(). I've set the parameter liveUntilCancelled to true, so I don't have to resubmit orders on every bar update.

If a condition arises that would dictate closing all open orders and any filled position (if it has already been entered). What is the preferred method to do this.

Since I would want to close all open orders, and my entry position if it has been filled, would AtmStrategyClose() , using the entry order signal name be best? Or is some other way preferred.

Thanks,
Phineas
phineas is offline  
Reply With Quote
Old 03-31-2008, 02:51 PM   #2
phineas
Member
 
Join Date: Jan 2008
Posts: 36
Thanks: 0
Thanked 0 times in 0 posts
Default

Follow-Up: I think the following works, Could you let me know if there is a better way.

I will first check on status of original entry order (filled or not). If not filled, I'll use CancelOrder(), and that is it.
If it has already been filled, I should submit an ExitShort() or ExitLong to close original position, AND then use CancelOrder() on Stop loss and CancelOrder() on Profit Target.
Thanks,
Phineas
phineas is offline  
Reply With Quote
Old 03-31-2008, 03:17 PM   #3
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

I would CancelOrder(myStopOrder), monitor this to make sure it comes back cancelled with a filled amount of zero, then modifying the limit order to a price (below market if a sell order for example) to get it to fill. This reduces any potential overfill on orders are you request cancellation.
NinjaTrader_Ray 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
Limit orders filled at different price Richard Von SuperDOM and other Order Entry Windows 4 01-28-2008 12:02 PM
Closing a forex position with ExitLong() henry.omd Strategy Development 2 01-05-2008 12:31 PM
Automation-Orders not filled. Zardoz Automated Trading 2 02-26-2007 08:05 AM
partially filled entry orders werosen Miscellaneous Support 3 01-11-2006 07:53 AM
Partially filled orders bor Automated Trading 2 05-27-2005 01:39 AM


All times are GMT -6. The time now is 07:51 PM.