![]() |
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: Jul 2007
Location: Fairfax, VA
Posts: 216
Thanks: 0
Thanked 0 times in 0 posts
|
I'm working on a breakout long/short strategy. It is using EnterLongStop and EnterShortStop to submit the entry orders. Obviously, only one of those can be active at a time. I am seeing the above error in the log. I have read the help section it refers to.
The pseudocode for my strategy would be like this: if (flat and Close[0] above mean) EnterLongStop() else if (flat and Close[0] below mean) EnterShortStop() else do other stuff This means that the orders will be submitted every bar, which is my understanding of what I have to do to keep them alive. It also means I may switch directions: submit an EnterShortStop the bar after an EnterLongStop as long as I am still flat. Per the help, which states: Quote:
|
|
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
The problem I suspect is...
Bar1 - Buy stop condition is true and submitted Bar2 - Buy stop condition is true and submitted Bar3 - Sell stop condition is true, order method called but ignored since buy stop likely has not yet been removed from internal queing etc... I will check if this is expected behaviour or if something could be done. I suspect its expecte since we really would want to see the 1st order cancelled prior to a new one submitted to protect from unwanted fills etc...
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
After further investigation, here is what is happening using the same example as my prior post.
On OnBarUpdate() processing for Bar3, its not until after the user code contained in the OnBarUpdate() method is processed that we cancel the original BuyStop. This is because we need to process the code to see if the original BuyStop has been resubmitted. Therefore, in this processing of OnBarUpdate() the sell stop is then ignored since of course the buy stop does not expire until after your user code is processed. So what can you do? I can think of two potential workarounds. - Use unique signal names for your long and short entries. Then Set EntryHandling property to UniqueEntries intstead of AllEntries. - In 6.5 we have introduced order overloads that have a parameter named "liveUntilCancelled". Use this overload and set this parameter to a value of true. On Bar3, call the CancelOrder() method first on the buy stop and then issue the sell stop. I believe this order cancellation will internally clear some signal queing/tracking that will clear the path for the sell stop order to go through
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#4 | |
|
Senior Member
Join Date: Jul 2007
Location: Fairfax, VA
Posts: 216
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks for following up on this Ray.
Quote:
|
|
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Jul 2007
Location: Fairfax, VA
Posts: 216
Thanks: 0
Thanked 0 times in 0 posts
|
I've tried both of these out, with the same behavior (the order is ignored when I try to switch sides).
In my opinion, this should work the way I have coded it. If I was long, and wanted to go short, all I have to do is call EnterShort(). (I understand the technical details of why it is different wrt the outstanding order.) This seems like something the order management layer should handle (figuring out the orders which need to be cancelled based on the position, etc.) The net result of this right now for me is this strategy will be 1 bar (5 minutes) late catching a breakout if the market quickly changes direction. |
|
|
|
|
|
#6 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
As you have found out, my first potential workaround fails. I see now why that is and is expected. I will double check again on expected behaviour of my second workaround. I really thought that should work and need to check if I was wrong or if there is a bug here.
A third workaround would be to self monitor the stop prices and issue a market on breach of this price. I do understand the down side of this approach...just throwing more ideas out.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
Pete,
Could you PM me a simple as possible sample strategy to "dierk AT ninjatrader DOT com" which demonstrates that Ray's workaround fails? Additional info like strategy settings, data set etc. would help as well Thanks >> - In 6.5 we have introduced order overloads that have a parameter named "liveUntilCancelled". Use this overload and set this parameter to a value of true. On Bar3, call the CancelOrder() method first on the buy stop and then issue the sell stop. I believe this order cancellation will internally clear some signal queing/tracking that will clear the path for the sell stop order to go through
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#8 |
|
Senior Member
Join Date: Jul 2007
Location: Fairfax, VA
Posts: 216
Thanks: 0
Thanked 0 times in 0 posts
|
I will put that together at some point today and send it over.
|
|
|
|
|
|
#9 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
Next NT6.5 will hold a fix covering this issue in backtest mode. It should not have happened in live mode though. Thanks for providing the info to track down this one.
Dierk
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Entry order placed . . . has been ignored | whitmark | General Programming | 1 | 11-19-2007 11:57 AM |
| Can't Submit an Exit Order | yeneuro | Miscellaneous Support | 10 | 10-08-2007 08:23 AM |
| Submit Limit Entry Order and Stop Loss Order at same time? | aspTrader | Miscellaneous Support | 2 | 10-04-2006 02:40 AM |
| wait for entry order fill before placing stoplimit order | ratherBgolfing | Automated Trading | 2 | 03-27-2006 01:59 AM |