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 04-18-2008, 03:45 AM   #1
stefy
Senior Member
 
Join Date: Apr 2008
Posts: 310
Thanks: 0
Thanked 0 times in 0 posts
Default Profit Targets

Hi

I wrote a system and I'd like to apply a profit target, not a static one based on fixed nr of pips, but proportional to the ATR.

To do so, after my conditions to enter/exit trades, I wrote:

// Condition set 3
if (Close[0] > Position.AvgPrice * (1 + ATR(14)[0]))

{
ExitLong("TAKEPROFIT", " BUY");
}

It doesn't work though, like if those lines were not present, the system trades regardless.

What did I forget please?

Any help greatly appreciated
stefy is offline  
Reply With Quote
Old 04-18-2008, 05:18 AM   #2
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Default

I suggest debugging your code as per here: http://www.ninjatrader-support.com/v...ead.php?t=3418
NinjaTrader_Dierk is offline  
Reply With Quote
Old 04-18-2008, 07:59 AM   #3
stefy
Senior Member
 
Join Date: Apr 2008
Posts: 310
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi Ray,

Thank you for the link, but I didn't find anything close to what I need.

Could you please just watch the line of code and tell me if it's right? I just want to take profit conditional to a certain value of an indicator.

Otherwise, are there any strategy examples?

Many thanks
stefy is offline  
Reply With Quote
Old 04-18-2008, 08:10 AM   #4
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Default

You might find additional info on NinjaScript coding issues here: http://www.ninjatrader-support.com/v...splay.php?f=30

Also: Please check your logs for funny messages.
NinjaTrader_Dierk is offline  
Reply With Quote
Old 04-19-2008, 11:15 PM   #5
KBJ
Senior Member
 
Join Date: Mar 2007
Location: , Florida, USA
Posts: 663
Thanks: 36
Thanked 7 times in 6 posts
Default

I think your target will be way too big (or small if ATR is negative.)

Maybe you want something more like this...

Code:
if (Close[0] > (Position.AvgPrice + (multiplier * ATR(14)[0])))
{
  ExitLong...
}
Where "multiplier" is determined by your strategy.
KBJ 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
Simulated stops and profit targets. dtf139 ATM Strategies (Discretionary Trading) 3 03-11-2008 06:57 AM
Splitting Profit Targets fifty2aces Strategy Development 1 10-10-2007 08:00 AM
Profit Targets & 'Exit on Close' dgregor5 General Programming 2 07-15-2007 01:35 PM
Printing Current StopLoss & Profit Targets Jim-Boulder Strategy Analyzer 1 06-25-2007 11:16 AM
Profit Targets in Strategy Wizard gregw Strategy Development 3 01-24-2007 09:30 AM


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