如何在第一根蜡烛的低位高于布尔带下线时买入,在第一根蜡烛线的高位低于布尔带上线时卖出

时间:2021-05-26 22:58:53

标签: pine-script

我想知道如何打开和关闭布林带突破或下跌的交易。例如,如所附图片所示,每个绿色柱线的高点都在上布尔带上方,我想在高点低于上布尔带的第一个柱上卖出。谢谢点击链接查看图片。 (使用 Heiken Ashi 蜡烛,我知道利弊)

IMAGE:在第一根蜡烛线低于布尔带下线时买入,在第一根蜡烛线以高线低于布尔带线时卖出:
IMAGE: Buy on the first candle with a low above the lower boll band, sell on first candle with a high below upper boll band

1 个答案:

答案 0 :(得分:0)

在低于下线的第一个低点买入,在低于上线的第一个高点卖出

//@version=4
study(shorttitle="BB", title="Bollinger Bands", overlay=true, resolution="")
length = input(20, minval=1)
src = input(close, title="Source")
mult = input(2.0, minval=0.001, maxval=50, title="StdDev")
basis = sma(src, length)
dev = mult * stdev(src, length)
upper = basis + dev
lower = basis - dev
offset = input(0, "Offset", type = input.integer, minval = -500, maxval = 500)
plot(basis, "Basis", color=#872323, offset = offset)
p1 = plot(upper, "Upper", color=color.teal, offset = offset)
p2 = plot(lower, "Lower", color=color.teal, offset = offset)
fill(p1, p2, title = "Background", color=#198787, transp=95)

//
buy = low > lower and low[1] < lower[1]
sell = high < upper and high[1] > upper[1]

plotshape(buy, color = color.green, size = size.tiny)
plotshape(sell, color = color.red, size = size.tiny)

enter image description here