Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Issue in Code

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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.

    #2
    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>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    80 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    40 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    63 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    63 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    54 views
    0 likes
    Last Post CarlTrading  
    Working...
    X