RedKTrader

TA Basics: Creating a Zero Lag Moving Average using "Mirroring"

RedKTrader 업데이트됨   
we all know how moving averages suffer from lag - they have a delayed response to change in the underlying values - regardless if the underlying values are price movement or some kind of indicator formula that we are trying to smooth using a moving average.

here's a simple technique that can help minimize the lag built into the moving average - you can use this technique while building your own indicator (say modifying RSI) or simply apply it to a price chart to generate some sort of signal.

the concept here is simple and it actually depends on the fact that there's lag in moving averages - however, it was also observed that this lag is less when we use a weighted moving average (WMA) vs a simple moving average (SMA). (for a quick intro / refresher on Moving Averages, there's an awesome write-up here on TradingView that you can easily find with a quick search)

so the idea is to take the delta between these 2 lines (which is mathematically equal to SMA - WMA) , and "mirror it" on the other side of the WMA to produce the new Zero-lag line (let's call it ZLMA. sounds easy, right?

now, expanding on this concept just one step further, while we're at it, why don't we take, say, 1.5 times that delta, or 2 times and mirror it - wouldn't that produce an even less lagging line that moves in lockstep with the price (or whatever data series)? -- yes it would, we added that in the sample code here, but be careful with that, if you increase that factor too much, the ZLMA starts behaving "wildly" and loses relevance to the underlying data. so keep it from 1 to 2.5 -- an ideal value would be around the 1.5 (and of course, for the mathematically gifted, as you expect, you make that factor -1.0, and you end up with a ZLMA that is exactly same as the SMA :) ..

if you don't use a ZLMA factor "f" -- then the simple equation is ZLMA = 2W - S, which you can simply add to any indicator to smoother it without introducing a lot of lag -- however, i still suggest you keep that smoothing to a small value between 3 and 6 -- to stay relevant to underlying data


hope you like this and find it useful. let me know -- i'd like to know if there's interest in these types of concepts and there's more to come.

pls stay safe,
릴리즈 노트:
typo fixed in code comments
오픈 소스 스크립트

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

면책사항

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

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