Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

how to control SetTrailingStop properly

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

    how to control SetTrailingStop properly

    I want my trailing stop to trail by 1 ATR so I figured I'd call SetTrailingStop in the onBarUpdate() event to update it with the current ATR. However on trade I found exits as soon as it enters. So I get some weird exit executions, as if I am not implementing SetTrailingStop properly.

    See the attached image. Any advice?

    PS forgot to include the code I'm using:

    SetTrailStop(CalculationMode.Ticks, atr1[0] / TickSize);
    Attached Files
    Last edited by adamus; 11-12-2010, 07:27 AM.

    #2
    Hi adamus,

    A few suggestions:
    1. Monitor your stoploss to see what values you are truly submitting: http://www.ninjatrader.com/support/f...ead.php?t=5790

    2. I generally use SetStopLoss to add a little more control, as seen in this sample: http://www.ninjatrader.com/support/f...ead.php?t=3222
    TimNinjaTrader Customer Service

    Comment


      #3
      I have put logging into my strategy to show the stop loss level with SetTrailingStop and in 99% of trades it functions as expected, however I am still seeing the occasional malfunction.

      I'm attaching the chart that show the entry and the Trail stop exit at exactly the same price on the same bar.

      My logging shows that the Trail stop is below the market, so it's gone badly wrong since this is a short trade.

      2010-03-22 13:00:00 $CADJPY BarUpdate Flat O[88.68000] H[88.68000] L[88.48000] C[88.51500]
      2010-03-22 13:05:00 $CADJPY BarUpdate Flat O[88.51500] H[88.52000] L[88.26000] C[88.26000]
      2010-03-22 13:05:00 $CADJPY placeOrder() SellShort 100000 MKT (PendingSubmit)
      2010-03-22 13:05:00 $CADJPY BarUpdate OOs: SellShort 100000 MKT (PendingSubmit)
      2010-03-22 13:05:00 $CADJPY Execution SellShort 100000 MKT (Filled) @88.26000
      2010-03-22 13:05:00 $CADJPY Execution BuyToCover [email protected] STP (Filled) @88.26000
      2010-03-22 13:10:00 $CADJPY BarUpdate Flat O[88.26000] H[88.26500] L[87.97000] C[88.12500]
      Attached Files

      Comment


        #4
        adamus, would you reset the stop to a default value when you're flat in your strategy? This would be needed as otherwise you could use an 'old' stop value from a prior trade still.

        Comment


          #5
          Hi Bertrand,

          how can that make any difference?

          I do set the trailing stop in onBarUpdate(), but considering that I use something like this:

          Code:
          SetTrailStop(CalculationMode.Ticks, atr1[0] / TickSize);
          where atr1 is the 100 bar ATR, then it never really deviates from a standard value for long or short trades, unless I misunderstand what you mean by 'default'.

          Or do I have to set it to a negative value for short trades?

          Comment


            #6
            Hi adamus,

            A few things...
            1. Print your custom values for the Stop Loss to ensure you are submitting values that really make sense here.

            2. Make sure you reset the TrailStop to be sure you're not getting a value used from before: http://www.ninjatrader-support.com/H...l?SetTrailStop

            3. Not sure how you are logging the entires, but try using TraceOrders to truly see what is happening: http://www.ninjatrader.com/support/f...ead.php?t=3627
            TimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

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