OPEN-SOURCE SCRIPT

Prometheus IQR bands

This indicator is a tool that uses market data to plot bands along with a price chart.

This tool uses interquartile range (IQR) instead of Standard Deviation (STD) because market returns are not normally distributed. There is also no way to tell if the pocket of the market you are looking at is normally distributed. So using methods that work better with non-normal data minimizes risk more than using a different process.

Calculation

Code for helper functions:


Percentile Calculation (percentile function):
Calculates the percentile value of an array (arr) at a given percentile (p).
Uses linear interpolation to find the exact percentile value in a sorted array.

Manual IQR Calculation (manual_iqr function):
Converts the input data into an array (data_arr) and sorts it.
Computes the lower and upper quartiles (Q1 and Q3) using the specified percentiles (lower_percentile and upper_percentile).
Computes the Interquartile Range (IQR) as IQR = Q3 - Q1.
Returns the computed IQR.

IQRB Function Calculation (IQRB function):
Converts the sensitivity percentage (sens) into decimal values (sens_l for lower percentile and sens_h for upper percentile).
Calls manual_iqr with the closing prices (close) and the lower and upper percentiles.
Calculates the Simple Moving Average (SMA) of the closing prices (close) over a specified period (lkb_).
Computes the upper and lower bands of the IQR using the SMA and the calculated IQR (val).
Returns an array [upper, lower, sma] containing the upper band, lower band, and SMA values.

After the IQR is calculated at the specified sensitivity it is added to and subtracted from a SMA of the specified period.

This provides us with bands of the IQR sensitivity we want.

Trade Examples

https://www.tradingview.com/x/x3wHp9Xm/

Step 1: Price quickly and strongly breaks below the bottom band and continues there for some bars.

Step 2: Price re-enters the bottom band and has a strong reversal.

https://www.tradingview.com/x/leNP3ox3/

Step 1: Price strongly breaks above the top band and continues higher.

Step 2: Price breaks below the top band and reverses to the downside.

Step 3: Price breaks below the bottom band after our previous reversal.

Step 4: Price regains that bottom band and reverses to the upside.

Step 5: Price continues moving higher and does not break above the top band or reverse.

https://www.tradingview.com/x/NmZzAXvv/

Step 1: Price strongly breaks above the top band and continues higher.

Step 2: Price breaks below the top band and reverses to the downside.

Step 3: Price breaks below the bottom band after our previous reversal.

Step 4: Price regains that bottom band and reverses to the upside.

Step 5: Price strongly breaks above the top band after the previous reversal.

Step 6: Price breaks below the top band and reverses down.

Step 7: Price strongly breaks above the top band and continues moving higher.

Step 8: Price breaks below the top band and reverses down.

Step 9: Price strongly breaks above the top band and continues moving higher.

Step 10: Price breaks below the top band and reverses down.

https://www.tradingview.com/x/UIIb1KyL/

Step 1: Price breaks above the top band.

Step 2: Price drops below the top band and chops slightly, without a large reversal from that break.

Step 3: Price breaks below the bottom band.

Step 4: Price re-enters the bottom band and just chops, no large reversal.

Step 5: Price breaks below the bottom band.

Step 6: Price retakes the bottom band and strongly reverses.

This tool can be uses to spot reversals and see when trends may continue as the stay inside the bands. No indicator is 100% accurate, we encourage traders to not follow them blindly and use them as tools.
Chart patternsCycles

Скрипт с открытым кодом

В истинном духе TradingView автор этого скрипта опубликовал его с открытым исходным кодом, чтобы трейдеры могли понять, как он работает, и проверить на практике. Вы можете воспользоваться им бесплатно, но повторное использование этого кода в публикации регулируется Правилами поведения. Вы можете добавить этот скрипт в избранное и использовать его на графике.

Хотите использовать этот скрипт на графике?


Мои профили:

Отказ от ответственности