PDA

View Full Version : How to set up SetProfitTarget and also SetStopLoss in one trade


zooinek
06-16-2010, 03:50 AM
Hello

you told me that SetProfitTarget and SetStopLoss are OCO orders, so once proftitarget is set, the stoploss can not be set.

I would like to ask you.. is there any way how I could set ProfitTarget and ALSO StopLoss for my trade?

P.S.: why nobody is responding on my another thread?
http://www.ninjatrader.com/support/forum/showthread.php?t=30390

The problem is still not solved

NinjaTrader_Bertrand
06-16-2010, 04:46 AM
zooinek, to clarify - SetProfitTarget and SetStopLoss create OCO orders, which means if your target executes, the associated stop placed for the position is cancelled (as it would not have a 'job' then anymore, position closed).

Once the position is open and both the profit target and stop loss are still working, you can for sure set one to a new value by recalling the command for this position in the OnBarUpdate() code portion, you should also ensure to reset those to a default value when you're flat -

http://www.ninjatrader.com/support/forum/showthread.php?t=3222

We'll check into the other thread shortly.

zooinek
06-16-2010, 05:35 AM
So does it mean that I can set StopLoss and ProfitTarget everytime I do EnterLong?
Because every my entry has different stoploss and profittarget as the other entries.
So can I use setstoploss and setprofittarget methods everytime when I use EnterLong?

I understand that when I am already in position (and the position has stoploss 30ticks) and I will use SetStopLoss(10 ticks) the stoploss will "recalculate" for 10tick for the position.
But I am not sure if it is ok to use SetStopLoss function and SetProfitTarget function (both of them) everytime I am using new EnterLong.. ?

NinjaTrader_Bertrand
06-16-2010, 05:46 AM
Yes, the StopLoss and ProfitTarget values can be dynamic (for example based on ATR, prior swing high / low, indicator values etc) in the OnBarUpdate(), just reset to a static default value in ticks when you're flat with the strategy like shown in the sample.