Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.1 kB
10
Indexable
Never
//Bollinger Band Basic Code
length = input(20, minval=1,tooltip="Change length")
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
plot(basis, "Basis", color=#872323)
p1 = plot(upper, "Upper", color=color.teal)
p2 = plot(lower, "Lower", color=color.teal)


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


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

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


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

plotshape(sell,location=location.abovebar,style=shape.triangledown,color=color.red,text="SELL",textcolor=color.red,size=size.tiny,title="SELL")
Leave a Comment