Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Strategy Builder - How to set a Trailing Stop
Collapse
X
-
Strategy Builder - How to set a Trailing Stop
Using Strategy Builder, how do I add a trailing stop to a strategy that uses candle close above/below a moving average for the entry? Trailing stop doesn't work when I have selected "on bar close" for the strategy. If I change the strategy to "on price change" my entry criteria doesn't work properly. (enters a trade on every price change instead of the candle close after the cross/close). Is there a way to get these two items to work on the same strategy? ThanksTags: None
-
Hello kgroupllc,
You can add to your entry condition the following to have it simulate OnBarClose:
Left: Misc -> Is first tick of bar
Center: equals
Right: Misc -> True
That will let the trailing stop update on each price change and the entry only when the bar closes, the first tick is the same tick that closes the bar.
-
Hello kgroupllc,
Are you testing in realtime?
The next step would be to use prints to see why that is blocking the condition from being true. IsFirstTickOfBar should always be true in historical and in realtime would have the effect that you wanted to simulate OnBarClose when using OnPriceChange.
Comment
-
Hello kgroupllc,
That should also work in playback if you have the script set to OnPriceChange or OnEachTick and are playing forward. If its not I would suggest using a Print to output all of the values used in the condition to see if on the first tick of the bar if that specifically is the problem or if one of the other values is not in the correct range for the condition to become true at that time. There is a video linked below that goes over adding prints into builder scripts.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
61 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
40 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
21 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
23 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
51 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

Comment