TrailingStop decrease after time

Avatar
  • updated
  • Completed

When it comes to risk management, it often pretty much comes down to the famous risk/reward ratio especially when looking at trading from a stochastic view (expected value…)

We already have some powerful possibilities to set SL and TP based on points or based on volatility (very nice feature, like it very much 😊).
However, setting a fixed risk/reward ratio is not yet possible over the total time of a trade (correct me please if I’m mistaken). Here is why:

  • When you open a trade, a fixed Risk/Reward ratio can be set based on points or based on volatility
  • However, when the win area is reached, I want to use a trailing stop loss. This too, can be based on points or on volatility and can be different to what the condition for SL was when the trade was opened. So, this can change the risk/reward ratio drastically.

What I am suggesting is the possibility to set the Take Profit always based on the current Stop Loss. To illustrate, I will give an example here:

  • We start a trade with a SL based on volatility (e.g., 50 points). We set a Risk/Reward ratio of 0,5. This means, that the Take Profit will be 100 (=50 / 0,5).
  • When volatility increases, let’s say the stop loss becomes 100. This will raise the Take Profit to 200. Until here, we can implement this by using the respective factors for volatility in the SL & TP Options.
  • However, when we enter the win area, let’s say we want to use a trailing stop of a fixed 20 Points. The Take profit on the other hand will not be adjusted, as it is still based on volatility and remains 200. This leads us to a risk/reward ratio of 20/200 = 0,1 which drastically affects the expected value of the trade.

I would suggest implementing the option, to set a fixed Risk/Reward to calculate the Take Profit. So, let’s go back to the example from above. This would then lead to:

  • We again start a trade with a SL based on volatility (e.g., 50 points). We set a fixed Risk/Reward ratio of 0,5. This means, that the Take Profit will be set to 100 (=50 / 0,5).
  • When volatility increases, let’s say the stop loss becomes 100. This will raise the Take Profit to 200.
  • When we now enter the win area with a trailing stop of a fixed 20 Points, the Take profit will be set to 20/0,5=40. This ensures our initial risk/reward ratio of 20/40 = 0,5.

Maybe it is not directly apparent what good this will do. But when analyzing trades mathematically, it is often much easier to have a fixed risk/reward ratio as you can idealize the trades as Bernoulli Experiments with fixed probabilities.

Avatar
2
Andrey Khatimlianskyi
  • Completed

Done in 2.46.2

Avatar
0
Andrey Khatimlianskyi
  • Started
Avatar
0
Andrey Khatimlianskyi
  • Planned (collecting votes)
Quote from hendrik dubbe

Hello Andrey,

From me too, sorry for my late reply 😊. Thank you very much for your detailed reply. First things first, I would rename the topic as suggested by you, however I haven’t quite figured out how to rename ☹.

About your implementation idea: I really appreciate how you break down the idea in just a few parameters. To be honest, I believe that just the three parameters

- Decrease every minutes (for example, 5 mins)

- Decrease coefficient (for example, 0.9)

- Decrease start after minutes (for example, 30 mins)

will suffice. Having an additional exponential coefficient might improve back-testing results in some cases. Additionally, as you suggested in the lower part of the comment, I don’t think that these parameters will be independent! I could maybe just set 0,7*0,9=0,63 as decrease coefficient. Or, as it appears, that the first coefficient remains 0,9, it would be necessary to have one more parameter that defines the time after which the second exponential decrease will be added. Either way, I think this will rather end in too many parameters that cannot be fitted meaningfully.

So, long story short (too late for that by now, I know):

The setup “Decrease every minutes (for example, 5 mins), Decrease coefficient (for example, 0.9) Decrease start after minutes (for example, 30 mins)” will do the job I think

Accepted!

PS: topic renamed )

Avatar
0
hendrik dubbe

Hello Andrey,

From me too, sorry for my late reply 😊. Thank you very much for your detailed reply. First things first, I would rename the topic as suggested by you, however I haven’t quite figured out how to rename ☹.

About your implementation idea: I really appreciate how you break down the idea in just a few parameters. To be honest, I believe that just the three parameters

- Decrease every minutes (for example, 5 mins)

- Decrease coefficient (for example, 0.9)

- Decrease start after minutes (for example, 30 mins)

