Thanks pal
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Weird behavior of this simple Exit Long order
Collapse
X
-
Originally posted by NinjaTrader_Lance View Post
Thanks pal
-
The snippet that solved
Code: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:
-
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:
Code:xlEntryOrder = SubmitOrder(0, OrderAction.Sell, OrderType.Limit, Qty, priceEntry, 0, "", "Exit Long");
Code: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 leunating, Today, 12:56 AM
|
2 responses
17 views
0 likes
|
Last Post
by leunating
Today, 10:08 PM
|
||
Started by tmk-c, 07-19-2017, 11:29 PM
|
6 responses
1,687 views
0 likes
|
Last Post Today, 09:27 PM | ||
Started by Trader4Life, Today, 09:20 PM
|
0 responses
5 views
0 likes
|
Last Post
by Trader4Life
Today, 09:20 PM
|
||
Started by WileCoyote, Today, 08:26 PM
|
0 responses
8 views
0 likes
|
Last Post
by WileCoyote
Today, 08:26 PM
|
||
Started by madankumars, 11-18-2019, 11:12 AM
|
10 responses
176 views
0 likes
|
Last Post Today, 06:56 PM |
Leave a comment: