RedKTrader

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

RedKTrader Cập nhật   
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,
Phát hành các Ghi chú:
typo fixed in code comments
Mã nguồn mở

Với tinh thần TradingView, tác giả của tập lệnh này đã xuất bản nó dưới dạng mã nguồn mở, vì vậy các nhà giao dịch có thể hiểu và xác minh nó. Chúc mừng tác giả! Bạn có thể sử dụng mã này miễn phí, nhưng việc sử dụng lại mã này trong một ấn phẩm chịu sự điều chỉnh của Nội quy nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?