![]() |
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 |
|
Junior Member
Join Date: May 2011
Posts: 6
Thanks: 1
Thanked 0 times in 0 posts
|
Hi,
For a long position that I've entered, I need to know how to create a stop for : (1 x ATR) - low of entry bar and Target exit : (2 x ATR) + entry price or Market on Close (MOC), whichever comes first. If stop is 2 x ATR or more under the entry price, the setup should be ignored until the next opportunity comes along. Can anyone help me with this? |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,781
Thanks: 159
Thanked 565 times in 556 posts
|
Hello,
You can store these bar values in a double, and then use that double as the price level for your stop and your profit target: Code:
double stop1 = Low[0] - ATR(14)[0]; double target1 = Position.AvgPrice + (ATR(14)[0] * 2); SetStopLoss(stop1); SetProfitTarget(target1);
Matthew
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: May 2011
Posts: 6
Thanks: 1
Thanked 0 times in 0 posts
|
Thanks for the swift reply, really appreciate it.
However, I noticed for this line : Code:
double target1 = Position.AvgPrice + (ATR(14)[0] * 2); By the way, this code written here, is this done via editing the code of a strategy directly or can it be built with the condition builder when creating a strategy? Thank you very much for taking the time to help me, really appreciate it (:
Last edited by comfy; 08-20-2012 at 01:47 AM.
|
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
|
Hello comfy,
It might not be possible to do it via the strategy wizard and you have to do it by further coding it via the NinjaScript Editor.
Joydeep M.
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 2 things: Opposing Stop entries & Trade entry/exit info displayed on chart... | Barefoot Hank | Charting | 2 | 09-22-2011 06:24 AM |
| Stop Loss & Target Exit & winning strategies | johnbastawros | Strategy Development | 1 | 03-16-2011 03:50 PM |
| Partial Exit - named signal exit stop not updated | MicroTrends | Strategy Development | 5 | 02-08-2011 10:17 AM |
| Create a parked STOP order with simple stop loss | skynetman | Strategy Development | 3 | 03-14-2008 12:36 AM |
| Stop Loss & Managed Exit fire together | CashCache | Strategy Development | 11 | 01-18-2008 10:39 AM |