OPEN-SOURCE SCRIPT

Prometheus Stochastic

The Stochastic indicator is a popular indicator developed in the 1950s. It is designed to identify overbought and oversold scenarios on different assets. A value above 80 is considered overbought and a value below 20 is considered oversold.

The formula is as follows:

%k = ((Close - Low_i) / (High_i / Low_i)) * 100

Low_i and High_i represent the lowest low and highest high of the selected period.

The Prometheus version takes a slightly different approach:

%k = ((High - Lowest_Close_i) / (High_i / Low_i)) * 100

Using the Current High minus the Lowest Close provides us with a more robust range that can be slightly more sensitive to moves and provide a different perspective.

Code:



This is the function that returns our Stochastic indicator.

What period do we use for the calculation? Let Prometheus handle that, we utilize a Sum of Squared Error calculation to find what lookback values can be most useful for a trader. How we do it is we calculate a Simple Moving Average or SMA and the indicator using a lot of different bars back values. Then if there is an event, characterized by the indicator crossing above 80 or below 20, we subtract the close by the SMA and square it. If there is no event we return a big value, we want the error to be as small as possible. Because we loop over every value for bars back, we get the value with the smallest error. We also do this for the smoothing values.



This is the section where the best lookback values are calculated.

We provide the option to use this self optimizer or to use your own lookback values.

snapshot

Here is an example on the daily SPY chart. The top Stochastic is the value with the SSE calculation, the bottom is with a fixed 14, 1, 3 input values. We see in the candles with boxes where some potential differences and trades may be.

snapshot

This is another comparison of the SSE functionality and the fixed lookbacks on the PLTR 1 day chart.

snapshot

Differences may be more apparent on lower time frame charts.

We encourage traders to not follow indicators blindly, none are 100% accurate. SSE does not guarantee that the values generated will be the best for a given moment in time. Please comment on any desired updates, all criticism is welcome!
Bands and ChannelsChart patternsCycles

Script open-source

Dans le plus pur esprit TradingView, l'auteur de ce script l'a publié en open-source, afin que les traders puissent le comprendre et le vérifier. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais la réutilisation de ce code dans une publication est régie par nos Règles. Vous pouvez le mettre en favori pour l'utiliser sur un graphique.

Vous voulez utiliser ce script sur un graphique ?

Clause de non-responsabilité