View Full Version : two opposing entry limit orders?
auspiv
12-31-2008, 02:07 AM
the internal order handling rules are currently preventing me from trying an idea out. how should I go about placing two opposing orders for something like the following?
EnterLongLimit(bidprice, "buy bid");
EnterShortLimit(askprice, "sell ask");
NinjaTrader_Ben
12-31-2008, 08:22 AM
Hello,
This is expected behavior. You will need to build a condition that triggers when price has reached the price that you would have otherwise placed the Limit order.
Note you cannot place simultaneous opposing order in NinjaScript.
beastment
01-03-2009, 10:35 PM
I've just run into the same problem trying to set up a straddle strategy. Basically:
EnterLongStop(highpoint, "we broke resistance");
EnterShortStop(lowpoint, "we broke support");
I assume the purpose of the internal order handling rule that stops me from doing this is so that I don't accidentally have both orders trigger and hence not know what, if any, position I'm in.
It would be nice if instead of having this rule NT could automatically link the two orders OCO, or alternatively allow the rule to be turned off.
NinjaTrader_Ben
01-04-2009, 08:58 AM
Hello,
Yes, again this is expected behavior: two opposing orders/positions.
I will send your suggestion to our development department for consideration. Thank you!
auspiv
02-03-2009, 02:38 PM
after trying to come up with a solution for placing two opposing orders, i gave up.
i'd like to request a feature that allows this type of behavior, like something in the initialize section "InternalOrderHandling.AllowOppositeOrders = true".
thank you.
NinjaTrader_Josh
02-03-2009, 02:42 PM
Thank you for the suggestion. Currently you cannot place simultaneous opposing orders in the same market from the same strategy.
jonmoron
02-28-2010, 02:27 PM
Josh,
Is this still the case with NT6.5 or NT7?
Thanks!
jon
Thank you for the suggestion. Currently you cannot place simultaneous opposing orders in the same market from the same strategy.
NinjaTrader_Ben
02-28-2010, 08:29 PM
Hello,
Since you are asking about NT7, I will have someone reply to you on Monday. Thank you for your patience.
For NT6.5, it is still true.
jonmoron
03-08-2010, 06:38 PM
Ben,
Has anyone gotten to this yet? I would like to create one OCO order and handle the cancelling of the order on my own. However, it seems like I cannot short and go long (via two opposing stop or limit orders within the same strategy). Is this true?
This is what I want:
At a certain time, I want to submit an two orders (one short, one long).
If one gets filled, I want to cancel the opposing order.
I understand I will need to handle the cancelling using OnOrderUpdate or OnExecution. If this is not allowed, then what is the purpose behind EntriesPerDirection? I'm essentially placing the same quantity on opposing sides. Once a fill occurs on one side, I will cancel the working order via CancelOrder.
Again, if this is not possible (entering opposing limit or stop orders) then why have EntriesPerDirection??
thanks!
jon
Hello,
Since you are asking about NT7, I will have someone reply to you on Monday. Thank you for your patience.
For NT6.5, it is still true.
NinjaTrader_Bertrand
03-09-2010, 04:49 AM
Jon, with this approach you're running into the Internal Order Handling Rules - http://www.ninjatrader-support.com/HelpGuideV6/Overview36.html (bottom section here).
Those exist in NT 6.5 and still exist per default in NT7, however with NT7 we also offer a completely new unmanaged order submission feature where you could custom code exactly what you need using the SubmitOrder, ChangeOrder and CancelOrder methods in NinjaScript.
http://www.ninjatrader.com/webnew/NT7/NinjaTrader7.html
New Unmanaged Order Submission
In 6.5 some users were burdened with our "Internal Order Handling" rules. We have introduced unmanaged order submission which bypasses the convenience of our order handling layer. This lower level of programming allows you to do what you want relative to order submission/management without any limitations other than any imposed by your broker. There are only three methods, SubmitOrder(), ChangeOrder() and CancelOrder(). You then get the flexibility of managing your orders how you see fit and optionally handling rejections.
jonmoron
03-09-2010, 05:00 AM
Bertrand,
So with NT7 and the unmanaged order submission feature, I can SubmitOrder() two limit orders on opposing sides withing 1 strategy for the same market?
thanks!
jon
Jon, with this approach you're running into the Internal Order Handling Rules - http://www.ninjatrader-support.com/HelpGuideV6/Overview36.html (bottom section here).
Those exist in NT 6.5 and still exist per default in NT7, however with NT7 we also offer a completely new unmanaged order submission feature where you could custom code exactly what you need using the SubmitOrder, ChangeOrder and CancelOrder methods in NinjaScript.
http://www.ninjatrader.com/webnew/NT7/NinjaTrader7.html
New Unmanaged Order Submission
In 6.5 some users were burdened with our "Internal Order Handling" rules. We have introduced unmanaged order submission which bypasses the convenience of our order handling layer. This lower level of programming allows you to do what you want relative to order submission/management without any limitations other than any imposed by your broker. There are only three methods, SubmitOrder(), ChangeOrder() and CancelOrder(). You then get the flexibility of managing your orders how you see fit and optionally handling rejections.
NinjaTrader_Bertrand
03-09-2010, 05:12 AM
Yes, as with Unmanaged set to 'true' in the Strategy Initialize() you would not get 'ignored' orders then as the Internal Order Handling Rules are not at play then under the hood.
jonmoron
03-09-2010, 07:40 AM
Bertrand,
Beautiful! This is perfect. I tested this and it works nicely.
Now moving on to supporting StopLoss and ProfitTarget collars on all unmanaged orders. I don't suppose I could use some of the NT functionality for this on an unmanaged strategy (like setStopLoss or setProfitTarget)?
THANKS!
jon
Yes, as with Unmanaged set to 'true' in the Strategy Initialize() you would not get 'ignored' orders then as the Internal Order Handling Rules are not at play then under the hood.
NinjaTrader_Bertrand
03-09-2010, 07:55 AM
Correct, in unmanaged strategies only SubmitOrder, CancelOrder and ChangeOrder can be called...as their no NT signal tracking being applied and used. For the 'freedom' you gain you have to self manage order tracking aspects then in your code (storing as IOrder references).
jonmoron
03-09-2010, 09:01 AM
Bertrand,
I was trying to have my cake and eat it too. In any case, how do I monitor the last price? NT needs more documentation regarding this NT7 feature.
thanks!
jon
Correct, in unmanaged strategies only SubmitOrder, CancelOrder and ChangeOrder can be called...as their no NT signal tracking being applied and used. For the 'freedom' you gain you have to self manage order tracking aspects then in your code (storing as IOrder references).
NinjaTrader_Bertrand
03-09-2010, 09:04 AM
Jon, yes the NT7 docs and helpguide is still work in progress at this point in time. For monitoring price / last tick, just use Close[0] with CalculateOnBarClose = false.
jonmoron
03-09-2010, 10:42 AM
Doh! Of course. Sometimes when I start delving into the details, I forget the obvious. Thanks Bertrand and the rest of your team for all the help.
jon
Jon, yes the NT7 docs and helpguide is still work in progress at this point in time. For monitoring price / last tick, just use Close[0] with CalculateOnBarClose = false.
ariliveitup
03-16-2010, 11:14 AM
How do i do this?
I guess I have run into a similar issue which is hopefully fixed in Ninja 7.
http://www.ninjatrader-support2.com/vb/showthread.php?p=152162#post152162
I had started building the strategy in Ninja 7, however I have run into CHarting and rollover issues in 7.
http://www.ninjatrader-support2.com/vb/showthread.php?p=151945#post151945
So, assuming I can get charting issue fixed in Ninja 7, I definitely need the option to fire orders in multiple directions. Hence I am asking
1. How to set Unmanaged to true and
2. If I have to manage stop orders myself and the Ninja internal stop losses are not being managed, how do i maintain references to these orders
Thanks very much in advance
NinjaTrader_Bertrand
03-16-2010, 11:25 AM
ariliveitup, set Unmanaged to true in the Initialize() of your strategy. This will deactivate the Internal Order Handling Rules, answered your other post as well, believe you're running into those on 65.
Correct, there's then no signal tracking by NT, you could use IOrder objects to track and manage your orders then by collecting their tokens.
symphys
03-16-2010, 03:57 PM
I would like to submit an OCO Order in a strategy. With or without internal stuff.
How can I do that?
jonmoron
03-16-2010, 03:59 PM
symphys, try using the OCO property on the two orders you want to tie. Place the same string value in the two orders and enjoy!
I would like to submit an OCO Order in a strategy. With or without internal stuff.
How can I do that?
symphys
03-16-2010, 04:23 PM
Do I understand you correctly that I need to use:
EnterLongStop(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double stopPrice, signalNameOCO)
EnterShortStop(....., signalNameOCO)
So the string signalName = signalNameOCO needs to be the same?
NinjaTrader_Josh
03-16-2010, 04:47 PM
symphys,
You cannot OCO entry orders in the opposite direction. You need to submit one or the other and as price moves closer to the other direction cancel the first then submit the second.
symphys
03-16-2010, 04:55 PM
That is very sad, it can be done in SuperDOM.
symphys
04-21-2010, 06:23 AM
What is the best place to use Unmanaged = true, Initialize() or OnStartUp() ?
And please add OCO in a strategy would be very appreciated!
jonmoron
04-21-2010, 06:25 AM
What is the best place to use Unmanaged = true, Initialize() or OnStartUp() ?
I use it in Initialize().
This is a NT7 feature only.
symphys
04-21-2010, 08:34 AM
In SubmitOrder() there is an ocoID, can this be used to submit opposite OCO orders?
How can I generate one?
NinjaTrader_Bertrand
04-21-2010, 08:38 AM
Yes, you can link orders through this string - http://www.ninjatrader.com/support/helpGuides/nt7/submitorder.htm?zoom_highlightsub=SubmitOrder
zwoop
05-03-2010, 04:06 PM
Seems like there are lots of people wanting to do this. Would be nice if someone that has coded this would share there code for others to discuss.
jonmoron
05-03-2010, 04:14 PM
Seems like there are lots of people wanting to do this. Would be nice if someone that has coded this would share there code for others to discuss.
Zwoop,
What exactly do you want to see examples of? I may be able to provide some.
zwoop
05-04-2010, 12:22 AM
Hi j, I want to set two simultaneous orders in my system. One long order will be filled if High of the day is broken and one short will be filled if the low of the day is broken. So if the high is broken first the short order should be canceld and vice versa. Then after this order is placed i want to put a stop at low-1tic and at the same time if that stop is hit i want to reverse my order at that point (guess that would be a OCO order). As i understand this has to be done with unmangaed orders and im not sure how to manage them and trac them as i want to be able to have more then one possition open at a time in my strategy.
NinjaTrader_Bertrand
05-04-2010, 06:24 AM
zwoop, correct for placing those entry orders as OCO bracket you would need to use NT7's unmanaged approach, so you don't run into the order handling rules. However with going 'unmanaged' there's no order tracking by NinjaTrader done, so you would need to capture / store IOrder references yourself for this.
To simplify you also could work in the managed submission scheme and only place one needed order for the bracket by monitoring the last price in reference to your entry points and then issuing / canceling orders as needed.