Thanks!
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Cancel unfilled Auto order not working ..need help
Collapse
X
-
I'd be interested in this as well as I'm having the exact same problem cancelling an order. In fact, my strategy works just like the one from the OP, ie if the order hasn't been filled after the bar that generated it has closed, then I'd like to cancel it. I've tried to import the code snippet created by NinjaTrader_Ray named "Test" (thanks Ray), but I'm getting an error message when importing it, so this didn't help much I'm afraid.Originally posted by MrTicks View PostHi pdawg - Did you find a solution to the orderID does not exist entry in your logs? If so, could you share the code that solved the issue?
It would be great to have a generic example of a strategy that cancels an order if certain criteria are met (for example if the order hasn't been filled after one bar) in the Ninja Help section as there's only very little information available about this command and it seems that I'm not the only one struggling with it.
It's not about debugging the code or adding "print" commands, it's about learning from an actual example.
Thanks.Last edited by laocoon; 04-09-2013, 12:49 AM.
Comment
-
Hello laocoon,
I have changed the sample code so that it is compatible inside of NinjaTrader 7 so that you can have an example code of this.
To Import
1. Download the attached file to your desktop
2. From the Control Center window select the menu File > Utilities > Import NinjaScript
3. Select the downloaded file
Note that on any files that say "File already exists on your PC" that start with an "@" symbol are the ones that came preloaded inside of NinjaTrader so you would say "No" so that you do not override those files.Attached FilesJCNinjaTrader Customer Service
Comment
-
I've tested the sample code and it obviously works well, but I'm really at a loss when it comes to adding a very simple condition to the "Cancel" command.
This is Ray's / JC's original code:
if (!orderPlaced && my conditions here)
{
orderId = GetAtmStrategyUniqueId();
AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.StopLimit,High[0]+1*TickSize,High[0]+1*TickSize,TimeInForce.Day, orderId, "test", "testStrategyIdValue");
orderPlaced = true;
}
else
AtmStrategyCancelEntryOrder(orderId);
}
Now, if I add the condition on which the order shall be cancelled, ie that the bar following the signal doesn't make a higher high, I get the following error message: Missing orderId parameter.
All I modified was this:
else if (High[0] <= High[1])
{
AtmStrategyCancelEntryOrder(orderId);
}
Any pointers as to what I'm missing here would be greatly appreciated.Last edited by laocoon; 04-10-2013, 06:14 AM.
Comment
-
Hello laocoon,
I am not having any issues placing the "else if (High[0] <= High[1]) " and canceling the order. You may want to add some checks to make sure you have a proper "orderId" before trying to call a cancel like in the "SampleAtmStrategy" strategy that comes preloaded inside of NinjaTrader.JCNinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
668 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
377 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
110 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
575 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
580 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment