alexgrover

ZLMA - Low-Lag Moving Average Based On An Alternative SMA Design

There can be many ways to make a simple moving average, you can either sum the current and the n-1 previous data points and divide the result by n, or you can do it more efficiently by first taking the cumulative sum of your data points, and subtracting the current cumulative sum result with the cumulative sum results n bars ago, then divide the result by n. This can be described by the following formulas:

a(t) = a(t-1) + price(t)
b(t) = (a(t) - a(t-n))/n


This method is the one used in order to allow the user to use a series as SMA period, more info here:


Today we use this design in order to provide a pretty efficient low-lag moving average where the amount of lag of the moving average can be increased/decreased by the user.

THE INDICATOR

length control the period of the moving average, with larger value of length returning larger filtering amount. The lag setting in the other hand control the amount of lag of the moving average, with larger value of lag returning a moving average with less lag. The lag setting can't be lower than 1 or greater than 2, but values lower than 1 and greater than 0 would just return a moving average with larger filtering amount while values greater than 2 would create crazy wild overshoots.


In blue lag = 1.8, in red lag = 1.4, when lag = 1 the moving average is equal to a simple moving average of period length. Remember that larger values of lag will return greater over/undershoots.


Approximate amplitude response of the moving average, like all low-lag moving averages you can see frequencies amplified (the ones on the left greater than 1).

SUMMARY

We proposed a low-lag moving average based on the cumulative/change SMA design where the lag of the moving average can be controlled by the user. There are tons of low-lag moving averages already, and they don't necessarily provide different results from each others, however this one is still relatively interesting as you can switch from a simple MA from a low-lagging one, other indicators are ready using this design and will be posted soon.

Check out the indicators we are making at luxalgo: www.tradingview.com/u/LuxAlgo/
สคริปต์โอเพนซอร์ซ

ด้วยจิตวิญญาณของ TradingView อย่างแท้จริง ผู้เขียนสคริปต์นี้ได้เผยแพร่เป็นโอเพนซอร์ส เพื่อให้ผู้ค้าสามารถเข้าใจและตรวจสอบได้ ไชโยให้กับผู้เขียน! คุณสามารถใช้ได้ฟรี แต่การใช้รหัสนี้ซ้ำในสิ่งพิมพ์อยู่ภายใต้กฎระเบียบการใช้งาน คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ เงื่อนไขการใช้บริการ

ต้องการที่จะใช้สคริปต์นี้บนชาร์ตใช่ไหม?