Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

reseting a setstoploss

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

    reseting a setstoploss

    Hello,
    I'm running into this issue stated in the Help on SetStopLoss:
    "Should you call this method to dynamically change the stop loss price in the strategy OnBarUpdate() method, you should always reset the stop loss price/offset value when your strategy is flat otherwise, the last price/offset value set will be used to generate your stop loss order on your next open position"

    Can someone please give me and idea of how to reset the value. Also there may be times in my strategy when the value will need reset, but I won't be flat, such as having another open position.

    Thanks

    #2
    You will reset the stop by changing stop loss value. An example for this can be found from the following reference:

    http://www.ninjatrader.com/support/f...ead.php?t=3222

    So for example, you could use something like the the following in OnBarUpdate

    if (Position.MarketPosition == MarketPosition.Flat)
    SetStopLoss(CalculationMode.Ticks, 5);

    Please let me know if you have additional questions.
    MatthewNinjaTrader Product Management

    Comment


      #3
      Can I use another condition to reset the value? As I stated before, often my strategy will not be flat.

      Comment


        #4
        Originally posted by CaptainAmericaXX View Post
        Can I use another condition to reset the value? As I stated before, often my strategy will not be flat.
        You can change the StopLoss value at any time, using any trigger condition.

        It is just the you MUST reset the StopLoss when you go flat, or you will see many unintended consequences.

        Comment


          #5
          Thanks for the replies. To be clear must I be FLAT in order to reset the stoploss or can it be reset on another condition?

          Comment


            #6
            Hello,

            You can reset it under any condition, but do make sure you are also resetting when flat to avoid unwanted situations.
            MatthewNinjaTrader Product Management

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by helpwanted, Today, 03:06 AM
            1 response
            12 views
            0 likes
            Last Post sarafuenonly123  
            Started by Brevo, Today, 01:45 AM
            0 responses
            9 views
            0 likes
            Last Post Brevo
            by Brevo
             
            Started by aussugardefender, Today, 01:07 AM
            0 responses
            5 views
            0 likes
            Last Post aussugardefender  
            Started by pvincent, 06-23-2022, 12:53 PM
            14 responses
            242 views
            0 likes
            Last Post Nyman
            by Nyman
             
            Started by TraderG23, 12-08-2023, 07:56 AM
            9 responses
            387 views
            1 like
            Last Post Gavini
            by Gavini
             
            Working...
            X