However the exit order has been executed, it seems somewhere another exit order with the same name and a different Token are being created. Any idea what may be causing the problem?
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Cancelled pending exit order, since associated...
Collapse
X
-
Cancelled pending exit order, since associated...
After running a backtest on a strategy with advanced orders i'm getting a slew of messages at the end of the TraceOrders that read like: 4/21/2009 11:00:45 AM Cancelled pending exit order, since associated position is closed: Order='NT-00002/Back101' Name='exit.0' State=Initialized Instrument='$USDJPY' Action=BuyToCover Limit price=0 Stop price=0 Quantity=1 Strategy='BAMMultiTemplate' Type=Market Tif=Gtc Oco='' Filled=1 Fill price=99.4 Token='59412ec6ba3e411abc6d7e5477d014c4' Gtd='12/1/2099 12:00:00 AM'
However the exit order has been executed, it seems somewhere another exit order with the same name and a different Token are being created. Any idea what may be causing the problem?Tags: None
-
From your output I am reading an "Exit on Close" order being submitted which closes all open positions. This is why any additional stops/targets/etc you may have had now receives the message you are seeing. If you do not wish to use "Exit on Close" please set that property to false in the strategy parameters.Josh P.NinjaTrader Customer Service
-
I have Exit on close set to false. Its only being reported because the backtest has finished the available data and the strategy has an open position and in the begining of OnExecution i have:
Print("executed: " + execution.Order.ToString());
The order being cancelled at the end of the run is:
Order='NT-00002/Back101' Name='exit.0' State=Initialized
But in line number 11 of the output the same order, but with a different token has already been executed:
Order='NT-00002/Back101' Name='exit.0' State=Filled
Only seems to be a problem when the exit orders are placed as more then one market order. The position is being entered with two separate market orders, and closed with two separate market orders. It appears that this message comes at the end for any closing market order that does not flatten the position.
Say you have:
entry.0
entry.1
entry.2
and then exit with
exit.0
exit.1
exit.2
exit.0 and exit.1 will generate Cancelled pending exit order... messages.
Comment
-
Entries:
Code:[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]for[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] i = 0; i < entries; i++) { [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (disposition == 1) entry[i] = EnterLong(bip, increment, [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"entry."[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + i); [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (disposition == -1) entry[i] = EnterShort(bip, increment, [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"entry."[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + i); Print([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"submitted: "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + entry[i].ToString()); [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]; } [/SIZE]
Code:[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]for[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] i = 0; i < entries; i++) { [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (entry[i] != [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] && (entry[i].OrderState == OrderState.Filled || entry[i].OrderState == OrderState.PartFilled)) { [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (entry[i].Action == Action.Buy) exit[i] = ExitLong(bip,entry[i].Filled,[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"exit."[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + i,entry[i].Name); [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (entry[i].Action == Action.SellShort) exit[i] = ExitShort(bip,entry[i].Filled,[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"exit."[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + i,entry[i].Name); [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (debug) Print([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"submitted: "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + exit[i].ToString()); } [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (entry[i] != [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] && entry[i].OrderState == OrderState.Working) { [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (debug) Print([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"cancelling: "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + entry[i].ToString()); [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]try[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] {CancelOrder(entry[i]);} [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]catch[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]Exception[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] e) { Print(e.ToString()); } } } [/SIZE]
Code:[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (debug) Print([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"executed: "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + execution.Order.ToString()); [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (exit[i] != [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] && exit[i].Token == execution.Order.Token && execution.Order.OrderState == OrderState.Filled) { [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]try[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] {CancelOrder(entry[i]);} [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]catch[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]Exception[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] e) { Print(e.ToString()); } entry[i] = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]; [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]try[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] {CancelOrder(exit[i]);} [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]catch[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]Exception[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] e) { Print(e.ToString()); } exit[i] = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]; }[/SIZE]
Comment
-
darckeen,
Unfortunately use of arrays is beyond what we can support. Please simplify your case down and not use arrays. Try again with just a very simple setup where you specifically type out the entry and the exit signal names. Please try with only one market direction at a time too. Thank you.Josh P.NinjaTrader Customer Service
Comment
-
Okies here is a simplified version and associated TraceOrder output.
Thanks for your help.Last edited by darckeen; 04-21-2009, 03:22 PM.
Comment
-
Actually was able pair it down a good bit more. This code will execute one trade and will generate the afore mentioned message at the end of the run. As you can see from the output somehow an exit order is being created internally that is the same as the filled exit1 order except that it has a different token.Last edited by darckeen; 04-22-2009, 04:37 AM.
Comment
-
Thanks alot Josh, appreciate your looking into this. If anything trying to figure out why this was happening gave me a much better understanding of how the internal order management system works. What i've found is that a system that uses multiple advanced orders that works live is pretty darn hard to implement lol. Most of the difficulty i've encountered is due to the internal order queing where it seems to square a position when exit orders are submitted in OnBarUpdate then entry orders are submitted in the same OnBarUpdate. What seems to happen is that as soon as an entry order is recieved NT submits an internally generated "Close position" order. This will be processed along with the other exit orders and the position will get out of whack. Is there anyway to disable these internally generated "Close position" orders?
Comment
-
darckeen,
You cannot disable them. The "Close position" orders only occur if you were in a long position and you submitted a enter short order. The vice versa case would apply also. What NT does is reverse your position for you. If you do not want to reverse submit an ExitLong() instead of EnterShort().Josh P.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by jaybedreamin, Today, 05:56 PM
|
0 responses
3 views
0 likes
|
Last Post
by jaybedreamin
Today, 05:56 PM
|
||
Started by DJ888, 04-16-2024, 06:09 PM
|
6 responses
18 views
0 likes
|
Last Post
by DJ888
Today, 05:12 PM
|
||
Started by Jon17, Today, 04:33 PM
|
0 responses
1 view
0 likes
|
Last Post
by Jon17
Today, 04:33 PM
|
||
Started by Javierw.ok, Today, 04:12 PM
|
0 responses
6 views
0 likes
|
Last Post
by Javierw.ok
Today, 04:12 PM
|
||
Started by timmbbo, Today, 08:59 AM
|
2 responses
10 views
0 likes
|
Last Post
by bltdavid
Today, 04:10 PM
|
Comment