protected override void OnOrderUpdate(IOrder order) { if ((lOrder != null && lOrder.Token == order.Token) || (sOrder != null && sOrder.Token == order.Token)) { Print("IN HERE"); if(lOrder.OrderState == OrderState.Filled || lOrder.OrderState == OrderState.PartFilled) { Print("Cancel 1"); CancelOrder(sOrder); }else if (sOrder.OrderState == OrderState.Filled || sOrder.OrderState == OrderState.PartFilled) { Print("Cancel 2"); CancelOrder(lOrder); } } } protected override void OnBarUpdate() { ...do some stuff... lOrder = EnterLongStop(0,true,BuySize, (High[0] + (BuyOffset*TickSize)),"Long"); sOrder = EnterShortStop(0,true,BuySize, (Low[0] - (BuyOffset*TickSize)),"Short"); ...do some stuff... }
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Problem with IOrder
Collapse
X
-
Problem with IOrder
What I am trying to accomplish is setup to stop orders one for a long and one for a short, then once one of them is hit I want to cancel the other order. When I add the code for the OnOrderUpdate method I never get a buy in and with some simple debugging I think the code for the OnOrderUpdate is killing the process somehow....any idea's....
Code:Tags: None
-
Originally posted by NinjaTrader_Ray View PostYou are likely violating our internal order handling rules. Please see the following link and scroll near bottom.
http://www.ninjatrader-support.com/H...verview36.html
Gotcha, thanks! I didn't realize the log on the control panel posted errors, I was wondering where to find any errors occurred! So after reading the rules it looks like I need to code market orders to accomplish what I am trying to do? The only problem with this is I won't be able to backtest correctly as in doing this I think I will have to use the methods GetCurrentAsk() and GetCurrentBid() which state they use the current (or last) bars close price. Any idea's on how to submit two orders in opposite directions as an OCO that will work for back testing? Thanks for the help!
Comment
-
fxRichard, I'm interested, did you ever get this working?
Gotcha, thanks! I didn't realize the log on the control panel posted errors, I was wondering where to find any errors occurred! So after reading the rules it looks like I need to code market orders to accomplish what I am trying to do? The only problem with this is I won't be able to backtest correctly as in doing this I think I will have to use the methods GetCurrentAsk() and GetCurrentBid() which state they use the current (or last) bars close price. Any idea's on how to submit two orders in opposite directions as an OCO that will work for back testing? Thanks for the help!
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by inanazsocial, Today, 01:15 AM
|
0 responses
2 views
0 likes
|
Last Post
by inanazsocial
Today, 01:15 AM
|
||
Started by trilliantrader, 04-18-2024, 08:16 AM
|
5 responses
22 views
0 likes
|
Last Post Today, 12:32 AM | ||
Started by Davidtowleii, Today, 12:15 AM
|
0 responses
3 views
0 likes
|
Last Post
by Davidtowleii
Today, 12:15 AM
|
||
Started by guillembm, Yesterday, 11:25 AM
|
2 responses
9 views
0 likes
|
Last Post
by guillembm
Yesterday, 11:58 PM
|
||
Started by junkone, 04-21-2024, 07:17 AM
|
9 responses
70 views
0 likes
|
Last Post
by jeronymite
Yesterday, 11:51 PM
|
Comment