Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

A slithering Stop

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

    A slithering Stop

    This isn't an original idea, but I don't remember exactly where I got the idea from.

    Imagine after a decent up move, that the stop doesn't trail by ticks or percentage, but by the lows of the bars. In essence, this will continue to trail a long position until a truly new low is made.

    In this case, lets say 5 bars...

    So I'd want the stop to be the lowest low of the last 5 bars (minus a tick). Here's what I've come up with so far, but it doesn't seem to work at all during strategy testing. As a test, I just use a 2/3 period moving average for entries, so I can test the stop. However, it seems the only exits are the new entries in the other direction...

    So this is what I have as an idea so far:

    VARS:

    private int barsAgo = 5;

    OBU:

    int LoBar = LowestBar(Low, barsAgo);
    int HiBar = HighestBar(High, barsAgo);

    if(Position.MarketPosition == MarketPosition.Long)
    {
    SetStopLoss(CalculationMode.Ticks, Low[LoBar] - 1*TickSize);
    }


    Thanks for your help ahead of time.

    #2
    Ummm - What is your CalculateOnBarClose set to?

    If FALSE - then this hardly has a chance of becoming true, since you would be always setting your stop loss 1 tick lower than the current low. You would need to exclude the current bar.

    if TRUE - it looks like it would work.

    Comment


      #3
      Originally posted by Darth_Trader View Post
      This isn't an original idea, but I don't remember exactly where I got the idea from.

      Imagine after a decent up move, that the stop doesn't trail by ticks or percentage, but by the lows of the bars. In essence, this will continue to trail a long position until a truly new low is made.

      In this case, lets say 5 bars...

      So I'd want the stop to be the lowest low of the last 5 bars (minus a tick). Here's what I've come up with so far, but it doesn't seem to work at all during strategy testing. As a test, I just use a 2/3 period moving average for entries, so I can test the stop. However, it seems the only exits are the new entries in the other direction...

      So this is what I have as an idea so far:

      VARS:

      private int barsAgo = 5;

      OBU:

      int LoBar = LowestBar(Low, barsAgo);
      int HiBar = HighestBar(High, barsAgo);

      if(Position.MarketPosition == MarketPosition.Long)
      {
      SetStopLoss(CalculationMode.Ticks, Low[LoBar] - 1*TickSize);
      }


      Thanks for your help ahead of time.
      Low[LoBar] - 1*TickSize
      is a huge amount of ticks on most instruments.

      Did you intend to set a Price or a Tick offset? From how you pose the question, you should probably be using CalculationMode.Price.
      Last edited by koganam; 05-31-2015, 02:36 PM. Reason: Corrected punctuation.

      Comment


        #4
        1) Good point Sledge, I wasn't sure...but after checking it IS set to true.

        2) Koganam - I apologize, I wasn't clear. What I am hoping to do is determine the lowest low of the last 5 bars, then offset it one more tick (which I will probably set as a chosen variable later). Then set that as a stop loss until the close of the next bar where it will now recalculate. So that's why I subtracted the tick, but if that screws up the calcMode configuration, then that's probably what I did to screw it up.

        The purpose of this type of stop is that unless a new low is made, the stop will continue to become tighter and tighter, but still give the opportunity for another continuation move. This sort of stop naturally has volatility built in, so it doesn't have to be a modified percentage or based on some sort of ATR measurement per bar.

        Also, since most live traders usually move their own stop by hand to a tick or two below the last balance/low area, this does it naturally also.

        I will give the CalculationMode.Price a shot and see how that goes.

        Comment


          #5
          That solved it

          Thanks Koganam!

          That solved it all. It works precisely how I intended.

          Thank you for all your help!


          - DT

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by trilliantrader, 04-18-2024, 08:16 AM
          4 responses
          18 views
          0 likes
          Last Post trilliantrader  
          Started by mgco4you, Today, 09:46 PM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by wzgy0920, Today, 09:53 PM
          0 responses
          9 views
          0 likes
          Last Post wzgy0920  
          Started by Rapine Heihei, Today, 08:19 PM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by Rapine Heihei, Today, 08:25 PM
          0 responses
          10 views
          0 likes
          Last Post Rapine Heihei  
          Working...
          X