I'd say that the filter data[::h] is unnecessary since we've already computed the pct_change after h days – and in practice we can enter a position with a hold period of h days, on any day.
Take this example where we generated the signal without the filter data[::h].
Here the signals are generated every day. But when we use the filter data[::h]. It looks like this.
The signals are generated skipping the holding period which is 5 days here and is closer to real trading.