EQUAL VOLUME

Protrader426 · study · 168 行 · 点赞 11 · TradingView 原页

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

Pine Script

//@version=6
indicator(
     title="EQUAL VOLUME",
     shorttitle="EQUAL VOLUME",
     overlay=true
)
 
//====================================================================
// SETTINGS
//====================================================================
 
// Hidden from chart header/status line.
// Still available inside Settings → Inputs.
 
maxVolumeDifference = input.float(
     396.0,
     title="Maximum Volume Difference",
     minval=0.0,
     step=1.0,
     display=display.none
)
 
onlySameColor = input.bool(
     false,
     title="Only Mark If Both Candles Same Color",
     display=display.none
)
 
 
//====================================================================
// CANDLE 1
//====================================================================
 
candle1Volume = volume[1]
 
candle1Green =
     close[1] > open[1]
 
candle1Red =
     close[1] < open[1]
 
 
//====================================================================
// CANDLE 2
//====================================================================
 
candle2Volume = volume
 
candle2Green =
     close > open
 
candle2Red =
     close < open
 
 
//====================================================================
// VOLUME DIFFERENCE
//====================================================================
 
volumeDifference =
     math.abs(
         candle2Volume -
         candle1Volume
     )
 
 
//====================================================================
// SIMILAR VOLUME
//====================================================================
 
similarVolume =
     barstate.isconfirmed and
     not na(candle1Volume) and
     volumeDifference <= maxVolumeDifference
 
 
//====================================================================
// SAME CANDLE COLOR
//====================================================================
 
sameColor =
     (
         candle1Green and
         candle2Green
     ) or
     (
         candle1Red and
         candle2Red
     )
 
 
//====================================================================
// OPTIONAL SAME-COLOR FILTER
//====================================================================
 
colorFilter =
     not onlySameColor or
     sameColor
 
 
//====================================================================
// CANDLE 2 MUST HAVE HIGHER VOLUME
//====================================================================
 
higherVolume =
     similarVolume and
     candle2Volume > candle1Volume and
     colorFilter
 
 
//====================================================================
// SIGNALS
//====================================================================
 
bullSignal =
     higherVolume and
     candle2Green
 
bearSignal =
     higherVolume and
     candle2Red
 
 
//====================================================================
// BULL MARKER
//====================================================================
 
plotshape(
     bullSignal,
     title="Bull",
     style=shape.triangleup,
     location=location.belowbar,
     color=color.lime,
     size=size.tiny,
     force_overlay=true
)
 
 
//====================================================================
// BEAR MARKER
//====================================================================
 
plotshape(
     bearSignal,
     title="Bear",
     style=shape.triangledown,
     location=location.abovebar,
     color=color.red,
     size=size.tiny,
     force_overlay=true
)
 
 
//====================================================================
// ALERTS
//====================================================================
 
alertcondition(
     bullSignal,
     title="Bull",
     message="Bullish equal-volume signal."
)
 
alertcondition(
     bearSignal,
     title="Bear",
     message="Bearish equal-volume signal."
)

← 返回列表