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 > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 05-13-2008, 03:07 PM   #1
stefy
Senior Member
 
Join Date: Apr 2008
Posts: 310
Thanks: 0
Thanked 0 times in 0 posts
Default Stop Losses

Hi everyone
I want to apply a stop loss using the ATR(14).
I wrote the following code:
// Condition set Long Stop Loss
if (Close[0] < (Position.AvgPrice - ATR(14)[0])
&& Position.MarketPosition == MarketPosition.Long)
{
ExitLong(
"STOPLOSS", "BUY");
}

Problem is, the stop loss never kicks in!

Any advice?

Thank you
stefy is offline  
Reply With Quote
Old 05-13-2008, 05:44 PM   #2
Gumphrie
Senior Member
 
Join Date: Jun 2007
Posts: 218
Thanks: 0
Thanked 1 time in 1 post
Default

Hi Stefy,

Is "BUY" the same "fromentrysignal" used in the EnterLong() function? If not, that would cause the problem you are seeing...
Gumphrie is offline  
Reply With Quote
Old 05-13-2008, 07:15 PM   #3
stefy
Senior Member
 
Join Date: Apr 2008
Posts: 310
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by Gumphrie View Post
Hi Stefy,

Is "BUY" the same "fromentrysignal" used in the EnterLong() function? If not, that would cause the problem you are seeing...
Thank you, Gumphrie! That was the problem indeed.
stefy 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
can't get stop losses or profit targets to execute leemiles Strategy Development 9 11-04-2008 08:56 AM
Stop losses lgarcia3 Strategy Development 1 04-12-2008 08:00 AM
Stop losses on Positions from limit orders BenHeaton Strategy Development 5 03-04-2008 11:41 AM
Stop Losses not working? zoltran General Programming 2 11-08-2007 04:00 AM
Stop Loss Orders activated by number of trades past stop level DoveforUsAll Suggestions And Feedback 1 02-08-2006 01:19 AM


All times are GMT -6. The time now is 01:27 PM.