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

SetProfitTarget() and SetStopLoss() clarification

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

    SetProfitTarget() and SetStopLoss() clarification

    Hi all,

    I'm new in the forum and my name's Marco. I would like to ask for a clarification about the SetProfitTarget() and SetStopLoss() methods.

    In the tips list (https://ninjatrader.com/support/help...ttrailstop.htm) there's the following statement:

    If a stop loss or trail stop order is generated in addition to a profit target order, they are submitted as OCO (one cancels other)

    Is it means that I cannot set a ProfitTarget and a StopLoss simultaneously?

    Thanks a lot,
    Marco

    #2
    Hello Mbk2787 and welcome to the forum,

    This does not mean that you can not submit the ProfitTarget and StopLossat the same time. The OCO functionality just means when one of the orders fills, the other one cancels out ,or if one gets cancelled the other order gets cancelled as well.
    For more information on OCO please see the following link, http://www.investopedia.com/terms/o/oco.asp
    Cody B.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the clarification Cody.

      This means that, if the actual position is closed, I have to call again the SetStopLoss() method for the next position. Is it correct?

      The same concept is applied for the SetProfitTarget() method?

      Thanks.

      Comment


        #4
        generally speaking, no. you wont need to do that. however, it depens a bit on what ur tryin to do and how you wanna use it, so u might still have to do it.

        but if we are talking about the same kind of entry than before, and your stoploss is dynamic (meaning it takes the entry in consideration)then definitly no. then u can call stoploss and target once in your code and it will apply those values to every position you enter (if possible).

        but remember. you might have to define diffrent stoplosses depending on your entrysignal or your entrydirection.

        an example for an dynamic stoploss. would be Close[0]+0.001
        this stoploss ofc couldnt be applied to a long position, since u cant place the stop above the entry. so u might need a diffrent stop. with Close[0]-0.001.

        if you use a currency based stop however, so SetStopLoss(500); then u wont need to do that since you would simply get stopped out once u are 500 units down. but, its not ideal to use that kind of order, since it would only be send to the broker once the "goal" is reached. so if your internet breaks down, u wouldnt have an actual stop in place. thats why u should always try to use actual pricesbased stoplosses.

        the topic is i guess a bit to big to cover it all at once, if you need further assistance id suggest you share a bit of your code especially the parts where you enter and how u use ur entry and exit orders. but you might as well just test things out with the stratagy analyzer and then come back when things are not working the way you want them to work.

        Comment


          #5
          Hello,

          What Bigro comments on this is correct. It really depends on how you are calling your SetStopLoss() and SetProfitTarget(). Essentially you do not need to have code in place for each order that you make unless you are adding in the logic to do that, but that will most the time be more work than is needed.
          If you are setting the values dynamically then the only condition is the code needs to run again, meaning that you have entered a position again.
          If you are using SetStopLoss() and SetProfitTarget() in the Initialize() method then you would not need to do that either as this will cause all entry orders to be submitted with a Stop Loss and Profit Target.
          If you need further clarification on this please provide an example of how you are using your entry methods and SetStopLoss() and SetProfitTarget().
          Cody B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by mattbsea, Today, 05:44 PM
          0 responses
          3 views
          0 likes
          Last Post mattbsea  
          Started by RideMe, 04-07-2024, 04:54 PM
          6 responses
          31 views
          0 likes
          Last Post RideMe
          by RideMe
           
          Started by tkaboris, Today, 05:13 PM
          0 responses
          2 views
          0 likes
          Last Post tkaboris  
          Started by GussJ, 03-04-2020, 03:11 PM
          16 responses
          3,282 views
          0 likes
          Last Post Leafcutter  
          Started by WHICKED, Today, 12:45 PM
          2 responses
          20 views
          0 likes
          Last Post WHICKED
          by WHICKED
           
          Working...
          X