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 NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    62 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    134 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    75 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    50 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X