![]() |
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 |
|
Senior Member
Join Date: Apr 2008
Posts: 310
Thanks: 0
Thanked 0 times in 0 posts
|
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
|
|
|
|
|
|
#2 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
I suggest debugging your code as per here: http://www.ninjatrader-support.com/v...ead.php?t=3418
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Apr 2008
Posts: 310
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#4 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
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.
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Mar 2007
Location: , Florida, USA
Posts: 663
Thanks: 36
Thanked 7 times in 6 posts
|
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...
}
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |