Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Set Stop Loss with limit price

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

    Set Stop Loss with limit price

    Hallo.
    Can I use the Set method to place StopLoss with limit price or the only way is ExitLongStopLimit()???

    Czarek

    #2
    You will need to use ExitLongStopLimit().
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      I try use this method but the strategy cancell my order on the next bar.
      I use OnExecution(IExecution execution).
      My order syntax is: stopOrderLong1 = ExitLongStopLimit(execution.Order.Filled,firstEntr yLong - stop ,firstEntryLong - stop, "MyStopLong1", "MyEntryLong1");
      Cancelation note:
      20/9/2007 1:55:00 Cancelled expired order: BarsInProgress=0: Order='NT-00365/Back101' Name='MyStopLong1' State=Working Instrument='MHI 10-08' Action=Sell Limit price=26040 Stop price=26040 Quantity=0 Strategy='MHIAVGIOrder' Type=StopLimit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='df9f56e93a604018a468f9c560736a25' Gtd='1/12/2099 0:00:00'

      What could be possiblem reason that strategy cancell my stop order on the next bar?


      Rgsd
      Czarek

      Comment


        #4
        The reason is here in your printout. "Cancelled expired order". You need to resubmit this order every single OnBarUpdate() event or else it will expire and auto cancel. Alternatively you can use liveUntilCancelled = true, but then to cancel it you will have to manually call CancelOrder().
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          is that mean that I should change the method from OnExecution(IExecution execution) to OnBarUpdate() ??

          Comment


            #6
            I would recommend you just use liveUntilCancelled = true. Submit in OnExecution and then cancel if you don't want this order anymore later.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Hallo.
              When I place ExitLongStopLimit() sometimes order price hi the gap between the bars and is never filled. It could bring big losts.
              Is the possible to place 2 stop orders for same position?? One ExitLongStopLimit() and the market order with bigger offset??

              Rgds
              Czarek.

              Comment


                #8
                Czarek,

                You can run into problems placing two orders like that. If the price spikes and hits both stops what happens then? Will both your stops try to fill? That will leave you with a short position. Instead what you may want to do is monitor your first stop and resubmit with adjustments if some weird gapping happens.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Hallo.
                  If my first stop ExitLongStopLimit() hit the gap I would like to cancell it and place ExitLongStop with higher stop price and I would like to sure this time stop order will be executed immidiately that's why I want to place market order.
                  I think I can do do it if I be able too determinate current price than check that is higher than stop price and check that ExitLongStopLimit() is not filled. I think I can monitore stopLimit by StopLoss1 == execution.Order.Token but I do not know to check the current price for comarision to the stop price??

                  Comment


                    #10
                    You can check price like how you normally would do it. Close[0]. You can check your IOrder object for the stop and the limit prices of your orders.


                    Ex:
                    Code:
                    if (myStopOrder != null && Close[0] > myStopOrder.StopPrice)
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      HI.
                      I have 2 questions.
                      1. This is my entry order code:
                      Code:
                      if  (Close[1] < Close[0]
                             && entryOrderLong2 == null)
                          
                         {
                             limitPrice = Close[0]; 
                          entryOrderLong2 = EnterLongLimit(positionsize, limitPrice-priceBack*TickSize,"MyEntryLong2");
                            }
                      if the order (EnterLongLimit) hit he gap, strategy keep this order until next bar close time, than the order is cancelled and if the market going in good direction is placed again and if hit gap again strategy keep it until bar close and cancell again than wait one more bar and place again. Of course each order is placed with adjustment. The problem is that strategy keep order one bar and cancell for the next bar. So one bar order is valid one cancelled.
                      I would like strategy only amend the order price and keep this order all time.
                      The solution I found is cancell && entryOrderLong2 == null but I do not know if strategy will work properly without this code??
                      Can you find for me better solution??
                      My strategy is based on your sampel: Sample OnOrderUpdate.

                      2. What could be the possible reason of such log:5/11/2008 0:31:33 Strategy Error on calling the 'OnExecution' method for strategy 'EUROAVGLimitIOrder2stopBreakeven': Object reference not set to an instance of an object.

                      Rgds
                      Czarek.

                      Comment


                        #12
                        Czarek,

                        1. I am not sure exactly what you mean, but remember that you need to resubmit limit and stop orders on every single bar to keep it alive if you want it not to be automatically cancelled. Please try the liveUntilCancelled = true parameter and then use CancelOrder() when you want to cancel it.

                        2. Please see this tip: http://www.ninjatrader-support2.com/...ead.php?t=4226
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          Josh.
                          I up date code to keep liveUntilCancelled = true parameter and keep odrer alive and order is keep all time but if price hit the gap is not updated on each bar close (price is all time same not amended in each bar close price)
                          if (Close[1] < Close[0]
                          && entryOrderLong2 == null)

                          {
                          limitPrice = Close[0];
                          entryOrderLong2 = EnterLongLimit(0, true,positionsize, limitPrice-priceBack*TickSize,"MyEntryLong2");
                          }
                          How update order price on each bar close???
                          Rgds.
                          Czarek
                          Last edited by Czarek; 11-06-2008, 01:55 PM.

                          Comment


                            #14
                            If you want to update price you will need to resubmit the order. If you are going to resubmit your order on every bar you might as well leave liveUntilCancelled as false and then just keep resubmitting at either the same price or a new price.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Josh.
                              I have tested 3 codes combination, only one works but I'm not sure if it is correct solution.
                              My strategy is based on sample shown here: http://www.ninjatrader-support2.com/...ead.php?t=3222
                              In this sample entryOrderLong1 == null is added to entry conditions.

                              General problem is: how to place EnterLongLimit() and amend this order on each bar close if price hit the gap.

                              1.
                              Code:
                              if ( maxClose < Close[0]
                                              && Open[0] < Close[0]
                                              && maxOpen < Close[0]
                                              && entryOrderLong1 == null
                                              && Position.MarketPosition == MarketPosition.Flat)
                                     {
                                      limitPrice = Close[0];
                                  entryOrderLong1 = EnterLongLimit(0,true,positionsize, limitPrice-priceBack*TickSize,"MyEntryLong1");
                              With liveUntilCancelled=true strategy place order and keep it alive with same price. Do not update price on each bar close.

                              2.
                              Code:
                              if ( maxClose < Close[0]
                                              && Open[0] < Close[0]
                                              && maxOpen < Close[0]
                                              && entryOrderLong1 == null
                                              && Position.MarketPosition == MarketPosition.Flat)
                                     {
                                      limitPrice = Close[0];
                                  entryOrderLong1 = EnterLongLimit(0,false,positionsize, limitPrice-priceBack*TickSize,"MyEntryLong1");
                              With liveUntilCancelled=false strategy place order with adjustment but every second bar. So one bar keep order alive, keep canceled on second bar, and place on third bar etc..
                              Better but stiill not good.

                              3.
                              Code:
                              if ( maxClose < Close[0]
                                              && Open[0] < Close[0]
                                              && maxOpen < Close[0]
                               
                                              && Position.MarketPosition == MarketPosition.Flat)
                                     {
                                      limitPrice = Close[0];
                                  entryOrderLong1 = EnterLongLimit(0,false,positionsize, limitPrice-priceBack*TickSize,"MyEntryLong1");
                              With liveUntilCancelled=false and if snipped: && entryOrderLong1 == null, is removed, strategy place order on the each bar close with adjustment. This solution is OK.
                              But I' not sure if snipped: entryOrderLong1 == null, is removed, strategy will work properly?????
                              I'm arfraid that it could be reason of some errors.

                              Please advise me if I can freely remove if snipped: && entryOrderLong1 == null or show me snipped whih resolve my problem in correct way.

                              Rgds
                              Wesley

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              578 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              334 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              101 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              553 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              551 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X