Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Update StopLoss real time

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

    Update StopLoss real time

    I would like to change the stoploss when price hit some value but, I am using setstoploss in onbarupdate then, it is updatin only after the bar close. How can I update in real time? Thanks

    #2
    Hello wagner4691,

    Thanks for your post.

    In order for the SetStopLoss to update sooner (real time), on live or replay data, you would need to run your strategy with Calculate.OnEachTick or Calculate.OnPriceChange. Either of these will cause your script to run as a new tick is received or as a change in price occurs, keep in mind that this means your strategy code may run hundreds of times (or more or less) per bar compared to once per bar as it does now.

    You may want to segment some of your code so that it runs on the live data and some so that it only runs once per bar. Here is a link to an example of that: https://ninjatrader.com/support/help...either_cal.htm


    Comment

    Latest Posts

    Collapse

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