![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Sep 2008
Posts: 185
Thanks: 20
Thanked 2 times in 2 posts
|
Hello,
I'm receiving this message in the log/output window http://screencast.com/t/MxKpUFnVM Is it preferable to allow the Internal Order Handling to cancel this target order as shown once the corresponding stop is hit? Or should I make a specific section of code to cancel these orders before the IOrder sequence gets to this point? The reason I'm asking is that I'll be attempting to code Overfill error avoidance in my strat. Any help is appreciated since I'll need to know where it is best to cancel or read the orderstate: i.e. OnOrderUpdate or OnExecution. Thanks, Kirk |
|
|
|
|
|
#2 | ||
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
zeller4,
I am happy to assist you. Quote:
Quote:
Please let me know if I may assist further.
Adam P.
NinjaTrader Customer Service |
||
|
|
|
|
The following user says thank you to NinjaTrader_AdamP for this post: |
|
|
|
#3 |
|
Junior Member
Join Date: Jan 2012
Posts: 26
Thanks: 0
Thanked 0 times in 0 posts
|
Hello,
If I have a long position on and I have a target price and a stop price in. How can I then cancel the stop price if my target price is filled ? Put another way can a stop be placed in conjuction with OCO ? And how do I use the OCO function? I am not using a script, these are manually entered. Thanks |
|
|
|
|
|
#4 | |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
Quote:
http://www.youtube.com/watch?v=kIHBYC15luc
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
|
#5 | |
|
Junior Member
Join Date: Jan 2012
Posts: 26
Thanks: 0
Thanked 0 times in 0 posts
|
Quote:
thanks |
|
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
mcorbett,
Thanks for your note. If you right click in the Chart trader or Dom before you place your stop and target, you can enable OCO, then place your orders, then right click again and uncheck OCO. Otherwise, please watch the video I have provided as it will allow you to create a ATM strategy that does this as well, however automated. Please let me know if I may assist further.
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Jan 2012
Posts: 26
Thanks: 0
Thanked 0 times in 0 posts
|
Hi,
Is it possible to just use the field in the control center labeled OCO? Thanks |
|
|
|
|
|
#8 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
mcorbett,
Here is our OCO documentation : http://www.ninjatrader.com/support/h...ng_orders3.htm You can use OCO in chart trader and the superdom.
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#9 |
|
Junior Member
Join Date: Jan 2012
Posts: 26
Thanks: 0
Thanked 0 times in 0 posts
|
Thank you.
I read it. However why is there an OCO field in the control center window? I was thinking there is an easy manula way to link orders, the OCO function as it stands is really just for intraday trades... |
|
|
|
|
|
#10 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
mcorbett,
If you are referring to the orders tab in the control center, this is just giving you the OCO ID so you can see which trades are grouped in OCO. Please let me know if I may assist further.
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#11 |
|
Junior Member
Join Date: Jan 2012
Posts: 26
Thanks: 0
Thanked 0 times in 0 posts
|
I see a blank space on the orders tab named "OCO".
It appears to be a place where I can input an order "ID" or token. Example, I were to put in a stop I could also include an "ID" here that would link it to the limit order. So if stop is hit limit would cancel..... sort of manual The tutorial is unclear... no idea what its trying to do |
|
|
|
|
|
#12 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
mcorbett,
ID's are generated by ninjatrader whenever you place an OCO order, there is no way to set them in the control center. OCO is enabled or disabled manually in the SuperDOM or ChartTrader. We have a video that covers how to do it. http://www.youtube.com/watch?v=DBuD2Lps46s
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#13 |
|
Senior Member
Join Date: Sep 2008
Posts: 185
Thanks: 20
Thanked 2 times in 2 posts
|
Hello,
I've developed a small script based on SampleCancelOrder so that I could learn how to avoid errors with Overfills. Here is a screenshot of the error message: http://screencast.com/t/1bDpZKpo I placed this code in the OnOrderUpdate to attempt to force an Overfill error. Code:
if (order.OrderState == OrderState.PendingCancel)
{
Print("26 - order.OrderState == OrderState.PendingCancel: "+DateTime.Now.ToString());
//placed here on purpose to force an Overfill condition
CancelOrder(entryOrder);
Print("26 ==================================");
}
Am I right in assuming the PendingCancel within OnOrderUpdate is the main area where overfill problems will surface? Or can they surface in OnExecution as well? Thanks, kz
Last edited by zeller4; 02-16-2012 at 01:51 PM.
|
|
|
|
|
|
#14 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Hi zeller4,
There's no specific handler used for generating overfills. Overfill is when an order is marked for cancellation and then filled. It can also happen when the strategy has competing orders sent at the same time, when only one should be filled. The main area where they will occur is with orders resting close near the market and cancel is sent for any reason: One pair of OCO is filled, position set to opened in opposite direction, autoexpirations, or you send CancelOrder(). I don't think you'll be able to reproduce an overfill on simulated account like you're doing. For an overfill the order must be filled in-between pending cancel and cancel. Unfortunately we do not have a strategy to provide you that will produce overfills on demand.
Ryan M
NinjaTrader Customer Service
Last edited by NinjaTrader_RyanM; 02-16-2012 at 03:35 PM.
|
|
|
|
|
|
#15 | |
|
Senior Member
Join Date: Sep 2008
Posts: 185
Thanks: 20
Thanked 2 times in 2 posts
|
Thanks for the explanation. My only reason for "mis-coding" to achieve an overfill was so that I can learn how to prevent them. The sample or code snippet of the method of checking a "resting-near-the-market" order would be beneficial.
Also, what do you mean by Quote:
My purpose of creating the indi was to get a better understanding from the print statements how the Internal Orders are processed in OnOrderUpdate vs. OnExecution. Also, is there any validity to the following? Or will it never occur? (I'm trying to understand why (or if) a fill state would have to be checked for something that is cancelled.) Code:
if (entryOrder_1a != null && entryOrder_1a == execution.Order)
{
if (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled == 0)
{//print or do something...
}
}
Last edited by zeller4; 02-16-2012 at 03:55 PM.
|
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Overfill Handling | guillembm | Miscellaneous Support | 4 | 02-29-2012 01:48 PM |
| OCO issues cancelling entry orders on partial fills | tony98 | Strategy Development | 3 | 01-31-2012 01:38 PM |
| ATM strategy stops on partially filled orders | arnonmoscona | ATM Strategies (Discretionary Trading) | 1 | 01-10-2012 06:31 AM |
| Retrieving partially filled OCO orders | billitin | Strategy Development | 10 | 07-15-2008 10:35 PM |
| Setting stops and Target orders | trader333 | ATM Strategies (Discretionary Trading) | 1 | 08-29-2007 07:37 AM |