will suffice. Having an additional exponential coefficient might improve back-testing results in some cases. Additionally, as you suggested in the lower part of the comment, I don’t think that these parameters will be independent! I could maybe just set 0,7*0,9=0,63 as decrease coefficient. Or, as it appears, that the first coefficient remains 0,9, it would be necessary to have one more parameter that defines the time after which the second exponential decrease will be added. Either way, I think this will rather end in too many parameters that cannot be fitted meaningfully.

So, long story short (too late for that by now, I know):

The setup “Decrease every minutes (for example, 5 mins), Decrease coefficient (for example, 0.9) Decrease start after minutes (for example, 30 mins)” will do the job I think

Avatar
0
Andrey Khatimlianskyi

Hendrik, sorry for a late reply!

I agree, let's rename topic to "TrailingStop decrease after time".

It's bad idea to calculate TS size using TS activation time (T1). It will be harder to program and will cause higher CPU usage.

Let's simplify it to the following parameters:

- Decrease every minutes (for example, 5 mins)

- Decrease coefficient (for example, 0.9)

- Decrease start after minutes (for example, 30 mins)

So, after 30 minutes after position opening, TS size will be multiplied by 0.9 every 5 minutes.

For example, with Initial TS size 50 points:

- after 30 minutes it will be 50*0.9 = 45 points

 - after 35 minutes it will be 50*0.9*0.9 = 40.5 points
 - after 40 minutes it will be 50*0.9*0.9*0.9 = 36.5 points

- ...

- after 60 minutes it will be 50*0.9*0.9*0.9*0.9*0.9*0.9*0.9 = 23.9 points

We can also add some exponential coefficient that will increase "Decrease coefficient".

For example, with Exponential coefficient = 0.7:

 - after 30 minutes TS will be 50*0.9 = 45 points (exp coeff is not active yet)
 - after 35 minutes it will be 50*0.9*(0.9*0.7) = 28.35 points
 - after 40 minutes it will be 50*0.9*(0.9*0.7)*(0.9*0.7) = 17.86 points

- and so on..

What do you think?

Avatar
0
hendrik dubbe

Thank you for your kind reply. The calculation of Risk/Reward Ratio at Break Even when profit is 0 is indeed something I forgot. However, your idea of an increasing Trailing Stop depending on “time” is quite charming, I think. I will try to explain why.

Let’s look at the illustrated example:

  • We open a long trade at t=0 at point 1 with an initial stop at SL(t=0) at point 2.
  • When the trade moves in our desired direction, we will hit break even at point 3 at t=T0
  • Depending on the offset we define in trailing stop, then the SL will switch to a trailing stop at t=T1 (point 4).
  • As long as we continue in the long direction, the world is ok and we get richer 😊. Depending on the step size of trailing stop, it will be adjusted (point 4).
  • However, when we head toward a reversal, then this is the level of stop (point 4) will be what we get.
  • Especially in times of market consolidation it can however move sideways for quite some time before finally changing direction an being stopped out (point 5)
  • The idea would now be analogue to what I suggested with the time dependent stop loss just applied to the Trailing stop. Hence, we would increase the Trailing stop exponentially until trade is either stopped out (point 5*) or (hopefully) continues going up.

The algorithm would look like the following:

In the condition of Trailing Stop activated at t = T1 start measuring time.

  • If by the time t = T1+T the trailing stop is changed due to price rise reset timer
  • If Trailing Stop is hit before time reaches t=T1+T, then never mind 😊
  • If at t = T1+T the trailing stop is still at the same level as it was t=T1, then start exponential increase:

TS(t): Trailing Stop value at time t

P(T1+T): Asset price at the moment when the trailing stop will be decreased by time

K: Exponential damping constant (“How quickly is the SL decreased”)

Just one question at the end: This heavily changes the idea from the initial one. Should I rather make it a new suggestion? Or at least change the title name?

Avatar
0
Andrey Khatimlianskyi
  • Under review

This idea is not so clear as previous )

TrailingStop is usually used when some profit is already reached. SL moves to BreakEven.

How to calculate the TP size based on zero SL? )

Another question: why do you need TP if you use TS?

Let's think about "TS decrease coefficient" (based on the position life time) to close more profit )

What do you think?