NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > Application Technical Support > Automated Trading

Automated Trading Support for automated trading systems using NinjaScript. Support for our ATI (Automated Trading Interface) used to link an external application such as TradeStation and eSignal to NinjaTrader.

Reply
 
Thread Tools Display Modes
Old 01-14-2009, 05:05 PM   #1
ahagger
Junior Member
 
Join Date: Jan 2008
Posts: 18
Thanks: 2
Thanked 0 times in 0 posts
Default Stop order is being cancelled that is unrelated

I'm having a problem at the moment whereby the below ShortStopOrder2 is being cancelled when the ShortTargetOrder is executed. I expect the ShortStopOrder1 to be cancelled which is happening because it is related to the ShortEntryOrder1. The tricky thing is this does not happen all the time and I believe the problem may occur when the ShortEntryOrder1 has multiple rows in the Control Center's Executions Tab. eg 2 rows with 1 contract each. I run this strategy on both the ES and NQ contracts and it occurs more frequently on NQ maybe because of the way it fills??

The problem is occurring in Simulation mode for both long and short entries. I would appreciate any help please.

ShortEntryOrder1=EnterShortLimit(0,false,2,EntryOr derPrice,"MyShortEntry1");

ShortEntryOrder2=EnterShortLimit(0,false,1,EntryOr derPrice,"MyShortEntry2");

ShortStopOrder1=ExitShortStop(0,true,order.Filled, StopOrderPrice, "MyShortStop1", "MyShortEntry1");

ShortTargetOrder = ExitShortLimit(0, true, order.Filled, TargetOrderPrice, "MyShortTarget", "MyShortEntry1");

ShortStopOrder2 = ExitShortStop(0, true, order.Filled, StopOrderPrice, "MyShortStop2", "MyShortEntry2");
ahagger is offline  
Reply With Quote
Old 01-14-2009, 05:14 PM   #2
ahagger
Junior Member
 
Join Date: Jan 2008
Posts: 18
Thanks: 2
Thanked 0 times in 0 posts
Default top order is being cancelled that is unrelated cont..

I forgot to mention when the strategy is run on historical data it performs as expected.
ahagger is offline  
Reply With Quote
Old 01-15-2009, 04:30 AM   #3
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
Default

Hi ahagger, welcome to the NinjaTrader support forums! Please use TraceOrders = true in your Initialize() and see what insight the TraceOrders output has to offer - http://www.ninjatrader-support.com/H...aceOrders.html

Please also see this tip regarding TraceOrders - http://www.ninjatrader-support2.com/...ead.php?t=3627
Last edited by NinjaTrader_Bertrand; 01-15-2009 at 08:43 AM.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 01-15-2009, 09:50 PM   #4
ahagger
Junior Member
 
Join Date: Jan 2008
Posts: 18
Thanks: 2
Thanked 0 times in 0 posts
Default

Thanks for replying Bertrand. I actually already run TraceOrders = True in my code. I will run my scripts on live data tomorrow and provide the output for you to check out. When the problem does occur the output I have seen to date generated by TraceOrders just gives the standard "Cancelled pending exit order, since associated position is closed". Problem is that the associated ShortEntryOrder2 position isn't closed. I do not know why it cancels the ShortStopOrder2 only to say that it seems to occur when the ShortEntryOrder1 which is a 2 contract position is filled in single contracts (ie. two rows in the Executions Tab). Previously mentioned when run on historical data the trace orders output looks and behaves correctly also when run on live data and ShortEntryOrder1 generates 1 row, places a 2 in the Qty column in the Executions Tab everything works correctly.
ahagger is offline  
Reply With Quote
Old 01-16-2009, 05:52 AM   #5
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
Default

Hi ahagger, yes please post the TraceOrders output here for review. It may have to do with your order.filled parameter as quantity in the order, if this is invalid or not supplied the full position will be exited.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 01-16-2009, 12:22 PM   #6
ahagger
Junior Member
 
Join Date: Jan 2008
Posts: 18
Thanks: 2
Thanked 0 times in 0 posts
Default

Hi Bertrand here is the trace orders output.

