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 ) 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 ( ) vs a ( ). (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 - ) , and "mirror it" on the other side of the 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 :) ..
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,