Lemrin

Awesome Oscillator with AntiStep Correction

Lemrin Cập nhật   
Here is the well-known Awesome Oscillator (AO), which I use to present the real purpose of this post: a function that provides step correction for simple moving averages (SMAs).

We all know that any indicator based on moving averages lags real-time movement. Normally this is fine, but just after large ("step") changes in level, the pre-step values that are still within the SMA window cause the result to falsely reflect continued movement, even when real-time values remain flat.

To counter this, when a step change of a configurable size is detected, I temporarily shrink the SMA window size to include only those values occurring since the step change, and then allow the size to increase to normal length as we move away from the step change. This is accomplished within the antistep_sma() function.

Note that this will cause SMAs of different lengths (e.g. those used in the AO) to be temporarily equal, until the shorter of the two reaches its normal size and begins to leave the longer one behind again. You can see this above, where the AO, which is the difference of two SMAs, goes to 0 immediately after a sufficiently large step change--configured to 0.5% in this case.
Phát hành các Ghi chú:
I have generalized all flavors of exponential moving average (you may create your own alpha using my function) and used it to implement anti-step versions of the TradingView EMA and RMA, in addition to the SMA from version 1.

Also, following a very good idea from Tracks, I added the option to base step detection on stochastic level (change the value from ~1% up to perhaps 50% for decent results). This still needs some work, though, so I am leaving that option disabled by default. Please feel free to toy with it, and let me know if you have any suggestions!
Phát hành các Ghi chú:
Came up with an easier way to generalize step threshold for any tickerid or resolution.
Removed stochastic method.
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 đồ?