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

Change a SetStopLoss() Order

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

    Change a SetStopLoss() Order

    Hi, Can a StopLoss submitted after an order execution, which was set using SetStopLoss() be subsequently changed?

    #2
    Hello sjmuk1,

    The Set methods are submitted based on the entry fill but you can change it later by calling SetStopLoss again with new values.

    The two ways to use SetStopLoss orders would be statically by calling SetStopLoss in State.SetDefaults, that gives an always used stop. The other way would be to initialize the stop then submit the entry so that the stop is attached to the entry, that looks like this:

    SetStopLoss(yourvalues);
    EnterLong();

    later you can call SetStopLoss again from other conditions in OnBarUpdate to update it.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks, what if i have two speperate entry orders and I want to manage two separate stoploss orders for them, can I do that with SetStopLoss()?

      Comment


        #4
        Hello sjmuk1,

        Yes its the same exact concept you would just have two separate entry orders and two separate SetStopLoss syntax.

        The Signal name from the entry order is used to tie a stop to that entry so you would have two entries with unique signal names and then each of your targets can reference a specific entry to close out part of a position.
        JesseNinjaTrader Customer Service

        Comment


          #5
          OK Thanks, How could you suggest i approach checking my open positions for moving them to breakeven at some point if I am using SetStopLoss(). I'll have filled entry order objects to check and some will be closed positions with cancelled or filled stops and some will be open positions with active working stops. I want to only check breakeven on the ones that are currently open positions. What do you suggest?

          Comment


            #6
            Hello sjmuk1,

            There is a sample in the following link that shows how you can do a breakeven. The sample is not using SetStopLoss but is instead using ExitLongStopMarket, if you wanted to use SetStopLoss instead you could replace the ExitLongStopMarket order syntax with SetStopLoss. This sample otherwise lines up with what you described, it uses Order objects to know the state of the orders and also uses the order events to drive its logic.



            The important parts of this sample would be its use of OnExecutionUpdate and OnOrderUpdate to manage its Order variables. Also OnBarUpdate where the entry is submitted and the break even for the target is managed. The Position and Order information are used from OnBarUpdate to delegate the breakeven and entry.

            This sample only uses 1 order for simplicity, I would suggest that you initially do the same to make sure you have a single order being tracked correctly. That also lets you change to using SetStopLoss if you wanted. Once you do that you can expand it to support multiple entries or scaling if you wanted to.



            JesseNinjaTrader Customer Service

            Comment


              #7
              Thanks that's helped me.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by cls71, Today, 04:45 AM
              0 responses
              1 view
              0 likes
              Last Post cls71
              by cls71
               
              Started by mjairg, 07-20-2023, 11:57 PM
              3 responses
              213 views
              1 like
              Last Post PaulMohn  
              Started by TheWhiteDragon, 01-21-2019, 12:44 PM
              4 responses
              544 views
              0 likes
              Last Post PaulMohn  
              Started by GLFX005, Today, 03:23 AM
              0 responses
              3 views
              0 likes
              Last Post GLFX005
              by GLFX005
               
              Started by XXtrader, Yesterday, 11:30 PM
              2 responses
              12 views
              0 likes
              Last Post XXtrader  
              Working...
              X