Thanks pal
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Weird behavior of this simple Exit Long order
Collapse
X
-
Almost writing at the same time. As you can see in my earlier post, I redesigned the routine, and it was that when you set the main order = null, it shouldn't do more comparison, that's why it did that run time errorOriginally posted by NinjaTrader_Lance View Post
Thanks pal
-
The snippet that solved
ThanksCode:if (xlEntryOrder != null && xlEntryOrder== execution.Order ) { if ( xlEntryOrder.OrderState == OrderState.Filled ) { CancelOrder(slEntryOrder); sEntryOrder = SubmitOrder(0, OrderAction.SellShort, OrderType.Limit, quant, priceEntry, 0, "", "Enter Short"); } else { ChangeOrder(slEntryOrder, Position.Quantity-xlEntryOrder.Filled, 0, (Position.AvgPrice-stop)); } if (xlEntryOrder.OrderState != OrderState.PartFilled ) { xlEntryOrder = null; } }
Leave a comment:
-
In this case you'll need to add print statements before and after the different if checks to see where the code is breaking.
Tips on debugging: http://www.ninjatrader.com/support/f...ead.php?t=3418
Let me know if I can further assist.
Leave a comment:
-
Lance, following your suggestion I've just simply erase all instructions after the statement of Par.Filled and Part.Filled and cancelled, and the same error...so it's not slEntryOrder..it must be something else that fails to read these normal statements.Originally posted by NinjaTrader_Lance View PostMy guess without debugging is that slEntryOrder is null at this point when its first called
Consider adding && slEntryOrder!= null before every changeorder check.
Let me know if I can further assist.
What I think is that I must set these instructions filtering conditions first with the typical: Filled, PartFilled and PartFilled-Cancelled statement and then in a logic breakdown trying not to repeat or interrupt the logic flow. When solved, I'll post itLast edited by pstrusi; 12-20-2013, 02:21 PM.
Leave a comment:
-
Lance, I appreciate very much your help. As soon as I can code it again I´ll let u know.
Leave a comment:
-
My guess without debugging is that slEntryOrder is null at this point when its first called
Consider adding && slEntryOrder!= null before every changeorder check.
Let me know if I can further assist.
Leave a comment:
-
Weird behavior of this simple Exit Long order
Hi Ninjas,
I got a situation here, which I've tried to discover the cause but still.
It's a simple rutine of exit a long position and cancelling its StopLoss. The script uses the unmanaged approach.
The order of exitLong:
The exit long rutine:Code:xlEntryOrder = SubmitOrder(0, OrderAction.Sell, OrderType.Limit, Qty, priceEntry, 0, "", "Exit Long");
If I just set and let the instruction for "Filled" then everything works perfectly, BUTCode:protected override void OnExecution(IExecution execution) { if (xlEntryOrder != null && xlEntryOrder== execution.Order ) { if ( xlEntryOrder.OrderState == OrderState.Filled) { CancelOrder(slEntryOrder); // Cancel the stop order xlEntryOrder = null; } if ( xlEntryOrder.OrderState == OrderState.PartFilled ) { ChangeOrder(slEntryOrder, Position.Quantity-xlEntryOrder.Filled, 0, (Position.AvgPrice-stop)); // Change the Stop order accordingly } if ( xlEntryOrder.OrderState == OrderState.Cancelled && xlEntryOrder.Filled > 0) { ChangeOrder(slEntryOrder, Position.Quantity-xlEntryOrder.Filled, 0, (Position.AvgPrice-stop)); xlEntryOrder = null; } } }
if I add the others PartFilled or Part.Filled and Cancelled, it just simple doesn't run, NT give the typical Run time error.
So any ideas why this?Tags: None
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CaptainJack, 05-29-2026, 05:09 AM
|
0 responses
246 views
0 likes
|
Last Post
by CaptainJack
05-29-2026, 05:09 AM
|
||
|
Started by CaptainJack, 05-29-2026, 12:02 AM
|
0 responses
158 views
0 likes
|
Last Post
by CaptainJack
05-29-2026, 12:02 AM
|
||
|
Started by charlesugo_1, 05-26-2026, 05:03 PM
|
0 responses
165 views
1 like
|
Last Post
by charlesugo_1
05-26-2026, 05:03 PM
|
||
|
Started by DannyP96, 05-18-2026, 02:38 PM
|
1 response
250 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 05-11-2026, 05:56 AM
|
0 responses
201 views
0 likes
|
Last Post
by CarlTrading
05-11-2026, 05:56 AM
|

Leave a comment: