TradingView
alexgrover
4 oct. 2019 17:51

%G Oscillator 

Intel CorporationNASDAQ

Description

Introduction

Rescaling often involve bringing a series of values in a certain range, there have been many rescaling methods proposed in technical analysis such as the stochastic oscillator, relative strength index or the William %R to name a few. Rescaling the price allow the user to see when the security is overbought or oversold, in the case of the stochastic oscillator it can also determine the price position relative to the highest and lowest price over a user defined period window.

Computing highest and lowest over a certain period window involve calculating what is called a rolling maximum/minimum, those calculations have tried to be efficient but they can still remain relatively complex. This is why i propose a similar rescaling indicator that don't use rolling maximum/minimum for its calculation, the indicator can be interpreted like the stochastic oscillator since they are similar.

The Indicator

The indicator is based on the current price position relative to past observations, for example, if the indicator is equal to 80, this mean that the current price is greater than 80% of the k past observations, where k = 1, 2, 3...length.

The indicator offer many benefits such as a custom rescaling range, unlike the stochastic oscillator this step is directly integrated in the core calculations of the indicator, this can be done by changing the code in line 7 :

a = src > src ? Max : Min

where Max should be the maximum value of the indicator and Min the minimum value, therefore the indicator would lay in a range of (Max,Min).



here the indicator is in a range of (5,2), this mean that :

a = src > src ? 5 : 2

Conclusion

I proposed an alternative to the stochastic oscillator. Both indicators return similar results, advantages of the proposed indicators are its simple calculation and its ability to return custom ranges. I hope it find its use in the community.

Thanks for reading !
Commentaires
Old_tom
Thanks again Alex

The problem of subjective selection of src prompted not entirely unrelated thoughts on some "ancient" history.

H. Ford of California came out with an "Umbrella Stop" calculation many years ago involving ATR.
However LeBeau also developed an "Umbrella Stop" and holds copyright to the name.
Ford's solution seems to have been lost.
While both solutions provided similar looking curves, IMHO Ford's system was vastly superior with superb response to character changes in each specific data series.
Unfortunately, Ford's calculations utilized Excel functions abandoned after the 2001 version of Excel. (I may have archived the code - but after so many years, where?)
The stop was x times average ATR looking back n days.
With time, both x and n reduced in size. The reduction factors themselves lessened with time, quickly at first, and more slowly with time, and were determined from the data series itself.
Matrices required to calculate appropriate factors were rather large for Windows 98. (Did I mention ancient history?)
slowcoconut
@Old_tom, incredible history lesson, thanks for sharing. reminds me that the Mac im using now is a supercomputer by the standards of another time
levith
The results are similar percentrank(src, length) ???
alexgrover
@levith, Indeed
alexgrover
@levith, In fact they should be the same, thx for pointing it out, i will think about asking an admin to take the script down.
levith
@alexgrover, I think it is quite good. If it weren't for your script, I wouldn't understand this function.
scamArtist
amazing toy, very pythonic way btw , just what i like to see :D

thank you man, u are great as usual
:)
aaahopper
Excellent work
alexgrover
@aaahopper, Hey, thanks for the support :D
Junglistt
Another great post - I'm learning a lot from you. Thanks!
Plus