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 02-18-2009, 01:24 PM   #1
xewoox
Senior Member
 
Join Date: Dec 2008
Posts: 118
Thanks: 0
Thanked 0 times in 0 posts
Default How CancelOrder() work?

When I execute the cancelOrder() functions, rather than it actually cancel the order, internal NT will always report Cancelled Expired order instead. Is that make sense? Can you explain how CancelOrder work internally?
xewoox is offline  
Reply With Quote
Old 02-18-2009, 01:51 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

xewoox,

CancelOrder() is only for IOrders that you specifically told to stay alive via the liveUntilCancelled parameter. Otherwise, if you do not resubmit your order to keep it alive on every bar it will just automatically cancel.
NinjaTrader_Josh is offline  
Reply With Quote
Old 02-18-2009, 01:57 PM   #3
xewoox
Senior Member
 
Join Date: Dec 2008
Posts: 118
Thanks: 0
Thanked 0 times in 0 posts
Default

So how can you cancel your order in next ticks (in real time as soon as possible)
xewoox is offline  
Reply With Quote
Old 02-18-2009, 01:58 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

Use CalculateOnBarClose = false and call CancelOrder whenever you want to cancel.
NinjaTrader_Josh is offline  
Reply With Quote
Old 02-18-2009, 02:08 PM   #5
xewoox
Senior Member
 
Join Date: Dec 2008
Posts: 118
Thanks: 0
Thanked 0 times in 0 posts
Default

Please try this script, I have it. It does not work.
xewoox is offline  
Reply With Quote
Old 02-18-2009, 02:09 PM   #6
xewoox
Senior Member
 
Join Date: Dec 2008
Posts: 118
Thanks: 0
Thanked 0 times in 0 posts
Default

The actual script
Attached Files
File Type: zip test.zip (1.6 KB, 8 views)
xewoox is offline  
Reply With Quote
Old 02-18-2009, 02:21 PM   #7
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

Your script is telling it to CancelOrder only when you orderOut is true. orderOut is only true when your OrderState reaches a cancelled state. If it has reached a cancel state already there is nothing to cancel. That is why your CancelOrder() doesn't do anything.
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
How does this work? SystemTrading ATM Strategies (Discretionary Trading) 3 12-09-2008 07:24 AM
Simple Limit Strategy with CancelOrder stefy Strategy Development 7 11-10-2008 07:44 AM
CancelOrder() problem John833 Strategy Development 41 10-31-2008 03:15 PM
doesn't work Gregory Arkadin Charting 11 07-31-2008 07:58 AM
Strategy doesn't work somehow Gordon_Gekko Strategy Development 4 11-06-2007 12:10 AM


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