16/01/2009 9:28:54 AM Entered internal PlaceOrder() method at 16/01/2009 9:28:54 AM: Action=SellShort OrderType=Limit Quantity=2 LimitPrice=463.8 StopPrice=0 SignalName='MyOracleShortEntry1' FromEntrySignal=''
16/01/2009 9:28:54 AM Entered internal PlaceOrder() method at 16/01/2009 9:28:54 AM: Action=SellShort OrderType=Limit Quantity=1 LimitPrice=463.8 StopPrice=0 SignalName='MyOracleShortEntry2' FromEntrySignal=''
16/01/2009 9:28:56 AM Entered internal PlaceOrder() method at 16/01/2009 9:28:56 AM: Action=BuyToCover OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=464.6 SignalName='MyOracleShortStop2' FromEntrySignal='MyOracleShortEntry2'
16/01/2009 9:28:56 AM Entered internal PlaceOrder() method at 16/01/2009 9:28:56 AM: Action=BuyToCover OrderType=Stop Quantity=2 LimitPrice=0 StopPrice=464.6 SignalName='MyOracleShortStop1' FromEntrySignal='MyOracleShortEntry1'
16/01/2009 9:28:56 AM Entered internal PlaceOrder() method at 16/01/2009 9:28:56 AM: Action=BuyToCover OrderType=Limit Quantity=2 LimitPrice=463.4 StopPrice=0 SignalName='MyOracleShortTarget' FromEntrySignal='MyOracleShortEntry1'
16/01/2009 9:30:04 AM Cancelled pending exit order, since associated position is closed: Order='09447b3ff67443748adb42b3ae4b7b03/Sim103' Name='MyOracleShortStop1' State=Accepted Instrument='TF 03-09' Action=BuyToCover Limit price=0 Stop price=464.6 Quantity=2 Strategy='SystemOracle' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='09447b3ff67443748adb42b3ae4b7b03' Gtd='01/12/2099 12:00:00 AM'
16/01/2009 9:30:04 AM Cancelled pending exit order, since associated position is closed: Order='3d80612553b44516ab3ae22b7681c43f/Sim103' Name='MyOracleShortStop2' State=Accepted Instrument='TF 03-09' Action=BuyToCover Limit price=0 Stop price=464.6 Quantity=1 Strategy='SystemOracle' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='3d80612553b44516ab3ae22b7681c43f' Gtd='01/12/2099 12:00:00 AM'
ahagger is offline  
Reply With Quote
Old 01-16-2009, 01:11 PM   #7
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

ahagger,

Do you have a simple-as-possible strategy that demonstrates this? We would like to test it on our end and are not sure how you have coded yours. Thank you.
NinjaTrader_Josh is offline  
Reply With Quote
Old 01-16-2009, 01:19 PM   #8
ahagger
Junior Member
 
Join Date: Jan 2008
Posts: 18
Thanks: 2
Thanked 0 times in 0 posts
Default

Hi Josh,
I will try and put something together. As mentioned previously it doesn't happen all the time only when the rows in the Executions tab look like this;

Instrument Action Qty Price Time ID E/X Position Order ID Name Commission Rate Account Connection
TF 03-09 Sell 1 463.8 16/01/2009 9:28 e146643734544fbbaa17e51d812d61d9 Entry 1S f33ac1a3c3284ace916407ee669af953 MyOracleShortEntry1 0 1 Sim103 Mirus-Live
TF 03-09 Sell 1 463.8 16/01/2009 9:28 c0d422ce0ca54db9a598e6a5f94abafa Entry 2S 6e29a5333d9b468a9bd326f5c7a07be4 MyOracleShortEntry2 0 1 Sim103 Mirus-Live
TF 03-09 Sell 1 463.8 16/01/2009 9:28 2df3c6edbd1e4523b1ffe36a1e4d8199 Entry 3S f33ac1a3c3284ace916407ee669af953 MyOracleShortEntry1 0 1 Sim103 Mirus-Live
TF 03-09 Buy 2 463.4 16/01/2009 9:30 c51d1d76b4b844bd9ebcc8b6831b53a8 Exit 1S 80c5c57d3d7f4cbaaa63aa605c38b333 MyOracleShortTarget 0 1 Sim103 Mirus-Live
ahagger is offline  
Reply With Quote
Old 01-16-2009, 01:34 PM   #9
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

