Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Resubmitting SetProfitTarget() on every bar close

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

    Resubmitting SetProfitTarget() on every bar close

    Hello,

    I think the title of the topic is self-explanatory. Do I need to re-submit the SetProfitTarget() and SetStopLoss() on every bar close?

    Because this is not described into the documentation

    Best wishes

    #2
    Hello nrgful,

    Thanks for your message.



    To clarify, are you using the Strategy builder to develop your strategy, or are you writing a script manually?


    You do not need to re-submit SetProfitTarget() and SetStopLoss() on every bar close.

    When you use SetProfitTarget() or SetStopLoss() in a NinjaTrader strategy, those settings persist until they are either modified or cancelled. You should only re-submit set methods if you want to change the values, such as price or calculation.


    SetStopLoss()

    SetProfitTarget()


    I also recommend you check out the guide below, which explains how to avoid stop order rejections, such as SetStopLoss() or SetProfitTarget(), due to an invalid price.


    NinjaScript Guide - Avoiding stop order rejections due to an invalid price


    Feel free to reach out with any other questions or concerns.

    Comment


      #3

      Thank you for your response.

      I am writing my own script. I want to use SetStopLoss() and SetProfitTarget() methods to avoid other problematic circumstances. Could you provide me an example of how I can do that? Do I need to use the OnOrderUpdate() if using SetStopLoss() and SetProfitTarget() to handle with the order exceptions when volatility is increased?

      Last edited by nrgful; 05-04-2025, 07:46 AM.

      Comment


        #4
        Hello nrgful,

        Thanks for your reply.



        The Developer Guide below contains a sample code that demonstrates the use of SetStopLoss() and SetProfitTarget().


        https://support.ninjatrader.com/s/article/Profit-Chase-Stop-Trail?language=en_US


        To answer the second half of your question, only your needs will determine if you need to use OnOrderUpdate() with RealtimeErrorHandling to protect your position.

        Below you will find a sample code demonstrating the use of OnOrderUpdate().


        Using OnOrderUpdate() and OnExecution() methods to submit protective orders

        RealtimeErrorHandling


        Feel free to reach out with any other questions or concerns.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        44 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        124 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        65 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        42 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X