Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Modifying Trailing Stop

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

    Modifying Trailing Stop

    I have would like to know how to implement the latter, which was for a stop loss for trailing stop. The caveat is that I want to keep my use input and just divide my "TrailingStop" by two or whatever. My issue is how to divide it by two? Once and if "Trailing Stop" can be divide will the following work?

    // Resets the trailing stop to the original value when all positions are closed
    if (Position.MarketPosition == MarketPosition.Flat)
    {
    SetTrailStop(CalculationMode.Ticks, TrailingStop);
    }

    // If a long position is open, allow for trailing stop modification
    else if (Position.MarketPosition == MarketPosition.Long)

    // Once the price is greater than entry price+50 ticks, set trailing stop to half of use input
    Close[0] > Position.AvgPrice + 50 * TickSize)
    {
    SetTrailStop(CalculationMode.Price, TrailingStop/2);
    }

    #2
    Originally posted by Hammerhorn View Post
    I have would like to know how to implement the latter, which was for a stop loss for trailing stop. The caveat is that I want to keep my use input and just divide my "TrailingStop" by two or whatever. My issue is how to divide it by two? Once and if "Trailing Stop" can be divide will the following work?

    // Resets the trailing stop to the original value when all positions are closed
    if (Position.MarketPosition == MarketPosition.Flat)
    {
    SetTrailStop(CalculationMode.Ticks, TrailingStop);
    }

    // If a long position is open, allow for trailing stop modification
    else if (Position.MarketPosition == MarketPosition.Long)

    // Once the price is greater than entry price+50 ticks, set trailing stop to half of use input
    Close[0] > Position.AvgPrice + 50 * TickSize)
    {
    SetTrailStop(CalculationMode.Price, TrailingStop/2);
    }
    If you are specifying the TrailingStop variable in ticks, then your price calculation is not valid. Correct would be:
    Code:
     
    double StopPrice = Close[0] - TickSize * TrailingStop/2;
    SetTrailStop(CalculationMode.Price, StopPrice);
    Of course, you can concatenate that into one line.

    Comment


      #3
      It should be ticks, sorry. Does that make a difference in your example? I don't see the English in your assistance. Can you break it down for me?
      Last edited by Hammerhorn; 05-03-2013, 11:11 PM.

      Comment


        #4
        Originally posted by Hammerhorn View Post
        It should be ticks, sorry. Does that make a difference in your example? I don't see the English in your assistance. Can you break it down for me?
        I am not sure that I understand your query. My answer assumed that TrailingStop is in ticks, so that is still the answer.

        All it does it to calculate the correct stop price (in the first line), then use that value in the SetTrailStop() method in the next line.

        That having been said, I find that using CalculationMode.Price with SetTrailStop() to be dodgy, so I would just use CalculationMode.Ticks straight out where you have used CalculationMode.Price, thus:
        Code:
        // Once the price is greater than entry price+50 ticks, set trailing stop to half of use input
        Close[0] > Position.AvgPrice + 50 * TickSize)
        {
        SetTrailStop(CalculationMode.[B]Ticks[/B], TrailingStop/2);
        }
        Last edited by koganam; 05-04-2013, 08:17 AM.

        Comment


          #5
          Thanks, sorry for the confusion, I guess I should not reply when it late and I got a baby in my arms.

          Actually, tried inputting,
          // Once the price is greater than entry price+50 ticks, set trailing stop to half of use input Close[0] > Position.AvgPrice + 50 * TickSize) { SetTrailStop(CalculationMode.Ticks, TrailingStop/2); }
          and I get nothing but errors.
          Last edited by Hammerhorn; 05-04-2013, 02:32 PM.

          Comment


            #6
            Hello Hammerhorn,

            Thank you for your post.

            What errors are you receiving? Can you detail the errors in your response or provide a screenshot of these errors?

            I look forward to your response.

            Comment


              #7
              As it is coming back to me I sometimes surprise myself. I added "If" and it fixed it. Tested and works beautiful, thank you again for your assistance and patience.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              649 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              370 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              109 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              574 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              576 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X