RedKTrader

TA Basics: Evolving our Zero Lag Moving Average.

In the previous Zero-Lag MA post, we introduced the "mirroring" technique and the associated calculation.

In this post, we will see how we can use the same technique, with a slight variation, to evolve our zero lag moving average line, add more "smoothness" and still maintaining the low lag and fast response to data series changes.

to use the "mirroring" technique, we need to use 2 MA lines with varying speeds - this is essential to produce the delta between the lines, that can then be mirrored around the fast line to produce the final line. in the first example, we used a Simple MA (slow) and a Weighted MA (fast) of the same length to achieve that.

here we introduce a different way of doing that. we will use a Weighted MA of the length (slow) and another Weighted MA of half the length (fast) -- the difference in "speed" between these 2 lines should produce the delta we need, we mirror it around the fast line, and we get our desired Zero-lag line. Check!

then while we're at it, why don't we introduce an additional smoothing just to ensure the new line is not too "broken" and jumpy .. and flows smoothly across the data series. but what length should we use for smoothing?
smoothing length should be enough to make an actual smoothing effect, but not too large else it will introduce lagging on its own. how about 3? usually 3 or 4 are good values for smoothing. A brilliant idea here is to use a number related to the same input length of the original line, which can always be relatively small -- the square root (integer portion) of that original length - and in that case, the user will only need to enter 1 input for the moving average, just the length - everything will be calculated from there. Check again!

I commented the code if you like to follow the simplified build-up of the formula, now that the concept is explained.
the (more complex-looking) 1-line, condensed form of that formula to use is (alert: watch out for the ()'s -- they're tricky :) )

----------------------------------------------
ZLMA_Line = wma((2*wma(close,int(length/2)) - wma(close,length)), int(sqrt(length)))
------------------------------------------

the one thing i do not like about this technique, is that we introduce the use of the half length MA. i do not like to build indicators that make decisions like this on behalf of the trader - the trader wants to analyze the data for a specific length, and we should continue to stick to that consistently across the moving average (or whatever indicator) calculation. I would always be caution about "hardcoding" some optional values (in this case 0.5 * length) within the indicator itself - others may not mind that.

Now to a nice surprise for the patient folks who got so far in this post - Congratulations, we have just discovered the concept and the formula behind the famous Hull Moving Average .. the big thing here is, we just had the opportunity to learn how to create the whole thing ourselves from the ground up step by step, and had fun doing it (I hope!)

-- these posts are meant to provide those who are new to the world of technical analysis and want to learn how and why to build their own technical indicators. i hope some of you find them useful and interesting, and i wish you the best of luck.

오픈 소스 스크립트

이 스크립트의 오써는 참된 트레이딩뷰의 스피릿으로 이 스크립트를 오픈소스로 퍼블리쉬하여 트레이더들로 하여금 이해 및 검증할 수 있도록 하였습니다. 오써를 응원합니다! 스크립트를 무료로 쓸 수 있지만, 다른 퍼블리케이션에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?