Untitled

mail@pastecode.io avatar
unknown
plain_text
18 days ago
1.4 kB
20
Indexable
Never
//@version=5
indicator(shorttitle='Bollinger Bands + Volume', title='Bollinger Bands + Volume', overlay=true, timeframe='')

//Bollinger Band Basic Code
length = input.int(20, minval=1, tooltip='Change length')
src = input(close, title='Source')
mult = input.float(2.0, minval=0.001, maxval=50, title='StdDev')
basis = ta.sma(src, length)
dev = mult * ta.stdev(src, length)
upper = basis + dev
lower = basis - dev
plot(basis, 'Basis', color=color.new(#872323, 0))
p1 = plot(upper, 'Upper', color=color.new(color.teal, 0))
p2 = plot(lower, 'Lower', color=color.new(color.teal, 0))


//average of upper and lower bands of bollinger bands
upper_average = ta.sma(upper, 10)
lower_average = ta.sma(lower, 10)


//Setting up Criteria for signals 
sell = ta.crossover(close, upper_average) == true and ta.falling(volume, 2)

buy = ta.crossunder(close, lower_average) == true and ta.falling(volume, 2)


//If above criteria happens then give buy and sell signals
plotshape(buy, location=location.belowbar, style=shape.triangleup, color=color.new(color.green, 0), text='BUY', textcolor=color.new(color.green, 0), size=size.tiny, title='BUY')


plotshape(sell, location=location.abovebar, style=shape.triangledown, color=color.new(color.red, 0), text='SELL', textcolor=color.new(color.red, 0), size=size.tiny, title='SELL')


Leave a Comment