OPEN-SOURCE SCRIPT

Bilateral Stochastic Oscillator - For The Sake Of Efficiency

Introduction

The stochastic oscillator is a feature scaling method commonly used in technical analysis, this method is the same as the running min-max normalization method except that the stochastic oscillator is in a range of (0,100) while min-max normalization is in a range of (0,1). The stochastic oscillator in itself is efficient since it tell's us when the price reached its highest/lowest or crossed this average, however there could be ways to further develop the stochastic oscillator, this is why i propose this new indicator that aim to show all the information a classical stochastic oscillator would give with some additional features.

Min-Max Derivation

The min-max normalization of the price is calculated as follow : (price - min)/(max - min), this calculation is efficient but there is alternates forms such as :

price - (max - min) - min/(max - min)

This alternate form is the one i chosen to make the indicator except that both range (max - min) are smoothed with a simple moving average, there are also additional modifications that you can see on the code.

The Indicator

The indicator return two main lines, in blue the bull line who show the buying force and in red the bear line who show the selling force.

An orange line show the signal line who represent the moving average of the max(bull,bear), this line aim to show possible exit/reversals points for the current trend.

Length control the highest/lowest period as well as the smoothing amount, signal length control the moving average period of the signal line, the pre-filtering setting indicate which smoothing method will be used to smooth the input source before applying normalization.

imagen

The default pre-filtering method is the sma.

imagen

The ema method is slightly faster as you can see above.

imagen

The triangular moving average is the moving average of another moving average, the impulse response of this filter is a triangular function hence its name. This moving average is really smooth.

imagen

The lsma or least squares moving average is the fastest moving average used in this indicator, this filter try to best fit a linear function to the data in a certain window by using the least squares method.

No filtering will use the source price without prior smoothing for the indicator calculation.

imagen

Relationship With The Stochastic Oscillator

The crosses between the bull and bear line mean that the stochastic oscillator crossed the 50 level. When the Bull line is equal to 0 this mean that the stochastic oscillator is equal to 0 while a bear line equal to 0 mean a stochastic oscillator equal to 100.

imagen

The indicator and below a stochastic oscillator of both period 100

Using Levels

Unlike a stochastic oscillator who would clip at the 0 and 100 level the proposed indicator is not heavily constrained in a range like the stochastic oscillator, this mean that you can apply levels to trigger signals

Possible levels could be 1,2,3... even if the indicator rarely go over 3.

Its then possible to create strategies using such levels as support or resistance one.

Conclusion

I've showed a modified stochastic oscillator who aim to show additional information to the user while keeping all the information a classical stochastic oscillator would give. The proposed indicator is no longer constrained in an hard range and posses more liberty to exploit its scale which in return allow to create strategies based on levels.

For pinescript users what you can learn from this is that alternates forms of specific formulas can be extremely interesting to modify, changes can be really surprising so if you are feeling stuck, modifying alternates forms of know indicators can give great results, use tools such as sympy gamma to get alternates forms of formulas.

Thanks for reading !

If you are looking for something or just want to say thanks try to pm me :)

Bearish PatternsBullish PatternsMoving AveragesOscillatorsscaledsmoothTrend Analysis

Script de código abierto

Siguiendo fielmente el espíritu de TradingView, el autor de este script lo ha publicado en código abierto, permitiendo que otros traders puedan entenderlo y verificarlo. ¡Olé por el autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la reutilización de este código en la publicación se rige por las Normas internas. Puede añadir este script a sus favoritos y usarlo en un gráfico.

¿Quiere utilizar este script en un gráfico?


Check out the indicators we are making at luxalgo: tradingview.com/u/LuxAlgo/
También en:

Exención de responsabilidad