There was a related bug here. You need to isolate to one type of stop loss statement, and definitely test on our next beta.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
RE: Stoploss orders stay Initialized {372020}
Collapse
X
-
Well, there's a new issue in connection with this one.
Since I disabled my stoploss resetting code (the one with the simulated stop set to the minimum price(near 0 ~ TickSize)), my stoplosses are going crazy. NT submits my old stoploss first, and then it changes to the new one. The problem is that it sometimes gets rejected, because it's an invalid (above the market price for long) price.
For example:
At a previous position my stoploss was at 119.52. My strategy exits that position. Later it enters again and my stoploss is set to 119.52, though it should be set to 119.4. My stoploss then changes to 119.4. However on the next position it tries to set the stoploss to an invalid price(119.4) (above the market), and thus my stoploss is rejected.
How do I disable the stoploss when my strategy exits, so that the next time there isn't any stoploss order submitted until the next time I call SetstopLoss?
Your help is very misleading:
I was resetting the stoploss, but it was causing my stoploss orders not to be sent at all (the first issue in this topic).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
Something is messed up with the stoploss handling.
Comment
-
Hello vides2012,
You will have to debug the price level that you're submitting orders at. If you want to ensure that stop loss price is valid, it may help to use calculation mode ticks or percent. These will then be based from an offset of the entry price.
If you are submitting stop loss orders with mode price, there is nothing stopping you from submitting invalid orders.
If you'd like more control over the submission of stop orders, you can also use ExitLongStop() or ExitShortStop().Ryan M.NinjaTrader Customer Service
Comment
-
My price levels are correct, though as I have mentioned the price level from the previous SetStopLoss call remains, and that price level is now obsolete and invalid.
How do I disable this, so that on the next entry there isn't any stoploss order until I call again SetStopLoss? Or how do I reset the stoploss? As you can see my previous solution (the one at the beginning of this topic) was working from this point of view. However it caused NT work unpredictably while trading live.
There must be a solution to this. I would like to set the stoploss according to the entry circumstances of the position (average price to be more specific). Setting the stoploss in the OnExecution seems to be the hard way due to these behaviors of NT.
Either please resolve the live trading issue (when having resetted stoploss orders, the actual ones don't become alive), or provide a way to propely disable the stoploss so that it doesn't activate on next entry.
Comment
-
The default value in my case is not to have a stoploss. In my initial version I was resetting the stoploss to be simulated, so that it wouldn't interfere. But that caused NT not to send the real, not simulated order later, so I removed the resetting mechanism.
Can you propose a way to properly reset the stoploss to a non-working state?
Thanks.
Here's the initial code:
As you can see, when the strategy exits the position I reset the stoploss to a simulated state, but after entry I set it again to a functioning state. But it didn't work out well, as NT denied to send the new, real, not simulated stoploss order to the TWS.Code:protected override void OnExecution(IExecution execution) { IOrder ord=execution.Order; base.OnExecution(execution); //If we have just bought (entered into long) if(ord.OrderAction==OrderAction.Buy && ord.OrderType != OrderType.Stop && Position.Quantity>0) { SetStopLoss(Name+" EnterLong",CalculationMode.Price,avgPrice+l_ln/(Position.Quantity),false); SetStopLoss(Name+" EnterShort",CalculationMode.Price,TickSize,true); //reset the short stoploss } //IF we have just sold (entered into short) else if(ord.OrderAction==OrderAction.SellShort && ord.OrderType != OrderType.Stop && Position.Quantity>0) { SetStopLoss(Name+" EnterShort",CalculationMode.Price,avgPrice-s_ln/(Position.Quantity),false); SetStopLoss(Name+" EnterLong",CalculationMode.Price,TickSize,true); //reset the long stoploss } else //not in position anymore { //reset both stoplosses SetStopLoss(Name+" EnterShort",CalculationMode.Price,TickSize,true); SetStopLoss(Name+" EnterLong",CalculationMode.Price,TickSize,true); } }Last edited by vides2012; 10-08-2010, 07:07 AM.
Comment
-
Well, actually I was doing that - moving far away to the minimum price available (TickSize, since it cannot be 0), and also using simulated orders.
The problem is that this far-placed live stoploss would actually be sent to the TWS, and, even for a moment would be active. It would interfere with my other orders, wouldn't it? These short lifed stoploss orders can mean trouble if they are not cancelled (for any reason).
I would consider adding a DisableStopLoss(string entryName) function. Or looking into, why doesn't NT send the live order, after having the simulated one! This one's not clear to me, why can't I have both simulated and live stoplosses.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
626 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
359 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
105 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
562 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
567 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment