Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NonStopping Stop Loss??!!

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

    NonStopping Stop Loss??!!

    Hello,

    I am using an Unmanaged approach in NinjaScript to create an OCO order. This process works and the Submit order code is pasted below in Code 1


    ***************** Code 1 *******************

    longOrder = SubmitOrder(0, OrderAction.Buy, OrderType.StopLimit, 1, tickPrice +3 * TickSize, tickPrice +3 * TickSize, String.Format("Oil" + qty), "long limit entry");

    ***************** End of Code 1 *******************


    In the Following OnExecution Event I then create a Stop Loss. This also works and I can see it trailing the market price on the chart - Notice the ocoid differs from the one associated with the current long order.

    ***************** Code 2 *******************

    stopOrder = SubmitOrder(0, OrderAction.SellShort, OrderType.StopLimit, 1, tickPrice -1 * TickSize, tickPrice -1 * TickSize * TickSize, String.Format("OilStop" + qty), "Stop loss to protect long");

    ***************** End of Code 2 *******************

    The thing though is that when the market prices reverses and hits my Stop loss, it simply goes past it leaving it unaffected. Why does it not get a fill and close the current "Long" position?

    C

    #2
    Hello,

    Thank you for the question.

    Do you get the same result with a stop market order?

    The stop limit order would not necessarily have to fill depending on the market.

    I look forward to being of further assistance.

    Comment


      #3
      Hmmmm... Not sure what I'm doing so this is what iv got. Iv changed the "SubmitOrder" to OrderType.Stop. This had no impact

      ***************** Code 1 *******************

      stopOrder = SubmitOrder(0, OrderAction.SellShort, OrderType.Stop, 1, tickPrice -1 * TickSize, tickPrice -1 * TickSize * TickSize, String.Format("OilStop" + qty), "Stop loss to protect long");

      ***************** End of Code 1 *******************

      The trail part then calls the code below. does this have to be changed also? What to?

      ChangeOrder(stopOrder, 1, stopOrder.LimitPrice, pTickPrice -1 * TickSize)

      Comment


        #4
        Hello,

        Yes I was referring to your stop loss as the one to modify from limit to just stop, the limit could potentially be passed so setting a stop should prevent the price from moving through it.

        I look forward to being of further assistance.

        Comment


          #5
          Changed

          ChangeOrder(stopOrder, ContractCnt, stopOrder.LimitPrice, pTickPrice -1 * TickSize

          to

          ChangeOrder(stopOrder, ContractCnt, stopOrder.Stop, pTickPrice -1 * TickSize

          However it wouldn't compile. "Cbi.Iorder does not contain a definition for stop"

          Comment


            #6
            Hello,

            I think there was some confusion, I was referring to your stop you originally posted about, I am still looking at the information you originally provided and not the change order in which you just posted about.

            What I was referring to was to change:
            Code:
            ***************** Code 2 *******************
            
            stopOrder = SubmitOrder(0, OrderAction.SellShort, [B]OrderType.StopLimit[/B], 1, tickPrice -1 * TickSize, tickPrice -1 * TickSize * TickSize, String.Format("OilStop" + qty), "Stop loss to protect long");
            
            ***************** End of Code 2 *******************
            to:

            Code:
            ***************** Code 2 *******************
            
            stopOrder = SubmitOrder(0, OrderAction.SellShort, [B]OrderType.Stop[/B], 1, tickPrice -1 * TickSize, tickPrice -1 * TickSize * TickSize, String.Format("OilStop" + qty), "Stop loss to protect long");
            
            ***************** End of Code 2 *******************
            I look forward to being of further assistance.

            Comment


              #7
              Hi... Well yes I made the change however it made no difference.. The StopLoss still wasn't filled

              Comment


                #8
                Hello,

                Thank you for trying that.

                Can you please use TraceOrders to see what is being reported as the orders happen?



                and then use the Tools -> Output window to view the orders output.

                I look forward to being of further assistance.

                Comment


                  #9
                  I noticed this in the Trace

                  First the Short was created
                  Execution='fa5ee5923b0e469291ff1db4fe982a4c' Instrument='CL 12-14' Account='Sim101' Name='Short limit entry' Exchange=Default Price=74.45 Quantity=1 Market position=Short



                  Next the Submit order for the Stop Loss

                  SubmitOrder() method at 18/11/2014 17:28:31: Action=BuyToCover OrderType=Stop Quantity=1 LimitPrice=74.46 StopPrice=74.45 OcoId='OilStop1' Name='Stop loss to protect short'


                  Then the market began to trail... however should the limit price be "0"
                  Action=BuyToCover Limit price=0 Stop price=74.46 Quantity=1 Strategy='OilSpike' Type=Stop


                  C

                  Comment


                    #10
                    Hello,

                    Thank you for that,

                    Just checking is this during live/Historical or is this in a backtest?

                    I look forward to being of further assistance.

                    Comment


                      #11
                      Live... But I am in SIM

                      Comment


                        #12
                        Hello,

                        Thank you.

                        Can you please email me your trace and logs?

                        In NinjaTrader go to Help -> Mail to support and send the log and trace files.

                        Please reference ticket: 1198066 in the area where you can put text.

                        I look forward to being of further assistance .

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        647 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        369 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        108 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        572 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        573 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X