Hello.

Try to use ROC (Rate Of Change).

https://www.investopedia.com/terms/p/pricerateofchange.asp#:~:text=The Price Rate of Change (ROC) is a momentum-,certain number of periods ago.

... import qnt.ta as qnta ... def single_pass_strategy(data, wma_period=20, roc_period=10): wma = qnta.lwma(data.sel(field='close'), wma_period) sroc = qnta.roc(wma, roc_period) # it measures the angle (tg) weights = xr.where(sroc > 0, 1, 0) return weights ...

Regards.