Lemrin

Awesome Oscillator with AntiStep Correction

Lemrin 已更新   
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.
發布通知:
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!
發布通知:
Came up with an easier way to generalize step threshold for any tickerid or resolution.
Removed stochastic method.
開源腳本

本著真正的TradingView精神,該腳本的作者將其開源發布,以便交易者可以理解和驗證它。為作者喝彩吧!您可以免費使用它,但在出版物中重複使用此代碼受網站規則的約束。 您可以收藏它以在圖表上使用。

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。

想在圖表上使用此腳本?