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

Cancel Stop Loss/Profit Target

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

    Cancel Stop Loss/Profit Target

    Hi,

    My strategy is returning an 'order rejected' message and shutting itself down due to my OCO order residing on IB servers while the strategy tries to exit the position at market.

    Please see the following excerpts of my code:

    SetProfitTarget(CalculationMode.Percent, sellLimit);
    SetStopLoss(CalculationMode.Percent, sellStop);


    and

    if ((ToTime(Time[0]) >= ToTime(9, 59, 0)))
    {
    ExitLong("Exit", "Enter");
    }


    When the second part is called WHILE the OCO (stop loss and profit target) is still active on IB's end, the strategy shuts itself down.

    Is there a way to have NT cancel the stop loss and profit targets prior to submitting the ExitLong order so that this doesn't occur?

    Or is there any other way to solve this?

    Thanks a lot,

    Zuhayr

    #2
    Hello Zuhayr,

    Thank you for writing in.

    You are unable to cancel Set() orders.

    Rather than using SetProfitTarget() and SetStopLoss(), you can use ExitLongStop()/ExitShortStop() and ExitLongLimit()/ExitShortLimit().

    ExitLongStop()
    ExitShortStop()

    ExitLongLimit()
    ExitShortLimit()

    These orders will automatically cancel if the position no longer exists.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ZacharyG View Post
      Hello Zuhayr,

      Thank you for writing in.

      You are unable to cancel Set() orders.

      Rather than using SetProfitTarget() and SetStopLoss(), you can use ExitLongStop()/ExitShortStop() and ExitLongLimit()/ExitShortLimit().

      ExitLongStop()
      ExitShortStop()

      ExitLongLimit()
      ExitShortLimit()

      These orders will automatically cancel if the position no longer exists.
      Hi,

      Thanks a lot for the quick response.

      Are these orders also placed on the broker's end? I would like to have stop loss and profit targets on the broker's end so that if there are connection issues, things will be alright.

      If these are indeed submitted on the broker's end, what makes them different from regular 'SetStopLoss' and 'SetProfitTarget' orders? Do they work like bracket (OCO) orders? Because that's what I need.

      I am not using a margin account so submitting two sell orders individually will not work, they must be bracketed.

      Thanks,

      Zuhayr

      Comment


        #4
        Hello Zuhayr,

        Please take a look at this particular section of our support forum to see where your orders reside (the order states can be checked within the Orders tab of the Control Center): http://ninjatrader.com/support/forum...ead.php?t=5349

        These orders are not OCO. If you would like to OCO orders together, you will need to utilize the Unmanaged Approach and the SubmitOrder() method and specify the same OCO ID for both orders: https://ninjatrader.com/support/help...ubmitorder.htm

        More information about the Unmanaged Approach can be found here: http://ninjatrader.com/support/helpG...d_approach.htm
        Zachary G.NinjaTrader Customer Service

        Comment


          #5
          Hi,

          Thanks for the reply. I'd rather not deal with the order states or other complex things.

          I guess what I'm asking is the following:

          Is there any simple way to exit an position at market while there is an OCO SetStopLoss and SetProfitTarget order in place that won't cause the script to shut itself off due to a cancellation error?

          I guess spoken-code wise it goes as follows:

          Exit position IF:

          price reaches X
          or
          price drops to Y
          or
          time is Z
          Last edited by zuhayr123; 03-18-2016, 10:26 AM.

          Comment


            #6
            Hello Zuhayr,

            Both the stop loss and profit targets should automatically cancel once the managing position is closed by another exit order. I am not clear why you are getting an error.

            Please send me your log and trace files for today so that I may look into what occurred.

            You can do this by going to the Control Center-> Help-> Mail to Platform Support.

            Please reference both my name and a link to this thread in the body of the email. Additionally, please provide the latest date this error occurred so I can look into it.
            Zachary G.NinjaTrader Customer Service

            Comment


              #7
              I've sent the files.

              Thanks a lot,

              Zuhayr

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by cmtjoancolmenero, Yesterday, 03:58 PM
              5 responses
              28 views
              0 likes
              Last Post cmtjoancolmenero  
              Started by gbourque, Today, 06:39 AM
              2 responses
              14 views
              0 likes
              Last Post gbourque  
              Started by rexsole, Today, 08:39 AM
              0 responses
              4 views
              0 likes
              Last Post rexsole
              by rexsole
               
              Started by trilliantrader, Yesterday, 03:01 PM
              3 responses
              31 views
              0 likes
              Last Post NinjaTrader_Clayton  
              Started by Brevo, Today, 01:45 AM
              1 response
              14 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Working...
              X