我对以下代码有疑问,希望得到帮助:
//@version=4
study(title="Example", shorttitle="Ex", overlay=true)
//Average volume, 45 periods
sum = volume[1]
for i = 1 to 45
sum := sum + volume[i]
volumeMA = sum / 45
VolumeRatio = volume/volumeMA
//Calculate Scores - Volume
VolumeScore = 0
if VolumeRatio > 1 and VolumeRatio < 1.5
VolumeScore := 1
if VolumeRatio >= 1.5 and VolumeRatio < 2
VolumeScore := 2
if VolumeRatio >= 2
VolumeScore := 3
//Calculate Scores - HH
HH_Bull = 0
if high >= highest(high, 5)
HH_Bull := 1
if high >= highest(high, 8)
HH_Bull := 2
if high >= highest(high, 14)
HH_Bull := 3
HH_Bear = 0
if low >= lowest(low, 3)
HH_Bear := 1
if low >= lowest(low, 6)
HH_Bear := 2
if low >= lowest(low, 10)
HH_Bear := 3
//Caclulate Total Score
Candle_Bull_Score = VolumeScore + HH_Bull
Candle_Bear_Score = VolumeScore + HH_Bear
BullCandle = close > close[1] and open-low >= 10
BearCandle = close < close[1] and high-open >= 10
plotshape(BullCandle, title= "Bull", location=location.belowbar, color=color.green, transp=0, style=shape.triangleup, text="BUY-" & Candle_Bull_Score)
plotshape(BearCandle, title= "Bear", location=location.belowbar, color=color.red, transp=0, style=shape.triangledown, text="SELL-" & Candle_Bear_Score)
请注意,我是故意合并text="Buy" & Candle_Bull_Score的,我知道仅仅解释我正在尝试做的事情是行不通的。我想绘制“BullCandle”变量,但通过使用 Candle_Bull_Score 和 Candle_Bear_Score 来指示信号强度。
