Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SetTrailStop not adjusting

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

    SetTrailStop not adjusting

    In my strategy I want to use two different trail stops:

    Code:
    if (GetCurrentAsk() >= Position.AvgPrice)
    {
    SetTrailStop(CalculationMode.Ticks, 10/TickSize);
    }
    else
    {
    SetTrailStop(CalculationMode.Ticks, 20/TickSize);
    }
    Basically when the "CurrentAsk" is below the "Position.AvgPrice" I want to have a trail stop with "20/TickSize" and when it is above I want the trail stop to be "10/TickSize".
    The problem is that the trail stop will always stay at "10/TickSize" and it won't adjust if the price drops below the "Position.AvgPrice".

    Do I have to cancel the trail stop first before changing it? If not, what am I doing wrong?

    Thanks a lot!

    Edit: Also, I'd like to know how to cancel a trail stop at "CurrentAsk < Position.AvgPrice" and set a Stop Loss instead. When the CurrentAsk returns to > Position.AvgPrice I'd like to cancel the stop loss and set a trail stop again.
    Last edited by roberttk; 03-21-2014, 04:21 AM.

    #2
    Robert, you could not cancel a Set order explicitly just change it's characteristics dynamically like you attempted. Did you see the return for backtesting or realtime testing? As GetCurrentAsk is just the Close price always in backtesting.

    Comment


      #3
      I'm already using my strategy live. I didn't realize this behavior before.

      Comment


        #4
        Thanks, just also saw your edit, you could not cancel any Set method - the usual approach is for example just using SetStopLoss then and changing the values dynamically as desired, as you could just for example set a price based hard stop then or provide means to update the stop value as the trade progresses and thus have the trailing effect without using SetTrailStop. An example to get started would be found here - http://www.ninjatrader.com/support/f...ead.php?t=3222

        Comment


          #5
          Thanks for the example.
          Still, when I change the trail stop (as described in post #1) it should work? Meaning this is the correct way to change a trail stop?

          Comment


            #6
            Yes, it would. Please run with TraceOrders enabled and you should see the changing value of the stop in the NT output window if the condition triggered to change.

            Comment


              #7
              Ok, I will do that.
              Thanks a lot for the fast help and support!

              Comment


                #8
                I still can't get "SetTrailStop" to work properly. TraceOrders is showing me the correct Trail Stop but it doesn't change the order. I've tested with the simulated data feed and also with my live connection (Vision Financial Markets).
                I'm using "SetStopLoss" with "CalculationMode.Price" now and calculating the trail stop with a function.

                Comment


                  #9
                  Robertkk,

                  What is updated script that you are using?
                  Cal H.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  601 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  347 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  103 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  559 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  558 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X