OK, I want to RESET the StopLoss as if it had never been set. That's what Reset means to me. How?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
SetStopLoss()
Collapse
X
-
SetStopLoss()
The help says "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 "
OK, I want to RESET the StopLoss as if it had never been set. That's what Reset means to me. How?Tags: None
-
Lost Trader, to totally reset the order "as if it had never been set", you would need to use IOrders and use CancelOrder() to get the stop loss completely out of the way (a canceled state). In the help guide, the reset method is to simply place the stop loss so far away from the market that it would never get triggered.AustinNinjaTrader Customer Service
-
Well, if flat, then the strategy has already either canceled or filled the Stop.
But that does not remove the setting apparently, as subsequent orders that should start w/o a stop are being assigned (a wrong) one immediately.
So how do I cancel this remembered Stop Loss order explicitly? Does SetStopLoss() return an IOrder object that I can cancel after the position is closed? Since I know the system submitted order has the Name='Stop loss' can I use that information to get an IOrder object to cancel (reset) the the StopLoss memory?
Can EnterLongStop() and ExitShortStop() be used instead without this memory effect? And will the strategy cancel an open EnterLongStop() if the profit target is reached and the position closed?
Comment
-
Lost Trader, unfortunately you would need to assign your stops a specific IOrder variable and then call that variable. It is not possible to get an IOrder from a signal name, as there can be many orders with the same exact name.
You can use ExitLongStop() and/or ExitShortStop() to do the same thing as a stop loss, but without the memory effect. As long as the two closing orders (one stop, one limit) are using the same 'from entry' name, if one is filled the other will be canceled.
A small bit of sample code to demonstrate this is as follows:
When TraceOrders = true in Initialize(), the following output is produced:Code:protected override void OnBarUpdate() { if (CurrentBar == 100) EnterLong(1, "long entry"); else if (CurrentBar == 101) { ExitLongStop(0, true, 1, Close[0] - 50 * TickSize, "long stop loss", "long entry"); ExitLongLimit(0, true, 1, Close[0] + 50 * TickSize, "long target", "long entry"); } }
Code:7/26/2010 9:11:00 AM Entered internal PlaceOrder() method at 7/26/2010 9:11:00 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='long entry' FromEntrySignal='' 7/26/2010 9:12:00 AM Entered internal PlaceOrder() method at 7/26/2010 9:12:00 AM: Action=Sell OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=10373 SignalName='long stop loss' FromEntrySignal='long entry' 7/26/2010 9:12:00 AM Entered internal PlaceOrder() method at 7/26/2010 9:12:00 AM: Action=Sell OrderType=Limit Quantity=1 LimitPrice=10473 StopPrice=0 SignalName='long target' FromEntrySignal='long entry' 7/26/2010 1:48:00 PM Cancelled pending exit order, since associated position is closed: Order='NT-00001/Backtest' Name='long stop loss' State=Working Instrument='YM 09-10' Action=Sell Limit price=0 Stop price=10373 Quantity=1 Strategy='BIPCheck' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='fc9460ee691247e997e6e2f02694043e' Gtd='12/1/2099 12:00:00 AM'
AustinNinjaTrader Customer Service
Comment
-
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
650 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
370 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
109 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
574 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
577 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment