PDA

View Full Version : stop loss order rejected


maxpi
11-20-2007, 06:25 PM
running a strategy on market replay data, ver 6.0.1000.5, the entry order gets placed and the target order gets placed but the stop order gets rejected for being "below the market". I don't understand this.... The strategy is flat before this code is run. Price is not changing enough before the fill to cause the rejection...

EnterShort(contracts,"sig10");
SetStopLoss(CalculationMode.Price,10);
SetProfitTarget(CalculationMode.Price,30);

Similar code used for a long entry works as per the documentation...

NinjaTrader_Josh
11-20-2007, 10:52 PM
Right. When you use CalculationMode.Price, the variable you set is the actual price you want to exit at. For instance if your instrument is trading at 100, you may want to set a Profit Target at 110 and to do that you would do SetProfitTarget(CalculationMode.Price, 110).

From the looks of your numbers it looks like you want to use CalculationMode.Ticks instead.

maxpi
11-21-2007, 12:16 AM
Ok, i was using the idea that the value i supplied would be offset from the entry price.

thanks muchly

NinjaTrader_Josh
11-21-2007, 12:38 AM
You can do something like Position.AvgPrice + somevalue.

maxpi
11-21-2007, 12:13 PM
The docs say the following regarding SetProfitTarget:

"Should you call this method to dynamically change the target price in the strategy OnBarUpdate() method, you should always reset the target price/offset value when your strategy is flat otherwise, the last price/offset value set will be used to generate your profit target order on your next open position "

what is meant by "reset the target price/offset value"? Do I issue a SetProfitTarget or update the variable used to fill in the target price immediately upon receiving the info that position is flat from TWS?

NinjaTrader_Ray
11-21-2007, 12:17 PM
See this reference sample

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

maxpi
11-21-2007, 12:55 PM
The reference sample helped, thanks. What I was wondering is if one has to wait to be flat before changing the stop values, apparently just changing them at the time of the entry order should be fine?

NinjaTrader_Josh
11-21-2007, 04:55 PM
Changing them whenever will work for updating the next profit target/stop loss orders sent.

NinjaTrader_Ray
11-22-2007, 08:35 AM
Yes, you can change it at the time of entry order submission, just do it prior to submitting an entry order otherwise it is possible that stop/targets will be submitted at the last known stop/target price for your prior trade.