duongphuoc - Volume Spike Detector

thieunamgiang92 · study · 124 行 · 点赞 10 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

//@version=6
indicator(
     title = "duongphuoc - Volume Spike Detector",
     shorttitle = "duongphuoc - Volume Spike",
     overlay = false
)
 
//====================================================
// VOLUME DETECTION
//====================================================
 
highVolumePeriod = input.int(
     20,
     title = "High Volume Period",
     minval = 2,
     group = "Volume Detection"
)
 
extremeVolumePeriod = input.int(
     200,
     title = "Extreme Volume Period",
     minval = 10,
     group = "Volume Detection"
)
 
showHighVolume = input.bool(
     true,
     title = "Show High Volume",
     group = "Volume Detection"
)
 
showExtremeVolume = input.bool(
     true,
     title = "Show Extreme Volume",
     group = "Volume Detection"
)
 
//====================================================
// COLORS
//====================================================
 
normalUpColor = input.color(
     #b2b5be,
     title = "Normal Volume - Up Candle",
     group = "Colors"
)
 
normalDownColor = input.color(
     #9598a1,
     title = "Normal Volume - Down Candle",
     group = "Colors"
)
 
highVolumeColor = input.color(
     #424CD8,
     title = "High Volume",
     group = "Colors"
)
 
extremeVolumeColor = input.color(
     #9c27b0,
     title = "Extreme Volume",
     group = "Colors"
)
 
//====================================================
// VOLUME MOVING AVERAGE
//====================================================
 
showMA = input.bool(
     false,
     title = "Show Volume Moving Average",
     group = "Volume Moving Average"
)
 
volumeMAPeriod = input.int(
     20,
     title = "Volume MA Period",
     minval = 1,
     group = "Volume Moving Average"
)
 
//====================================================
// CALCULATIONS
//====================================================
 
// Compare the current volume with previous candles only.
highestHighVolume = ta.highest(volume[1], highVolumePeriod)
highestExtremeVolume = ta.highest(volume[1], extremeVolumePeriod)
 
isHighVolume = volume > highestHighVolume
isExtremeVolume = volume > highestExtremeVolume
 
// Normal volume keeps candle direction information.
normalVolumeColor = close >= open ? normalUpColor : normalDownColor
 
// Priority:
// Extreme -> High -> Normal
volumeColor =
     showExtremeVolume and isExtremeVolume ? extremeVolumeColor :
     showHighVolume and isHighVolume ? highVolumeColor :
     normalVolumeColor
 
// Wilder's Moving Average
volumeMA = ta.rma(volume, volumeMAPeriod)
 
//====================================================
// PLOTS
//====================================================
 
plot(
     volume,
     title = "Volume",
     style = plot.style_columns,
     color = volumeColor,
     linewidth = 3
)
 
plot(
     showMA ? volumeMA : na,
     title = "Volume MA",
     color = color.green,
     linewidth = 3
)

← 返回列表