Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Issue in Code
Collapse
X
-
Issue in Code
Hello everyone, im new in coding in Ninjatrader, i created a trailing Stop which sets the Stop to the lowest low of the last 10 candles, the code it self works correctly, i first wanted to test code in the on bar update funktion and then out source it in an own function. Unfortunatly the code in the on bar update function only runs ones, so my print outputs for checking the codes create the illusion that the void on bar function runs only when there are no open positions? Is this correct or is there something else I have to observe? Thx for your help guys. https://kodi.software/ https://dltutuapp.com/tutuapp-download/Last edited by xeliw42651; 10-16-2023, 06:52 AM.Tags: None
-
Hello xeliw42651,
Thanks for your post.
When using Calculate.OnBarClose, the OnBarUpdate() section of code will process once at the end of each bar.
If you are using Set methods such as SetTrailStop() and the strategy submits an entry order, the stop loss order will be placed once the entry order is filled.
Note that SetTrailStop() orders will trail based on the Calculate mode being used. So if you are using Calculate.OnBarClose and the market moves in your favor at the close of a bar, the stop loss will trail.
See the help guide documentation below for more information.
Calculate: https://ninjatrader.com/support/help.../calculate.htm
SetTrailStop(): https://ninjatrader.com/support/help...ttrailstop.htm<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Mindset, 04-21-2026, 06:46 AM
|
0 responses
57 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
78 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
39 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|
||
|
Started by cmoran13, 04-16-2026, 01:02 PM
|
0 responses
101 views
0 likes
|
Last Post
by cmoran13
04-16-2026, 01:02 PM
|
||
|
Started by PaulMohn, 04-10-2026, 11:11 AM
|
0 responses
61 views
0 likes
|
Last Post
by PaulMohn
04-10-2026, 11:11 AM
|

Comment