Replies: 1 comment
|
It depends on how exact you need the rule to be. For a simple long-only strategy with one open position at a time, you can build the exit signal from two conditions:
Conceptually: raw_exit = rsi > 70
entry_price = close.where(entries).ffill()
exits = raw_exit & (close > entry_price)Then pass But there is an important caveat: this simple For a robust version, especially with pyramiding, partial exits, short positions, fees, or multiple entries, I would implement this in a custom signal/order function where you can inspect the current position state and compare the current price against the actual average entry price. The rule is path-dependent, so it belongs inside the simulation if the portfolio state can become non-trivial. Also remember to include fees/slippage in the profitability test if your real rule is “exit only when net profitable”. In that case |
Uh oh!
There was an error while loading. Please reload this page.
Let's say you exit when RSI>70.
How to add a filter to exit only when profitable ?
All reactions