- ago
Kindly consider adding the ability to specify the period used for ATR in CloseAtTrailingStop(... TrailingStopType.ATR...).
---------------------------------------

TrailingStopType has 5 possible values: PercentC / PointC / PercentHL / PointHL / ATR.
The first four can be fully customized using just one parameter and that's provided. However, ATR requires two - the ATR period and the ATR multiple; currently one can only specify the latter. The current ATR period default is 22 and while that may be appropriate in some situations its hardly suitable in all possible scenarios e.g. a user may find it unsuitable for Monthly and Weekly scales, and also perhaps in many Daily scale strategies (depending on context).

I request the developers to expose the ATR period as a user-selectable parameter; it can be prepopulated with a default value yet give the user the ability to modify it as appropriate.
2
551
15 Replies

Reply

Bookmark

Sort
- ago
#1
When we added it without the period, we intentionally refrained from making it more complex than necessary. 22 days are chosen exactly as the period used in the Chandelier Exit formula (a.k.a. the classic ATR trailing stop): https://school.stockcharts.com/doku.php?id=technical_indicators:chandelier_exit

If you want customization, sure it's possible to code this straight in your C# Strategy.
0
Cone8
 ( 26.65% )
- ago
#2
@Glitch, what do you think? Shall we do this?

CODE:
public void CloseAtTrailingStop(Position pos, TrailingStopType tst, double amount, string signalName = "", int atrPeriod = 22)

Seems simple enough and anyone who doesn't want to use it, doesn't have to.
0
- ago
#3
On second thought, adding the optional parameter to CloseAtTrailingStop looks like a no-brainer. Probably we're going to spend more time documenting it. :)

UPDATE: it turns out that the QuickRef for CloseAtTrailingStop required an update for a missing parameter so it's about time. Went ahead and committed the changes.
0
- ago
#4
Thanks!
0
ww58
- ago
#5
How about adding a step parameter to the trailing stop?
0
- ago
#6
There's no need for more parameters than the amount and atrPeriod, right?
0
Cone8
 ( 26.65% )
- ago
#7
You just need to add atrPeriod and modify the routine to use it.
0
- ago
#8
I've done it already @Cone, sorry for the confusion. I was replying to @ww5 who seems to be missing the "amount" parameter, judging by his "step parameter" question.
0
ww58
- ago
#9
>I was replying to @ww5 who seems to be missing the "amount" parameter, judging by his "step parameter" question.

By "step" I meant something else, how much the price should pass before the trailing is activated. For me it is not critical, it just helps in highly volatile markets
0
- ago
#10
QUOTE:
By "step" I meant ... how much the price should pass before the trailing is activated.

You can pass a C# object (such as a value or a struct of values, etc.) with the Tag attribute on a Position object. Moreover, you can assign this Tag following a PlaceTrade operation with the Tag property of that PlaceTrade Transaction.

Check the QuickRef under Transaction for the Tag property. If there are questions, start a new topic about passing custom arguments with the Tag property.
0
- ago
#11
QUOTE:
By "step" I meant something else, how much the price should pass before the trailing is activated.

This seems extraneous to CloseAtTrailingStop. If I'm reading you correctly, the general idea is to have a price action- (and maybe time-) based condition as a prerequisite to activating an exit - not necessarily a trailing one.

I don't see how @superticker's reply is helpful in this context. But you can simply program the condition in strategy's C# code, checking if the price has moved X ATR/%/$ compared to position's entry price.
0
- ago
#12
Just updated to B36. As per the update notes this has been implemented and the QuickRef also mentions it. Unfortunately, the ATR period field is missing as the following screenshot shows:


Hope this gets fixed soon.
0
- ago
#13
My bad. Missed exposing it here.🤦‍♂️Fixed for next build.
0
- ago
#14
Fixed in B37.
0
- ago
#15
Thanks!
0

Reply

Bookmark

Sort