Untitled
unknown
plain_text
a year ago
1.5 kB
37
Indexable
//@version=6
strategy(shorttitle="BB", title="Bollinger Bands", overlay=true)
length = input.int(20, minval=1)
maType = input.string("SMA", "Basis MA Type", options = ["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"])
src = input(close, title="Source")
mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev")
var bool giris = false
ma(source, length, _type) =>
switch _type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
basis = ma(src, length, maType)
dev = mult * ta.stdev(src, length)
upper = basis + dev
lower = basis - dev
offset = input.int(0, "Offset", minval = -500, maxval = 500, display = display.data_window)
plot(basis, "Basis", color=#2962FF, offset = offset)
p1 = plot(upper, "Upper", color=#F23645, offset = offset)
p2 = plot(lower, "Lower", color=#089981, offset = offset)
fill(p1, p2, title = "Background", color=color.rgb(33, 150, 243, 95))
fark = ((upper - lower) / close) * 100
if ta.crossunder(close, lower)
giris := true
if giris and ta.crossover(close, basis) and fark > 15
strategy.entry("Long", strategy.long)
giris := false
if strategy.position_size > 0 and ta.crossover(close, upper)
strategy.exit("TP", "Long", limit = close)
if strategy.position_size > 0 and ta.crossunder(close, lower)
strategy.exit("Stop Loss", "Long", limit = close)Editor is loading...
Leave a Comment