NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Sunday May 26th at 12PM 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-03-2007, 11:31 AM   #1
AO76
Member
 
Join Date: May 2007
Location: , ,
Posts: 57
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

I have a few questions:

1) Is it possible to set multiple profit targets with the SetProfitTarget() method?
2) Is it possible to auto enter but then exit manually?

3)Is it possible to SetStopLoss() method based on# ofbars or time(ie if it does not advance/decline in X bars/minutes) get out


Thanks

AO76 is offline  
Reply With Quote
Old 05-03-2007, 12:52 PM   #2
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Post imported post

1) You could do this if you provide unique signal names for your entry, such as entry1, entry2 and then call SetProfitTarget () specifying each entry signal.

2) Only by using ATM strategies. There is a section in the Help Guide on this topic.

3) You can always exit using ExitLong() after X bars, any stop loss in the market will be cancelled. You do run the risk of getting filled on both order in this case so make sure the stop loss is a good distance from the market.

Ray
NinjaTrader_Ray is offline  
Reply With Quote
Old 05-03-2007, 12:58 PM   #3
AO76
Member
 
Join Date: May 2007
Location: , ,
Posts: 57
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

Thanks for the response. In regards to 1)

I would like to enter all units at once and then take partial units off at specific targets. I'm guessing there is a way to this but it would be nice if the SetProfitTarget() method could provide this functionality.

Thanks Again


AO76 is offline  
Reply With Quote
Old 05-04-2007, 02:06 AM   #4
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Post imported post

You can enter at once, but with two orders:


Quote:

Within Initialize()

SetProfitTarget("Entry1", CalculationMode.Ticks, 6);
SetProfitTarget("Entry2", CalculationMode.Ticks, 12);

Within OnBarUpdate()

if (Close[0] > Open[0])
{
EnterLong(1, "Entry1");
EnterLong(1, "Entry2");
}
Then when running or backtesting a strategy, make sure you set the following parameters:

Entries per direction = 1
Entry handling = UniqueEntries

Ray
NinjaTrader_Ray is offline  
Reply With Quote
Old 05-06-2007, 11:20 AM   #5
AO76
Member
 
Join Date: May 2007
Location: , ,
Posts: 57
Thanks: 0
Thanked 0 times in 0 posts
Default

Great thanks.
AO76 is offline  
Reply With Quote
Old 05-06-2007, 10:47 PM   #6
jon_lbs
Junior Member
 
Join Date: May 2007
Location: , Washington, USA
Posts: 5
Thanks: 0
Thanked 0 times in 0 posts
Default

I just submitted same question.. See my post at Scale Out Partials . I attached the code __ Also got it working just fine.
jon_lbs is offline  
Reply With Quote
Old 05-20-2007, 12:01 AM   #7
AO76
Member
 
Join Date: May 2007
Location: , ,
Posts: 57
Thanks: 0
Thanked 0 times in 0 posts
Default

Another question.

I have two entries T1, T2. My T1 target is hit now I would like to bring my T2 original stop loss upto Break Even. Any idea how I can do this?

Thanks.
AO76 is offline  
Reply With Quote
Old 05-20-2007, 08:38 AM   #8
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

You would need to check Position.Quantity to determine if T1 is hit. Then you can call the SetStopLoss() method with different parameters to tighten the stop loss.

From the Help Guide:

Definition
Generates a stop loss order to exit a position. Stop loss orders are real working orders (unless simulated is specified in which case the stop order is locally simulated and submitted as market once triggered) submitted immediately to the market upon receiving an execution from an entry order.


It is suggested to call this method from within the strategy Initialize() method if your stop loss price/offset is static
You may call this method from within the strategy OnBarUpdate() method should you wish to dynamically change the stop loss price while in an open position
Should you call this method to dynamically change the stop loss price in the strategy OnBarUpdate() method, you should always reset the stop loss price/offset value when your strategy is flat otherwise, the last price/offset value set will be used to generate your stop loss order on your next open position
NinjaTrader_Ray 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


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