Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Create a stop order upon a trigger price
Collapse
X
-
Hello cfree5119,
I am following up Brett and is happy to assist you.
You can use Position.AvgPrice to calculate the new stop like
if (Position.MarketPosition == MarketPosition.Long && Close[0] >= Position.AvgPrice + Position.AvgPrice * .01 )
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice);
}
The above code is for long only.
Please let me know if this works for you or not.
Regards,
Joydeep.JoydeepNinjaTrader Customer Service
Comment
-
-
Hello,
Yes, you would use SetStopLoss() before you enter the trade to the value you would like using the method Joydeep demontrated below. Instead of using Position.AvgPrice and MarketPosition however since that does not exist yet since you are not in a position you would instead just use the Close[0] price and find out where the 5% level would be. Then set your original stop loss to that value.
SetProfitTarget can be used like the following.
Also here is the reference for SetStopLoss()
Let me know if any questions.
-BrettBrettNinjaTrader Product Management
Comment
-
I setup my absolute 5% stop loss under the Initialize() method.
SetStopLoss("Long Turtle Entry", CalculationMode.Percent,stopTrigger1, false);
I then setup my breakeven stop loss under OnBarUpdate() as:
if (Position.MarketPosition == MarketPosition.Long && Close[0] >= Position.AvgPrice + Position.AvgPrice * breakEvenStopTrigger)
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice);
}
The strategy does not recognize the latter when both stop losses are setup. Not sure how to "dynamically" change the sl. Thank you.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
633 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
364 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
567 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
568 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment