OPEN-SOURCE SCRIPT

WLSMA: fast approximation

258
🙏🏻 Sup TV & alexgrover

O(N) algocomplexity, just one loop inside. No, you can't do O(1) @ updates in moving window mode, only expanding window will allow that.

Now I have time series & stats models of my own creation, nowhere else available, just TV and my github for now, ain’t no legacy academic industry I always have fun about, but back in 2k20 when I consciously ain’t known much about quant, I remember seeing post by alexgrover recreating Moving Regression Endpoint dropped on price chart (called LSMA here) as a linear filter combination of filters (yea yeah DSP terms) as 3WMA - 2SMA. Now it’s my time to do smth alike aye?

...

This script is remake of my 1st degree WLSMA via linear filter combo. It’s much faster, we aint calculate moving regression per se, we just match its freq response. You can see it on the screen (WLSMAfa) almost perfectly matching the original one (WLSMA).

...

While humans like to overfit, I fw generalizations. So your lovely WMA is actually just one case of a more general weight pattern: pow(len - i, e), where pow is the power function and e is the exponent itself. So:
- If e = 0, then we have SMA (every number in 0th power is one)
- If e = 1, we get WMA
- If e = 2, we get quadratic weights.

We can recreate WLSMA freq response then by combining 2 filters with e = 1 and e = 2.

This is still an approximation, even tho enormously precise for the tasks you’ve shared with me. Due to the non-linear nature of the thing it’s all we can do, and as window size grows, even this small discrepancy converges with true WLSMA value, so we’re all good. Pls don’t try to model this 0.00xxxx discrepancy, it’s not natural.

...

DSP approach is unnatural for prices, but you can put this thing on volume delta and be happy, or on other metrics of yours, if for some reason u dont wanna estimate thresholds by fitting a distro.

All good TV



P.S.: strangely, the first script made & dropped in the location in Saint P where my actual quant way has started ~5 years ago xD, very thankful

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。