Awesome Oscillator with AntiStep Correction

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.
הסר מסקריפטים מועדפים הוסף לסקריפטים מועדפים


thank you i will check it out
בית סורק מניות סורק מט"ח סורק מטבעות-קריפטו יומן כלכלי איך זה עובד‏ תכונות גרף מחירון הפנה חבר כללי הבית מרכז תמיכה כלים לאתרים וברוקרים יישומונים פתרונות גרפיים ספריית גרפים קלי משקל בלוג וחדשות טוויטר‏
פרופיל הגדרות פרופיל חשבון וחיוב חברים מופנים מטבעות לשוניות התמיכה שלי מרכז תמיכה רעיונות שפורסמו עוקבים עוקב הודעות פרטיות צ'אט התנתק