Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dynamic StopLoss depending on psychological number

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

    Dynamic StopLoss depending on psychological number

    Hi all,

    I was wondering if it is possible to let a strategy check if a StopLoss is set close to a round number such as 1.2501.

    For example; When I am Long and my original rules tell the strategy the StopLoss has to be at 1.2501, I'd rather have them at 1.2498 because of the psychological number.

    Is it possible to have something like; IF price ends with ....01 THEN set StopLoss 3 pips lower at ....98.

    Thanks in advance!

    #2
    Originally posted by Aqua-Life View Post
    Hi all,

    I was wondering if it is possible to let a strategy check if a StopLoss is set close to a round number such as 1.2501.

    For example; When I am Long and my original rules tell the strategy the StopLoss has to be at 1.2501, I'd rather have them at 1.2498 because of the psychological number.

    Is it possible to have something like; IF price ends with ....01 THEN set StopLoss 3 pips lower at ....98.

    Thanks in advance!
    Code:
    if (StopPrice - (int)StopPrice < 0.0002) StopPrice -= 0.0003;
    Last edited by koganam; 11-09-2014, 09:19 AM.

    Comment


      #3
      Thanks for the input. I get the first part of your coding, but how is the strategy supposed to know what the StopPrice should be? (1.2498 in my example, but for diffrent pairs there are different numbers of course)

      Code:
      if (StopPrice - [COLOR=Red](int)StopPrice[/COLOR] < 0.0002) StopPrice -= 0.0003;

      Comment


        #4
        Originally posted by Aqua-Life View Post
        Thanks for the input. I get the first part of your coding, but how is the strategy supposed to know what the StopPrice should be? (1.2498 in my example, but for diffrent pairs there are different numbers of course)

        Code:
        if (StopPrice - [COLOR=Red](int)StopPrice[/COLOR] < 0.0002) StopPrice -= 0.0003;
        I coded exactly what you wrote. If you want something else, you would have to change it to handle that. For example if you wanted to make it 2 ticks below the round price, then that is what you would code.
        Code:
        if (StopPrice - (int)StopPrice < TickSize * 2) StopPrice = (int)StopPrice - TickSize * 2;

        Comment


          #5
          I've just done this in notepad during a meeting so I don't know if the code is write but I hope it helps....

          Code:
          int reduction = 1;
          string psych[8] = {"00","05","10","25","50","75","90","95"};
          string lvl;
          
          foreach(lvl in psych)
          {
          	if(Convert.ToString(SL).EndsWith(lvl))
          	{
          		if(Position.MarketPosition==MarketPosition.Long)
          		{
          			SL = SL - (reduction * TickSize)
          		}
          		if(Position.MarketPosition==MarketPosition.Short)
          		{
          			SL = SL + (reduction * TickSize)
          		}
          	}
          }

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          633 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          364 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          105 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          567 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          568 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X