![]() |
|
|||||||
| 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. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Jan 2008
Posts: 18
Thanks: 2
Thanked 0 times in 0 posts
|
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"); |
|
|
|
|
|
#2 |
|
Junior Member
Join Date: Jan 2008
Posts: 18
Thanks: 2
Thanked 0 times in 0 posts
|
I forgot to mention when the strategy is run on historical data it performs as expected.
|
|
|
|
|
|
#3 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
|
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
Bertrand
NinjaTrader Customer Service
Last edited by NinjaTrader_Bertrand; 01-15-2009 at 08:43 AM.
|
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Jan 2008
Posts: 18
Thanks: 2
Thanked 0 times in 0 posts
|
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.
|
|
|
|
|
|
#5 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
|
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.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Jan 2008
Posts: 18
Thanks: 2
Thanked 0 times in 0 posts
|
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' |
|
|
|
|
|
#7 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#8 |
|
Junior Member
Join Date: Jan 2008
Posts: 18
Thanks: 2
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#9 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Understood. If you are able to get it to reproduce at will, that scenario would be extremely helpful. Thank you.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#10 |
|
Junior Member
Join Date: Jan 2008
Posts: 18
Thanks: 2
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#11 |
|
Junior Member
Join Date: Jan 2008
Posts: 18
Thanks: 2
Thanked 0 times in 0 posts
|
Forgot to mention Entry Handling should be set to UniqueEntries.
|
|
|
|
|
|
#12 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
ahagger,
Realtime? Backtesting? Do you have a replay file and a timestamp where your issue consistently occurs?
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#13 |
|
Junior Member
Join Date: Jan 2008
Posts: 18
Thanks: 2
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#14 |
|
Junior Member
Join Date: Jan 2008
Posts: 18
Thanks: 2
Thanked 0 times in 0 posts
|
The timestamp on the orders below is Chicago time.
|
|
|
|
|
|
#15 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
ahagger,
We will take a look at it, but it may be till after the weekend before we can conclude anything.
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |