TradingView
alexgrover
2019年3月1日午後8時34分

1LC-LSMA (1 line code lsma with 3 functions) 

EUR/USDOANDA

詳細

Even Shorter Estimation

I know that i'am insistent with the lsma but i really like it and i'm happy to deconstruct it like a mad pinescript user. But if you have an idea about some kind of indicator then dont hesitate to contact me, i would be happy to help you if its feasible.

My motivation for such indicator was to use back the correlation function (that i had putted aside in the ligh-lsma code) and provide a shorter code than the estimation using the line rescaling method (see : Approximating A Least Square Moving Average In Pine).

The Method

Fairly simple, lets name y our estimation, we calculate it as follow:

y = x̄ + r*o*1.7

where is the price moving average, r the correlation between the price and a line (or n) and o the standard deviation. If plotted against a classic lsma the difference would be meaningless at first glance so lets plot the absolute value between the difference of the lsma and our estimation of both period 100.



The difference is under 0.0000 on eurusd, its really low.

In general the longer the period of the estimation, the lower the difference between a normal lsma, but when using shorter period they can differ a little bit.

Why 1.7 ?

We need to multiply the standard deviation by a constant in order to match the overshoot and the rise-time of the original lsma. The constant 1.7 is one that work well but actually this constant should be dependant of the length period of the filter to make the estimation more accurate.



More About Step-Response

Most of the time when a filter have less lag, it mean that he induce overshoot in order to decrease the rise-time. Rise-time is the time the output take to match the target input, its related to the lag. Overshoot mean that the output exceed the target input, you can clearly see those concept in the image above.

Conclusion

I've showed that its possible to be even more concise about the code it take to estimate an lsma. I've also briefly explained the concept of rise-time and overshoot, concepts really important to signal processing and particularly in filter design. I'm sure that it can be even more simplified and i have some ideas for such estimate.

Thanks for reading !





コメント
HumbledByMarket
Thanks, it is simple and lucid. Just curious about why we need to find the correlation with arbitrary bar number(n)?
alexgrover
@gvpathi.social, Thanks for your support and comment, n being the bar index is also a linear function (line), therefore the correlation between the price and a linear function change the slope of the filter accordingly to price trend.
HumbledByMarket
@alexgrover, I agree to create a slope we need some linear reference. And there is a better chance to optimize it. For e.g. from last known low for a very large period (for e.g. MA 200 may ref. 10X of MA low) can give a better slope than arbitrary starting for bar number. ?
aaahopper
Thank you again, I am new to all of this and been teaching myself. Lines that you create with such simplicity helps newbies like me greatly.
I have been waiting for something better than what exists in open source and as usual, it gets created by the best "alexgrover".
Thank you so much and looking forward to your next best thing.
alexgrover
@aaahopper, Thanks a lot for your support :D I'm glad you like it.
chrysopoetics
I absolutely love you work, thank you for everything.

Not sure if it's possible, but I thought you might be the one to ask: do you know of the ARIMA and, if so, is it possible in Pine? Here's an article explaining the concept (but I'd bet you know more of it now than I'll ever come to): en.wikipedia.org/wiki/Autoregressive_integrated_moving_average

Also, on the same note, do you know if the Leavitt Market Projection is possible? This article isn't the best, but information on it isn't in abundance: academia.edu/31136930/The_Hull_Moving_Average_Evolution_into_the_Leavitt_Market_Projections_with_an_Associated_Probability

Either way, keep it up. I love your research and work.
alexgrover
@chrysopoetics, Thanks for your support. The ARIMA model is not something i have ever considered implementing on pine, i dont know if its possible but i might be wrong since i'm not someone qualified in time-series analysis, but i'm sure that in order to compute an ARIMA model you need to use the Log-Likelihood for parameters estimation and this is related to state space and other stuff fairly to advanced for me at the moment. I will look into the Leavitt Market Projection but dont put to much expectations on me ;)
chrysopoetics
@alexgrover, No problem at all man. If nothing else I'm just happy you replied. I'll pester a few more people about to too and maybe it'll be added to the list of open-source scripts available to the TradingView community.

Keep up the amazing work! I'm always excited to see what you cook up.
csr1977
you still active?
alexgrover
@csr1977, Of course :)
詳細