Understood. If you are able to get it to reproduce at will, that scenario would be extremely helpful. Thank you.
NinjaTrader_Josh is offline  
Reply With Quote
Old 01-16-2009, 01:42 PM   #10
ahagger
Junior Member
 
Join Date: Jan 2008
Posts: 18
Thanks: 2
Thanked 0 times in 0 posts
Default

Hi Josh,

Attached is a strategy which should produce examples of the problem. Try testing it on the TF 03-09 contract on an 89 tick chart.
Attached Files
File Type: zip NTSupport.zip (6.6 KB, 5 views)
ahagger is offline  
Reply With Quote
Old 01-16-2009, 01:53 PM   #11
ahagger
Junior Member
 
Join Date: Jan 2008
Posts: 18
Thanks: 2
Thanked 0 times in 0 posts
Default

Forgot to mention Entry Handling should be set to UniqueEntries.
ahagger is offline  
Reply With Quote
Old 01-16-2009, 03:25 PM   #12
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

ahagger,

Realtime? Backtesting? Do you have a replay file and a timestamp where your issue consistently occurs?
NinjaTrader_Josh is offline  
Reply With Quote
Old 01-16-2009, 03:51 PM   #13
ahagger
Junior Member
 
Join Date: Jan 2008
Posts: 18
Thanks: 2
Thanked 0 times in 0 posts
Default

Realtime. I don't have a recent replay file. To reproduce the issue in replay mode I assume I will need to wait to Monday to record some data??. I ran the strategy I sent you on TF 03-09 89 tick and it produced the issue when it placed these orders;

Instrument Action Qty Price Time ID E/X Position Order ID Name Commission Rate Account Connection
TF 03-09 Buy 1 462.6 16/01/2009 14:35 125453905da745179b1730f4775ce63f Entry 1L 38deae3f343f4df48919865a13bdc738 MyNTSupportLongEntry1 0 1 Sim101 Mirus-Live
TF 03-09 Buy 1 462.6 16/01/2009 14:35 092b793f636c4cdbb4fbb21fda1302db Entry 2L f3d7d632274b48d9bbe90edb31b3af88 MyNTSupportLongEntry2 0 1 Sim101 Mirus-Live
TF 03-09 Buy 1 462.7 16/01/2009 14:35 6c3c3fee8e144a7eb468aecbb3786013 Entry 3L 38deae3f343f4df48919865a13bdc738 MyNTSupportLongEntry1 0 1 Sim101 Mirus-Live
TF 03-09 Sell 1 463 16/01/2009 14:35 319a5dc88c3546418de1092946e8e74e Exit 2L 9cb4f69919104463aa9aabe9570bad2e MyNTSupportLongTarget 0 1 Sim101 Mirus-Live
TF 03-09 Sell 1 463 16/01/2009 14:35 8979cab3cea6425fab5360a6431fef70 Exit 1L 9cb4f69919104463aa9aabe9570bad2e MyNTSupportLongTarget 0 1 Sim101 Mirus-Live
ahagger is offline  
Reply With Quote
Old 01-16-2009, 03:59 PM   #14
ahagger
Junior Member
 
Join Date: Jan 2008
Posts: 18
Thanks: 2
Thanked 0 times in 0 posts
Default

The timestamp on the orders below is Chicago time.
ahagger is offline  
Reply With Quote
Old 01-16-2009, 04:03 PM   #15
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

ahagger,

We will take a look at it, but it may be till after the weekend before we can conclude 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
Order cancelled when using liveUntilCancelled ntVic Automated Trading 21 12-23-2008 02:34 PM
My position disappeared - stop cancelled tradejockey SuperDOM and other Order Entry Windows 2 07-31-2008 07:44 PM
Cancelled custom managed order SteveB Strategy Development 2 03-27-2008 05:42 AM
CalculateMode.Percent stop loss gets cancelled suedeuno Strategy Analyzer 9 06-04-2007 11:18 PM
Cancelled order MrBaffalo Strategy Development 2 04-26-2007 05:44 AM


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