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 Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
648 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
369 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
108 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
572 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
574 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment