Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Sample Bracket Order w/Profit Target & Stop Loss

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

    Sample Bracket Order w/Profit Target & Stop Loss

    Hi All,

    Is there a sample Ninja Script for a bracket order that once executed the side that didn't execute gets canceled and the profit target and stop loss orders are placed also as OCO orders?

    From what I read, this would be done under the unmanaged order approach.

    Any help is greatly appreciated!

    #2
    Hello GeoOrtiz,
    Unfortunately we do not have any sample codes in such lines.

    Yes, you have to use the unmanaged approach to place bracket orders.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Hello Joydeep,

      I reviewed the unmanaged approach from the help files, but I can't find any reference as to how to enter a bracket order. One of the parameters of SubmitOrder() says "A string representing the OCO ID used to link OCO orders together", but there is no other mention as to how to link the orders. The examples only refer to single orders. I don't mind doing the research, I just don't know where to go from here. The documentation under Unmanaged Approach is very limited. Please point me in the right direction. Thank you!

      Comment


        #4
        Hello GeoOrtiz,
        You simply append a similar oco name to both the order. For example the below code will submit a buy and a sell limit order (with the OCO tag). If the buy order get filled the sell order will get cancelled.

        Code:
        SubmitOrder(0, OrderAction.Buy, OrderType.Limit, 1, Close[0] - TickSize * 10, 0, [B]"OCO"[/B], "LONG");
        SubmitOrder(0, OrderAction.Sell, OrderType.Limit, 1, Close[0] + TickSize * 10, 0, [B]"OCO"[/B], "SHORT");
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Thank you Joydeep. That was the missing part of the puzzle.

          Comment


            #6
            Managed Approach

            actually these will be set as "OCO" too when defined in combination:

            Code:
            			SetProfitTarget("long", CalculationMode.Percent, LimitPercent);
            			SetStopLoss("long", CalculationMode.Percent, StopPercent, false);

            Comment


              #7
              Originally posted by patroqueeet View Post
              actually these will be set as "OCO" too when defined in combination:

              Code:
              			SetProfitTarget("long", CalculationMode.Percent, LimitPercent);
              			SetStopLoss("long", CalculationMode.Percent, StopPercent, false);
              nt says these setprofittarget and setstoploss can't be used for unmanaged approach.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by judysamnt7, 03-13-2023, 09:11 AM
              4 responses
              55 views
              0 likes
              Last Post DynamicTest  
              Started by ScottWalsh, Today, 06:52 PM
              4 responses
              35 views
              0 likes
              Last Post ScottWalsh  
              Started by olisav57, Today, 07:39 PM
              0 responses
              7 views
              0 likes
              Last Post olisav57  
              Started by trilliantrader, Today, 03:01 PM
              2 responses
              19 views
              0 likes
              Last Post helpwanted  
              Started by cre8able, Today, 07:24 PM
              0 responses
              7 views
              0 likes
              Last Post cre8able  
              Working...
              X