NinjaTrader Support Forum  
X

Attention!

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


Go Back   NinjaTrader Support Forum > Application Technical Support > Miscellaneous Support

Miscellaneous Support Miscellaneous support issues.

Reply
 
Thread Tools Display Modes
Old 06-27-2011, 07:43 AM   #1
xbaha
Junior Member
 
Join Date: Jun 2011
Posts: 16
Thanks: 1
Thanked 0 times in 0 posts
Default Long & Short Strategy testing logic error?

hi,
i am trying this:

if (true)
{
EnterShortLimit(sentry);
EnterLongLimit(lentry);
}

when i test the strategy i get some results, now if i try it this way:

if (true)
{
EnterLongLimit(lentry);
EnterShortLimit(sentry);
}

i get totally different results:

i looked at the chart for both strategy results, and it seems if i placed a LONG LIMIT order first, and there was no LONG fill, While the price of the bar hit & passed my SHORT limit order (which was second in the order), i will not get any fills!

is this normal? how to write such a script???

Thanks.
xbaha is offline  
Reply With Quote
Old 06-27-2011, 08:38 AM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

xbaha,

The reason this happens is because you actually can't have two working limit orders in opposite directions simultaneously. You can read up on the internal order handling rules which prevents the submission of such an order here: http://www.ninjatrader.com/support/h...d_approach.htm

Basically what you would need to do is only submit one of the limits at a time. If price moves in the opposite direction closer to your other desired limit you would want to cancel the first, then submit the other instead and just switch back and forth if price keeps moving back and forth.

An alternative if you really want both orders in at the same time is to use the Unmanaged Approach for order submission, but this is reserved for skilled programmers and system developers who are absolutely certain they know exactly what they are doing because it bypasses any protection NT may provide in the Managed Approach for order errors.
NinjaTrader_Josh is offline  
Reply With Quote
Old 06-27-2011, 09:13 AM   #3
xbaha
Junior Member
 
Join Date: Jun 2011
Posts: 16
Thanks: 1
Thanked 0 times in 0 posts
Default

do you mean the Unmanaged Approach could have errors in the results because the script could have looked ahead?
xbaha is offline  
Reply With Quote
Old 06-27-2011, 09:19 AM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

xbaha,

No, unmanaged approach provides you zero safety net. Whatever you tell the strategy to do in terms of order placement is exactly what the strategy will do. There is no hand holding done by NT to try and protect you from erroneous orders or order rejections and such. You can read more about this in the Help Guide: http://www.ninjatrader.com/support/h...d_approach.htm
NinjaTrader_Josh is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Long & Short Order Problem upshon Strategy Development 1 03-03-2011 03:24 AM
Short & long at the same time "CJS" Strategy Development 5 09-24-2010 05:15 AM
Long & Short murfinp Strategy Development 1 05-13-2009 08:56 AM
Long & Short Stop Order PHOLAN Automated Trading 3 09-23-2008 08:18 AM
Long & short combined in 1 strategy dtf139 Automated Trading 5 01-08-2008 08:23 PM


All times are GMT -6. The time now is 07:38 AM.