Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adjusted Stop Not Working Correctly

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

    Adjusted Stop Not Working Correctly

    Moving closer and closer to getting my strategy completely coded - but still more work to go.

    When my first trade closes out at a profit, the second stop should be moving closer to the price and it is not moving where it should. In fact, it looks like it is not moving at all. I am attaching a screenshot of the chart showing that the stop did not move.

    Here is the code that I have.

    Code:
    // Set the adjusted stop loss
    			if (LongLimit != null
    				&& LongLimit == execution.Order)
    			{
    				LongStopB = ExitLongStop(0,true,DefaultQuantity,execution.Order.AvgFillPrice-(TargetPriceLong - execution.Order.AvgFillPrice),"EntryBStop","LongEntryB");
    			}
    As you can see in the screenshot - the first entry closed out at a very small profit. The second stop is then supposed to move closer. It is supposed to be an equal distance below the entry price as the initial profit target is above the entry price. This allows that if the second entry is stopped out, then the entire trade breaks even.

    The code that is posted above is located in OnExecution
    Attached Files

    #2
    I thought that I would show another example of the stop loss not having moved correctly in case that is important for helping to understand.
    Attached Files

    Comment


      #3
      Originally posted by jg123 View Post
      Moving closer and closer to getting my strategy completely coded - but still more work to go.

      When my first trade closes out at a profit, the second stop should be moving closer to the price and it is not moving where it should. In fact, it looks like it is not moving at all. I am attaching a screenshot of the chart showing that the stop did not move.

      Here is the code that I have.

      Code:
      // Set the adjusted stop loss
                  if (LongLimit != null
                      && LongLimit == execution.Order)
                  {
                      LongStopB = ExitLongStop(0,true,DefaultQuantity,execution.Order.AvgFillPrice-(TargetPriceLong - execution.Order.AvgFillPrice),"EntryBStop","LongEntryB");
                  }
      As you can see in the screenshot - the first entry closed out at a very small profit. The second stop is then supposed to move closer. It is supposed to be an equal distance below the entry price as the initial profit target is above the entry price. This allows that if the second entry is stopped out, then the entire trade breaks even.

      The code that is posted above is located in OnExecution
      This is the price to which you are setting your Stop.
      Code:
      execution.Order.AvgFillPrice-(TargetPriceLong - execution.Order.AvgFillPrice)
      Arithmetically, that translates to: Twice the average fill price - TargetPriceLong

      Is not that what you are seeing? Is that what you really intended? (That quantity does not seem to follow from any specific logical methodology).
      Last edited by koganam; 04-07-2014, 11:56 PM.

      Comment


        #4
        Thanks for your reply koganam.

        two things:

        first, mathematically, I think that I see it differently so maybe you could help me out on that.

        Entry Price - (Target Price - Entry Price) = Adjusted Stop Loss

        Numerically, using arbitrary numbers, it would look like this:

        100 - ( 110 - 100) = 90.

        Does that seem right to you?

        Secondly, in the even that I am seeing the math incorrectly, the stop didn't move at all. So there is probably something else that I am missing to make the stop move??

        Comment


          #5
          Originally posted by jg123 View Post
          Thanks for your reply koganam.

          two things:

          first, mathematically, I think that I see it differently so maybe you could help me out on that.

          Entry Price - (Target Price - Entry Price) = Adjusted Stop Loss

          Numerically, using arbitrary numbers, it would look like this:

          100 - ( 110 - 100) = 90.

          Does that seem right to you?

          Secondly, in the even that I am seeing the math incorrectly, the stop didn't move at all. So there is probably something else that I am missing to make the stop move??
          Well, what was the initial stop? The quantities that you are using for the adjusted stop are themselves invariants, for a particular trade, so can easily calculate to the same value as the initial stop, in which case there will be no movement of said stop. Look in your log, and/or use some Print() statements to verify the actual values that you are passing to the method.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          648 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          369 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          572 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          573 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X