Alternative exit for this strategy

Course Name: Quantitative Trading Strategies and Models, Section No: 2, Unit No: 4, Unit type: Notebook

Hello,

I was wondering if for the exit signal and a vectorized backtest this can be done:

I'm placing '1' when buy signal, '-1' when a sell signal and '0' if the candle 5 periods ago is '1' or '-1' (exit). After than I use .ffill() in signal column. Is this correct?

Hi Daniel,



Your approach should be able to ensure positions are held for exactly 5 days or exited by a counter-signal. However, if you need more explicit tracking of the trade duration and the exit process, the loop-based approach is more transparent in that sense.



Thanks

Rushda

Thanks!