Selling based on profit #842
Replies: 2 comments
-
I know this question is probably already answered. I guess my main question is I want to make a selling strategy where if the stock shoots up a certain point to take some profit but not all. Wait a little bit to see if it jumps more, and if it does to incrementally sell shares. But then the more the stock rises the total stop loss goes up. So if I am up 20% profit, I sell a little bit to wait and see if it goes up more but if it drops a certain point to sell everything. Basically incrementally changing my stop loss, and taking partial profit as it goes up. Thanks |
Beta Was this translation helpful? Give feedback.
-
class S(Strategy):
def next(self):
if self.trades:
trade = self.trades[0]
if self.data.Close[-1] / trade.entry_price > 1.10: # If trade in >10% profit
trade.close(.5) # Close half of the trade |
Beta Was this translation helpful? Give feedback.
-
Hello,
During backtesting, how would I code the sell part to be based on profit.
So once I buy a stock, sell when you reached a certain profit % (ex. sell when profit is over 10%)
Beta Was this translation helpful? Give feedback.
All reactions