In my strategy, I try to use SetStopLoss() with a CalculationMode.Price value inside OnBarUpdate(). And I ran into the problem of triggering a SetStopLoss() at a previous non-current price. There is a warning in the manual: https://ninjatrader.com/support/helpGuides/nt8/en-us/setstoploss.htm (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). This is just my case. But I do not know how to overload use SetStopLoss() in order not to use the price from the previous position. Thank.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Dynamically change the stop loss price in SetStopLoss()
Collapse
X
-
Dynamically change the stop loss price in SetStopLoss()
Hi guys.
In my strategy, I try to use SetStopLoss() with a CalculationMode.Price value inside OnBarUpdate(). And I ran into the problem of triggering a SetStopLoss() at a previous non-current price. There is a warning in the manual: https://ninjatrader.com/support/helpGuides/nt8/en-us/setstoploss.htm (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). This is just my case. But I do not know how to overload use SetStopLoss() in order not to use the price from the previous position. Thank.
Tags: None
-
Hello Kostiantyn,
Thank you for the post.
I noted that this question was also sent into our platform support email and we have replied by email. If you have other separate questions please feel free to create another email to support or forum post. Please be sure to only use one support method at a time for the same question going forward.
I look forward to being of further assistance.
-
This is the logic of order execution and support. Strategy for NT8.Attached Files
Comment
-
-
Hello Kostiantyn,
The error states the price being used is not valid or is 0. To address this you would need to debug the script further to find why an invalid price is being used. I could suggest using Prints with the price you are using where it is being used for SetStopLoss.
As we are already speaking through email, I would suggest replying to my prior email with these details if this is related to the script we have already been discussing so we can keep all of the information about your question in one place. If this is unrelated to your earlier post/email, please ensure to make a new thread for new questions.
Please let me know if I may be of additional assistance.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, 03-13-2026, 05:17 AM
|
0 responses
86 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
151 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
79 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
52 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
59 views
0 likes
|
Last Post
|

Comment