本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=4
//@author=© Alexter6277
study(title="Price Density (Market Noise) by Alejandro P", shorttitle="Price Density - AP", overlay=false, precision=2, resolution="")
PDLength = input(14, minval=1, title="Price Density Length")
UseRelative = input(false,"Use Relative Price Density Calculations", tooltip="By selecting to use Relaive Calcualtions the script will take the values of the indicator and stack them in a percentile rank. This allows to show the reltive noise vs the past X candles instead of absolute noise.",group="Relative / Percentile Ranked")
EvalPeriod = input(200, minval=1, title="# of Bars to Calculate Price Density Percent",group="Relative / Percentile Ranked")
ExtremeLevel = input(95.0, minval=0, maxval=100, title="Price Density % Extreme Level",group="Relative / Percentile Ranked")
HighLevel = input(50.0, minval=0, maxval=100, title="Price Density % High Level",group="Relative / Percentile Ranked")
LowLevel = input(25.0, minval=0, maxval=100, title="Price Density % Low Level",group="Relative / Percentile Ranked")
// Relative ATR Percent Function
PriceDensity (Length) =>
PD = sum(atr(1),Length)/(highest(high,Length)-lowest(low,Length))
PD
PDPercent (PDLen,RelLen) =>
PD = PriceDensity (PDLen)
PDP = percentrank(PD,RelLen)
PDP
RelPD = PDPercent(PDLength,EvalPeriod)
clr = RelPD >= ExtremeLevel ? color.purple : RelPD >= HighLevel ? color.green : RelPD >= LowLevel ? color.blue : color.red
plot(UseRelative?RelPD:PriceDensity (PDLength), "Price Density",style= UseRelative?plot.style_columns:plot.style_line ,color = UseRelative?clr:color.blue)