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...

    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 argusthome, 03-08-2026, 10:06 AM
          0 responses
          69 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          42 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          24 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          27 views
          0 likes
          Last Post TheRealMorford  
          Started by Mindset, 02-28-2026, 06:16 AM
          0 responses
          54 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X