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 > Automated Trading

Automated Trading Support for automated trading systems using NinjaScript. Support for our ATI (Automated Trading Interface) used to link an external application such as TradeStation and eSignal to NinjaTrader.

Reply
 
Thread Tools Display Modes
Old 07-09-2010, 06:56 PM   #1
Skeletor
Junior Member
 
Join Date: Jun 2010
Location: Vancouver, BC
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
Default Exits using Limit orders

I am trying to create limit exit orders but they do not show up in a back test when price moves beyond my limit prices. Here's the simple exit code:

if (Position.MarketPosition == MarketPosition.Long)
{
ExitLongLimit(LXprice, "LX");
}
if (Position.MarketPosition == MarketPosition.Short)
{
ExitShortLimit(SXprice, "SX");
}

If the order isn't filled, I'm happy to have the order canceled at the end of each bar and will calculate a new exit point for both long and short entries.

Once I get over this hurdle, I'd like to tie these exits to specific entries but the examples are limited on the ExitLongLimit help page. Could you please give me an example of how this is done? ie: Exit a long position, naming the exit so it shows up on the chart and also tying that exit to a specific entry.

Also... I'd rather not use SetProfitTarget. When I tried this, only the Long Limit entries worked. Short Limit entries did not show up in a back test.
Skeletor is offline  
Reply With Quote
Old 07-10-2010, 09:30 AM   #2
NinjaTrader_Ben
NinjaTrader Customer Service
 
NinjaTrader_Ben's Avatar
 
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
Default

Hello,

Using Print(), I would first check the condition values before the if conditions and use Print("is in conditon 1") etc. to see if it is even entering the condition.

If all is well with the above, use Print() again to see if the price you are using is reasonable and signal names match your entry signal names.

Thiis link may help:
http://www.ninjatrader.com/support/f...ead.php?t=3418
NinjaTrader_Ben is offline  
Reply With Quote
Old 07-11-2010, 04:49 PM   #3
Skeletor
Junior Member
 
Join Date: Jun 2010
Location: Vancouver, BC
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
Default

Using print and checking the output window, I have confirmed that these exit statements are being hit. I also printed out the prices of the limit orders and checked these prices with the date/timestamps on the chart. Price moves through these points but no exit occurs. In the Exit Limit statements I have tried the following to no avail:
1) putting in the price AND entry name
2) only putting in the exit price (as listed below).

if (Position.MarketPosition == MarketPosition.Long)
{
ExitLongLimit(LXprice);
Print(Time[0].ToString() + " LXprice=" + LXprice + " Bar#=" + CurrentBar);
}
Skeletor is offline  
Reply With Quote
Old 07-11-2010, 09:03 PM   #4
NinjaTrader_Ben
NinjaTrader Customer Service
 
NinjaTrader_Ben's Avatar
 
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
Default

Hello,

I'm not sure, sorry. Maybe post your log and trace files. Also, you do know what if you are long, and you submit a short order (for example), it will bring you flat. In other words, you don't need to submit an exit.

Also, you do know that you have to submit a working order each bar right?

Did you cofirm that the order is still working and exists at the time price moves through the order price?
NinjaTrader_Ben is offline  
Reply With Quote
Reply

Tags
limit exits

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
Cannot enter a limit price for a limit order on orders tab cunparis Version 7 Beta General Questions & Bug Reports 7 07-09-2010 07:01 AM
Strategy Limit Order Exits slimm Automated Trading 5 02-16-2010 12:47 PM
Limit Order Exits not working daven Automated Trading 2 08-23-2008 02:17 PM
Negative Limit - Stop Limit Entry Orders biswar Automated Trading 1 10-18-2005 12:58 AM
Exits by Limit in all circumstances Rognvald ATM Strategies (Discretionary Trading) 8 02-08-2005 10:41 PM


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