Is that possible the trail stop order type?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Delayed Trail Stop
Collapse
X
-
Delayed Trail Stop
SetTrailStop() executes as soon as an order is filled, what if I want to wait until I'm up say 1% then set a trail stop order.
Is that possible the trail stop order type?Tags: None
-
Hello JakeOfSpades,
Thank you for your post.
You may certainly place a more dynamic SetTrailStop() order within OnBarUpdate() that is triggered only under certain conditions. To calculate if you are up 1%, you could use GetUnrealizedProfitLoss() in your condition. Here is an example snippet:
if (Position.MarketPosition != MarketPosition.Flat && Position.GetUnrealizedProfitLoss(PerformanceUnit.P ercent, Close[0] >= .01)
SetTrailStop(CalculationMode.Ticks, 5);
The value shown in this snippet is .01 because with the percent calculation, a value of 1 equals 100%. .01 would be the equivalent of 1%.
Here are some additional resources regarding SetTrailStop and GetUnrealizedProfitLoss:
Please let us know if we may be of further assistance.
-
Hey Emily, I could do that but if I remember correctly that will work for the first order. If I submit another trade say the next day, because SetTrailStop() has been called the next trade will attach a trail immediately on fill and I want to wait if it's up 1%.Originally posted by NinjaTrader_Emily View PostHello JakeOfSpades,
Thank you for your post.
You may certainly place a more dynamic SetTrailStop() order within OnBarUpdate() that is triggered only under certain conditions. To calculate if you are up 1%, you could use GetUnrealizedProfitLoss() in your condition. Here is an example snippet:
if (Position.MarketPosition != MarketPosition.Flat && Position.GetUnrealizedProfitLoss(PerformanceUnit.P ercent, Close[0] >= .01)
SetTrailStop(CalculationMode.Ticks, 5);
The value shown in this snippet is .01 because with the percent calculation, a value of 1 equals 100%. .01 would be the equivalent of 1%.
Here are some additional resources regarding SetTrailStop and GetUnrealizedProfitLoss:
Please let us know if we may be of further assistance.
Comment
-
Hello JackOfSpades,
Thank you for your reply.
You make a good point; I was not thinking about the need to reset Set method orders and how that would mean that the SetTrailStop() would be triggered immediately on any subsequent orders. Set methods are essentially designed to prep NinjaTrader to submit a stop loss or profit target as soon as an order comes back as filled. In order to achieve your desired result where a trailing stop is not submitted until 1% of profit is hit, you would need to use OnExecutionUpdate() to submit the stop loss with Exit methods. If you want to use OCO functionality to tie together stops and profits, you would need to use the Unmanaged Approach for your strategy.
We have a reference sample that demonstrates how to submit protective orders by using OnOrderUpdate() and OnExecutionUpdate() here:
Please let us know if we may be of further assistance.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
65 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
139 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
75 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
45 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
50 views
0 likes
|
Last Post
|

Comment