本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
indicator("VOLUME RECOVERY", shorttitle="VOL RECOVERY", overlay=true)
//====================================================
// SETTINGS
//====================================================
requireSameColor = input.bool(
false,
"Require Candle 1 & Candle 4 Same Color",
display=display.none
)
//====================================================
// CANDLE MAP
//
// Candle 1 = [3]
// Candle 2 = [2]
// Candle 3 = [1]
// Candle 4 = [0]
//====================================================
//====================================================
// VOLUME CONDITIONS
//====================================================
// Candle 2 volume must be lower than Candle 1
candle2LowerThan1 =
volume[2] < volume[3]
// Candle 3 volume must be lower than Candle 1
candle3LowerThan1 =
volume[1] < volume[3]
// Candle 4 volume must be higher than Candle 3
candle4HigherThan3 =
volume > volume[1]
// Candle 4 volume must be higher than Candle 1
candle4HigherThan1 =
volume > volume[3]
//====================================================
// CANDLE COLORS
//====================================================
// Candle 1
candle1Green =
close[3] > open[3]
candle1Red =
close[3] < open[3]
// Candle 4
candle4Green =
close > open
candle4Red =
close < open
//====================================================
// SAME COLOR CONDITION
//
// If setting is OFF:
// Candle colors do not matter.
//
// If setting is ON:
// Green C1 requires Green C4.
// Red C1 requires Red C4.
//====================================================
sameColor =
(candle1Green and candle4Green) or
(candle1Red and candle4Red)
colorCondition =
not requireSameColor or sameColor
//====================================================
// COMPLETE VOLUME RECOVERY PATTERN
//====================================================
volumeRecoveryPattern =
candle2LowerThan1 and
candle3LowerThan1 and
candle4HigherThan3 and
candle4HigherThan1 and
colorCondition
//====================================================
// CONFIRMED SIGNALS
//
// Signal confirms when Candle 4 closes.
//====================================================
greenSignal =
volumeRecoveryPattern and
candle1Green and
barstate.isconfirmed
redSignal =
volumeRecoveryPattern and
candle1Red and
barstate.isconfirmed
//====================================================
// ARROWS ON CANDLE 1
//
// Green Candle 1 = arrow below.
//
// Red Candle 1 = arrow above.
//
// offset = -3 because detection completes
// when Candle 4 closes.
//====================================================
plotshape(
greenSignal,
title="Bullish Volume Recovery",
style=shape.triangleup,
location=location.belowbar,
color=color.lime,
size=size.tiny,
offset=-3
)
plotshape(
redSignal,
title="Bearish Volume Recovery",
style=shape.triangledown,
location=location.abovebar,
color=color.red,
size=size.tiny,
offset=-3
)
//====================================================
// ALERTS
//====================================================
alertcondition(
greenSignal,
title="Bullish Volume Recovery",
message="Bullish Volume Recovery pattern detected."
)
alertcondition(
redSignal,
title="Bearish Volume Recovery",
message="Bearish Volume Recovery pattern detected."
)