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.

ảnh chụp nhanh

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.

ảnh chụp nhanh

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

ảnh chụp nhanh

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

Mã nguồn mở

Theo tinh thần TradingView thực sự, tác giả của tập lệnh này đã xuất bản dưới dạng nguồn mở để các nhà giao dịch có thể hiểu và xác minh. Chúc mừng tác giả! Bạn có thể sử dụng miễn phí. Tuy nhiên, bạn cần sử dụng lại mã này theo Quy tắc nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?


Ngoài ra, trên:

Thông báo miễn trừ trách nhiệm