Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem setting Trailing Stop....

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

    Problem setting Trailing Stop....

    ...Ok,

    I am mostly done with a nice strategy.

    Here is my problem.

    * I open 3 positions.
    * All three get a SetStopLoss.
    * Two have targets. Once the second target is filled....
    ...I call "SetTrailingStop" for the third signal.

    This does not work - somehow, I am stuck with the stop loss order, the stop never starts moving.

    I have trace order in, and I see a set for trailing stop... followed by a cancel.

    Any idea?

    #2
    If you provided the information seen from TraceOrders it will tell you why an order was cancelled.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Here we go:

      Long switching to trail
      22/07/2009 20:35:03 Entered internal SetStopTarget() method: Type=TrailStop FromEntrySignal='HA L3' Mode=Ticks Value=16 Currency=0 Simulated=False
      22/07/2009 20:35:03 Cancelled expired order: BarsInProgress=0: Order='NT-00372/Sim101' Name='Stop loss' State=Cancelled Instrument='YM 09-09' Action=Sell Limit price=0 Stop price=8831 Quantity=1 Strategy='HeinekenAshiReversal' Type=Stop Tif=Gtc Oco='NT-00223' Filled=0 Fill price=0 Token='9168fe5cc17548418b3409bc9f4b21e5' Gtd='01/12/2099 00:00:00'

      I try switching to trailing stop

      Comment


        #4
        What do you mean by "switch"? You can't "switch" from a stop loss to a trailing stop. If you wanted to do that you would need to code the logic yourself. You can only have one of these (SetStopLoss/SetTrailStop) for a single entry order.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          That is my logical words.

          * WHen i open the three positions, I acutally set a stop (SetStopLoss).
          * When two of those are closed and a bar is processed, I put "SetTrailingStop" on the last one - i want THEN to go trailing.

          THis is my "logical switch".

          Comment


            #6
            You open 3 positions. Did you attach a SetStopLoss to each of those 3 in step 1? If so you can't switch to a trail stop.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              This is my code to go long:

              ExitShort ();
              EnterLong (1, ENTRY_L1);
              EnterLong (1, ENTRY_L2);
              EnterLong (1, ENTRY_L3);

              SetProfitTarget (ENTRY_L1, CalculationMode.Ticks, 7);
              SetProfitTarget (ENTRY_L2, CalculationMode.Ticks, 11);

              SetStopLoss (ENTRY_L1, CalculationMode.Ticks, 16, false);
              SetStopLoss (ENTRY_L2, CalculationMode.Ticks, 16, false);
              SetStopLoss (ENTRY_L3, CalculationMode.Ticks, 16, false);
              _TrailMode = false;

              How do you suggest I do that then? I want a stop loss for all orders open... and once the first two fill, the third starts trailing.

              Comment


                #8
                You can't use the Set() methods for your third position. You need to manually do it with ExitLongStop() and just send order modifications when you want it to start trailing.

                See this thread for an idea on programming your own trail stop: http://www.ninjatrader-support2.com/...ad.php?t=10344
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Ok.

                  Can i set the trail if i dont set the stop loss? I mean...
                  ....I can easily set the stop every bar, no problem. THis means I dont have to call SetStopLoss....
                  ....and could try SetTrail

                  Comment


                    #10
                    You can only set one or the other. You can set a Trail Stop but not in conjunction with the Stop Loss.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Note to development: I Suggest allowing this.

                      The SetTrailingStop should cancel the other order (from SetStopLoss) and start trailing from this moment on.

                      THis would be expected.

                      Or, PLEASE, throw an exception. Dont just take the method call and dont do what is asked for without an exception.

                      Comment


                        #12
                        NetTecture,

                        There is some misunderstanding here. When you call SetTrailStop() it places in another order and then you now have TWO orders trying to close one position. This is not what you want and that is why you should not call both methods.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          This is absolutley no misunderstanding.

                          I want to get rid of the stop loss (which I can not) and switch the order over to a trailing stop.

                          This you do not allow. Want to argue that this is inconvenient for those incidents that is needed (like me now)?

                          Same time you do note an error in the output on trace, but no feedback to the programmer. THis is bad practice. I should get an exception - in fact, InvalidOperationException.

                          That said, I suggest you fix it. If I call SetTrailingStop, and there is a StopLoss, then cancel the stop loss. Allow me the move over. That simple.

                          Comment


                            #14
                            NetTecture,

                            Thank you for the suggestion. For you to proceed forward, you should NOT call both Set methods for a single order. If you want to switch you should use ExitLongStop().
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Josh, if you want that to get bad...

                              ...yes, I know. This means your frameeowkr is limited.

                              And on top, not proving me feeback on the method call is a violation of C# and .NET coding guidelines.

                              Obviously someone:
                              * overlooked people may need a little more
                              * did not care enough about providing feedback on method call (i.e. throw an exception).

                              That is all.

                              Naturally I will work around I dont do anything else half the day today thanks to various little "ok, I am a beginner designer and never made an API" issues.

                              Slowly I get there. Once I have the trail in, I am done.

                              Which is complicated, thanks to... the need.... to.... trail per market update. No more bars completed.... Sadly.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              651 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              370 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              109 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              574 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              577 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X