![]() |
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 |
|
Member
Join Date: Apr 2008
Location: Seattle, WA
Posts: 47
Thanks: 0
Thanked 1 time in 1 post
|
I'm having difficulty getting my exits to work the way I intend them to. Basically, I want a short/long position closed out the instant price action crosses an SMA. Using EnterShortStop, this works for the entry, but not the exit thus far.
PHP Code:
I can use ExitShort currently, shown in Condition 2, however it always takes me out in strange places (subsequent bars, open of current bar, strange), always later than I want. Anyone able to show me some code using ExitShortStop to accomplish what I'm shooting for here? Thanks in advance ![]() Steve
Last edited by stevescott05; 07-15-2009 at 12:44 AM.
|
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
|
Steve, when you run this with TraceOrders = true in the Initialize() you'll most likely find orders ignored as you run into the 'Internal Order Handling Rules' with - http://www.ninjatrader-support.com/H...verview36.html
This is because your SetStopLoss is used together with the ExitShortStop you attempt to place (botton section of the link above). For NinjaTrader 7, we add the 'Unmanaged Order Submission' feature - 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. http://www.ninjatrader.com/webnew/NT7/NinjaTrader7.html
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Apr 2008
Location: Seattle, WA
Posts: 47
Thanks: 0
Thanked 1 time in 1 post
|
I attempted to resolve the OrderHandling Issue by using something like this, but to no avail:
PHP Code:
The results I've been seeing are always pretty much the same: One entry at the beginning of my historical data with either (1) a long, flat, dotted line connecting the entry to an exit point 50 days later after price returned to same level. Or, (2) no dotted line, and no additional trade activity, because the order never closed by exit order (and I have it set to only trade one contract at a time). What to do? Anyone have an idea how to code this? I just want the order closed immediately upon crossing an SMA. I don't want to see an exit on the open after a bar which closed after CrossAbove() or CrossBelow() the SMA. That's already too late for me. I want to see markers in the middle of the bar where it crossed the SMA. Again, thanks in advance for any and all ideas! Steve
|
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
|
stevescott05, since you cannot cancel SetStopLoss you would need to work with IOrder objects on this to CancelOrder() your offending stop before you place the 'SMACrossExit' - http://www.ninjatrader-support.com/H...ncelOrder.html
http://www.ninjatrader-support2.com/...ead.php?t=7499 To backtest your strategy with more realistic intrabar fills, please see this sample here - http://www.ninjatrader-support2.com/...ead.php?t=6652
Bertrand
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ExitShortStop fired again | xewoox | Automated Trading | 9 | 02-17-2009 11:18 AM |
| ExitShortLimit , ExitShortStop | xewoox | Strategy Development | 1 | 02-16-2009 09:15 AM |
| Simple question about a simple strategy. | shakira | Strategy Development | 1 | 02-14-2009 10:56 AM |
| ExitShortStop not getting executed: why? | stefy | Strategy Development | 7 | 01-14-2009 09:36 AM |
| ExitShortStop doesn't works | julen | Strategy Development | 1 | 09-16-2008 12:04 PM |