How to set a profit target with a trailing stop at the same time? #345
-
Hi Community and Creators, I was testing a strategy on conditions when today's close price is lower than past 7 day's close and take profit when the close is higher than the past 7 day's close. The stop loss is a trailing stop of 2*ATR(20) like it shows in the example. However, I couldn't make the strategy work since it gave me some errors about the rolling function can't be apply to the array and also I am not sure if it can be wrote as this logic below. Any help will be appreciated! Thank you a lot
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You are not returning anything from your Also be aware of the availability of def nd_low(s, n):
return s.rolling(n).min().shift()
nday_low = self.I(nd_low, self.data.Close.s, self.entry_period) |
Beta Was this translation helpful? Give feedback.
You are not returning anything from your
nd_low
andnd_high
.Also be aware of the availability of
.s
accessor.