Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Only move Stop if it is going to be at a better Price than Previous Stop

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

    Only move Stop if it is going to be at a better Price than Previous Stop

    Hi,

    I am moving my stop up to 5 pips below the Low of the last 3 bars.
    This seems to all be fine but I only want my stop to be moved when the new stop position will be better than the last Stop position.

    Below is my code: (Current.StopLoss in Red is what I need help with - I need this part of the script to get the current StopLoss so it can check to see if the new Stop is going to reduce the loss and not increase it):

    // Followup Stop 1 - Moves Stop to 3 Bar Stop


    if (Position.MarketPosition == MarketPosition.Long
    && LowestBar(Low, 2) + -5 * TickSize > Current.StopLoss)

    {
    SetStopLoss(CalculationMode.Price, LowestBar(Low, 2) + -5 * TickSize);
    }



    Thanks for your help,


    Michael
    Last edited by Michael1111; 11-05-2009, 03:55 AM.

    #2
    Michael, you would then need to store your stop value to a variable and compare this each bar if the newly calculated value is more favorable than the last one and only then call SetStopLoss with the new value to move the stop. As an alternative you could also work with the parabolic stop for example, it's also coded to move the stop closer with each bar...
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks for your reply,

      My Stop Value is determined by the setup candle,
      How would I go about storing this stop value?
      Can you please give me an example with a bit of code


      Many Thanks,

      Michael

      Comment


        #4
        Michael,

        You would somehow know which one of your candles was the setup candle. When you are there, just store whatever value you need.

        For instance.
        someVariable = Close[0];

        Then you can use someVariable at a later point in time.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Great, Thanks for that, makes sense . I was over complicating it.

          Michael

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by maybeimnotrader, Today, 05:46 PM
          0 responses
          6 views
          0 likes
          Last Post maybeimnotrader  
          Started by quantismo, Today, 05:13 PM
          0 responses
          6 views
          0 likes
          Last Post quantismo  
          Started by AttiM, 02-14-2024, 05:20 PM
          8 responses
          166 views
          0 likes
          Last Post jeronymite  
          Started by cre8able, Today, 04:22 PM
          0 responses
          8 views
          0 likes
          Last Post cre8able  
          Started by RichStudent, Today, 04:21 PM
          0 responses
          5 views
          0 likes
          Last Post RichStudent  
          Working...
          X