EnterLongLimit(tradeParams.max, Bars.LastPrice); ExitLongLimit(tradeParams.max, Bars.LastPrice + TickSize * 2); ExitLongStopLimit(tradeParams.max, Bars.LastPrice - TickSize * 5);
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Can't place several orders
Collapse
X
-
Can't place several orders
In my strategy, when I got some signal, I want to enter into a position with current price and then set Take-limit-order and Stop-limit-order. I write this code:
And I only get placed the first order. How to place another two?Code:Tags: None
-
Hello Defake,
The ExitLongLimit and ExitLongStopLimit would not be placed until the entry order is filled.
Under tips at the following section of our helpguide for ExitLongLimit you will see,
This method is ignored if a long position does not exist
Please let us know if you need further assistance.Alan P.NinjaTrader Customer Service
-
Thanks for response! And sorry for late...Originally posted by NinjaTrader_AlanP View PostHello Defake,
The ExitLongLimit and ExitLongStopLimit would not be placed until the entry order is filled.
Under tips at the following section of our helpguide for ExitLongLimit you will see,
This method is ignored if a long position does not exist
Please let us know if you need further assistance.
Okay, I read example from http://ninjatrader.com/support/helpG...r_handling.htm
And try to repeat this in my strategy. But anyway I can't place exit orders even if the enter order is already filled.
Placing enter order:
And OnOrderUpdateFunction:Code:if (Position.Quantity == 0 && curOrder == null) { if (decision > 0) { curOrder = EnterLongLimit(tradeParams.max, Bars.LastPrice, "EnterOrder"); toLongOrder = true; } else if (decision < 0) { curOrder = EnterShortLimit(tradeParams.max, Bars.LastPrice, "EnterOrder"); toLongOrder = false; } }
I got the same situation with this code. Strategy can place enter orders, but when they are filled nothing happens. What am I doing wrong?Code:protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError) { // if exited from trade, clear all remaining orders (e.g. remaining stop order) if (order.Name == "ExitOrder" && orderState == OrderState.Filled) Orders.Clear(); // if Enter order is filled, place exit orders if (curOrder != null && order == curOrder && order.OrderState == OrderState.Filled) { if (toLongOrder) { ExitLongLimit(tradeParams.max, order.AverageFillPrice + TickSize * tradeParams.take, "ExitOrder", "EnterOrder"); ExitLongStopLimit(tradeParams.max, order.AverageFillPrice - TickSize * tradeParams.stop, "ExitOrder", "EnterOrder"); } else { ExitShortLimit(tradeParams.max, order.AverageFillPrice - TickSize * tradeParams.take, "ExitOrder", "EnterOrder"); ExitShortStopLimit(tradeParams.max, order.AverageFillPrice + TickSize * tradeParams.stop, "ExitOrder", "EnterOrder"); } curOrder = null; } }
Comment
-
Is there any information about this in your log? Have you looked?Originally posted by Defake View PostThanks for response! And sorry for late...
Okay, I read example from http://ninjatrader.com/support/helpG...r_handling.htm
And try to repeat this in my strategy. But anyway I can't place exit orders even if the enter order is already filled.
Placing enter order:
And OnOrderUpdateFunction:Code:if (Position.Quantity == 0 && curOrder == null) { if (decision > 0) { curOrder = EnterLongLimit(tradeParams.max, Bars.LastPrice, "EnterOrder"); toLongOrder = true; } else if (decision < 0) { curOrder = EnterShortLimit(tradeParams.max, Bars.LastPrice, "EnterOrder"); toLongOrder = false; } }
I got the same situation with this code. Strategy can place enter orders, but when they are filled nothing happens. What am I doing wrong?Code:protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError) { // if exited from trade, clear all remaining orders (e.g. remaining stop order) if (order.Name == "ExitOrder" && orderState == OrderState.Filled) Orders.Clear(); // if Enter order is filled, place exit orders if (curOrder != null && order == curOrder && order.OrderState == OrderState.Filled) { if (toLongOrder) { ExitLongLimit(tradeParams.max, order.AverageFillPrice + TickSize * tradeParams.take, "ExitOrder", "EnterOrder"); ExitLongStopLimit(tradeParams.max, order.AverageFillPrice - TickSize * tradeParams.stop, "ExitOrder", "EnterOrder"); } else { ExitShortLimit(tradeParams.max, order.AverageFillPrice - TickSize * tradeParams.take, "ExitOrder", "EnterOrder"); ExitShortStopLimit(tradeParams.max, order.AverageFillPrice + TickSize * tradeParams.stop, "ExitOrder", "EnterOrder"); } curOrder = null; } }
Comment
-
Hello Defake,
I would suggest adding print statements to check whether your conditions are becoming true. For example I would put a print statement above if(toLongOrder), Print(“Getting to this part”);, as well as within that block to see if it’s being considered and whether the if statement is becoming true. You could also print the value of your variables as well as what you are checking them against, for example Print(order.ToString());
I’ve provided a link to a youtube video which covers an example of using prints to understand behavior:
I’ve provided a link covering debugging which you may find helpful.
Debugging: http://ninjatrader.com/support/forum...ead.php?t=3418
Please let us know if you need further assistance.Alan P.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
62 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
134 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
75 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
45 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
50 views
0 likes
|
Last Post
|

Comment