This indicator is based on the Dinapoli preferred detrended price oscillator calculation (ddpo v4.lua):
viewtopic.php?f=27&t=67266&start=20
The indicator is designed to display as a price channel/band on a price chart (see attachment). The channel indicates expected levels of market overbought/oversold based on historical oscillator extreme values. The indicator estimates levels of OB/OS for the next time period. In this way it is a leading indicator to indicate one period ahead, the price levels at which the market will be at extreme levels of OB/OS, based on historical values.
There are two channels in the display (an inner and an outer channel) consisting of the following 4 lines:
1) Max.OB - maximum overbought line based on maximum.overbought (positive) DDPO displacement within lookback period
2) %Avg.OB - user defined (%avg) percentage of average.overbought (based on average value of defined number of max peaks in the lookback period)
3) %Avg.OS - user defined (%avg) percentage of average.oversold (based on average value of defined number of min throughs in the lookback period)
4) Max.OS - maximum oversold line based on maximum.oversold (negative) DDPO displacement within lookback period
--> Price Source: Tick (default closing price, with option to also use high and low)
--> User-Input Parameters:
1) n.period - for calculation of "n.period simple moving average" in DDPO calculation - default value "7"
2) SF - Scaling factor - default value "1"
2) %avg - scaling factor applied to the calculated Avg.OB (average overbought) and Avg.OS (average oversold) values. Default value "90%"
3) Lookback period - default "100" bars
4) Max.peaks - number of the highest peaks within lookback period, for average overbought or Avg.OB calculation - default "3"
5) Min.troughs - number of the lowest troughs within lookback period, for average oversold or Avg.OS calculation - default "3"
6) Colour, style and thickness selection option for all 4 channel lines noted above
7) Option to manually input values of Max.OB, %Avg.OB, %Avg.OS and Min.OS for OBOS line calculations.
--> Calculation DDPO (as per "ddpo v4.lua"):
DDPO(time)=SF*{[Price(time)]-[n.period.SMA(time)]}
Where:
1) DDPO(time) is the current time-period DDPO oscillator value
2) SF is the scaling factor for the DDPO calculation
2) Price(time) is the current time-period high, low or closing price of the current bar depending on chosen price source
3) n.period.SMA(time) is the current time-period's "n.period simple moving average" value.
*****************************************************************
--> OB/OS price band calculation:
There are 4 lines - 2 off overbought lines and 2 off oversold lines
--> Max.OB_line calculation
Price.Max.OB_line(time+1)={[(OB.DDPO.max.disp)/(SF)]*[(n.period)/(n.period-1)]}+[(n-1).period.SMA(time)]
--> %Avg.OB_line calculation
Price.%Avg.OB_line(time+1)={[((Avg.OB)*(%avg))/(SF)]*[(n.period)/(n.period-1)]}+[(n-1).period.SMA(time)]
--> %Avg.OS_line calculation
Price.Avg.OS_line(time+1)={[((Avg.OS)*(%avg))/(SF)]*[(n.period)/(n.period-1)]}+[(n-1).period.SMA(time)]
--> Min.OS_line calculation
Price.Min.OS_line(time+1)={[(OS.DDPO.min.disp)/(SF)]*[(n.period)/(n.period-1)]}+[(n-1).period.SMA(time)]
*******************************************************************
Note:
1) "Price.xx.OB_line(time+1)" and "Price.xx.OS_line(time+1)" are the Max.OB, %Avg.OB, %Avg.OS and Min.OS "price calculations" for the next time-period. These calculated price levels form the channel lines.
2) "OB.DDPO.max.disp" is the maximum (positive) displacement or highest peak value of the DDPO calculation within the lookback period.
3) "OS.DDPO.min.disp" is the minimum (negative) displacement or lowest trough value of the DDPO within the lookback period.
4) "n.period" is the chosen period for the simple moving average calculation in the original DDPO calculation. This is part of the original user input parameters. So for example if "n.period"=7 then "(n.period-1)"=6 in the above 4 equations.
5) "SF" is the scaling factor used for the DDPO calculation.
6) (n-1).period.SMA(time) is the current time-period's "(n-1).period.SMA". So for example if "n.period"=7 then the "(n-1).period.SMA" is the "6-period.SMA" or simple moving average of the price, inclusive of the current time-period's (high, low or close) price.
7) "%Avg.OB" is the calculated percentage of average overbought value (average of the highest of the "Max.peaks" displacements within the lookback period in the DDPO calculation).
8) "%Avg.OS" is the calculated percentage of average oversold value (average of the lowest of the "Min.troughs" displacement within the lookback period in the DDPO calculation).
9) Option required for manual override to input user defined values of Max.OB, Avg.OB, Avg.OS and Min.OS - to test OBOS bands for what-if scenarios. This is particularly helpful when markets are spiking. Inputting specific historical value(s) of DDPO will produce channel lines which tend to provide OBOS guidance levels for spike moves.
Regards,
Fortcentral