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 CortexZenUSA, Today, 12:53 AM
|
0 responses
1 view
0 likes
|
Last Post
by CortexZenUSA
Today, 12:53 AM
|
||
Started by CortexZenUSA, Today, 12:46 AM
|
0 responses
1 view
0 likes
|
Last Post
by CortexZenUSA
Today, 12:46 AM
|
||
Started by usazencortex, Today, 12:43 AM
|
0 responses
5 views
0 likes
|
Last Post
by usazencortex
Today, 12:43 AM
|
||
Started by sidlercom80, 10-28-2023, 08:49 AM
|
168 responses
2,265 views
0 likes
|
Last Post
by sidlercom80
Today, 12:05 AM
|
||
Started by Barry Milan, Yesterday, 10:35 PM
|
3 responses
11 views
0 likes
|
Last Post Yesterday, 11:58 PM |
Comment