简体   繁体   中英

How to buy on the first candle with a low above the lower boll band, sell on first candle with a high below upper boll band

I want to know how to open and close a trade with break up or down of Bollinger bands. For example, as seen in the attached image the highs of each green bar is above the upper boll band, I want to sell on the first bar that has a high lower than the upper boll band. Thanks click the link to see image. (Using Heiken Ashi candles, I know the pros and cons)

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:
IMAGE: 在第一根蜡烛线的低点高于下线束时买入,在第一根蜡烛线的高点低于上线束时卖出

Buy at the first low that is above the lower line, sell at the first high that is below upper line

//@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)

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM