![]() |
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 |
|
Member
Join Date: May 2007
Location: , ,
Posts: 57
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
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
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: May 2007
Location: , ,
Posts: 57
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#4 | |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
You can enter at once, but with two orders:
Quote:
Entries per direction = 1 Entry handling = UniqueEntries Ray
Ray
NinjaTrader Customer Service |
|
|
|
|
|
|
#5 |
|
Member
Join Date: May 2007
Location: , ,
Posts: 57
Thanks: 0
Thanked 0 times in 0 posts
|
Great thanks.
|
|
|
|
|
|
#6 |
|
Junior Member
Join Date: May 2007
Location: , Washington, USA
Posts: 5
Thanks: 0
Thanked 0 times in 0 posts
|
I just submitted same question.. See my post at Scale Out Partials . I attached the code __ Also got it working just fine.
|
|
|
|
|
|
#7 |
|
Member
Join Date: May 2007
Location: , ,
Posts: 57
Thanks: 0
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#8 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
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
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#9 |
|
Member
Join Date: May 2007
Location: , ,
Posts: 57
Thanks: 0
Thanked 0 times in 0 posts
|
Not sure if I'm doing this right:
Initialization: SetProfitTarget("T1", CalculationMode.Ticks, 5); SetProfitTarget("T2", CalculationMode.Ticks, 7); SetStopLoss("T1", CalculationMode.Ticks, 10, true); SetStopLoss("T2", CalculationMode.Ticks, 10, true); OnBarUpdate: (not sure if this is how I modify the order) EnterLong(2, "T1"); EnterLong(2, "T2"); if(Position.Quantity == 2) { SetStopLoss("T2", CalculationMode.Ticks, 0, true); } |
|
|
|
|
|
#10 |
|
Member
Join Date: May 2007
Location: , ,
Posts: 57
Thanks: 0
Thanked 0 times in 0 posts
|
I know in the ATM there are advanced stop loss orders which will trigger the stop loss to BE + X. It would be nice if we had a method to this.
|
|
|
|
|
|
#11 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
if(Position.Quantity == 2)
{ SetStopLoss("T2", CalculationMode.Price, Position.AvgPrice, true); } Then you have to reset this when flat: if(Position.MarketPosition== MarketPosition.Flat) { SetStopLoss("T2", CalculationMode.Ticks, 10, true); }
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#12 |
|
Member
Join Date: May 2007
Location: , ,
Posts: 57
Thanks: 0
Thanked 0 times in 0 posts
|
Great thanks Ray. Works great.
Appreciate your help. |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|