Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.7 kB
9
Indexable
Never
//@version=5

indicator(shorttitle='BB - Pinbar', title='Bollinger Bands - Pinbar', overlay=true)

length = input.int(20, minval=1, title='BB Length')
mult = input.float(2.0, minval=0.001, maxval=50, title='BB StdDev')
lengthRSI = input.int(9, minval=1, title='RSI Length')
pinbardown = input.int(75, minval=1, maxval=99, title='Bearish pinbar when RSI >= ')
pinbarup = input.int(25, minval=1, maxval=99, title='Bullish pinbar when RSI <= ')

basis = ta.sma(close, length)
dev = mult * ta.stdev(close, length)
upper = basis + dev
lower = basis - dev
plot(basis, 'Basis', color=color.new(#872323, 0), offset=0)
p1 = plot(upper, 'Upper', color=color.new(color.teal, 0), offset=0)
p2 = plot(lower, 'Lower', color=color.new(color.teal, 0), offset=0)
fill(p1, p2, title='Background', color=color.new(#198787, 95))

rsi = ta.rsi(close, lengthRSI)
body = math.abs(close - open)
upshadow = open > close ? high - open : high - close
downshadow = open > close ? close - low : open - low
pinbar_h = close[1] > open[1] and rsi > pinbardown ? body[1] > body ? upshadow > 0.8 * body ? upshadow > 2 * downshadow ? 1 : 0 : 0 : 0 : 0
pinbar_l = open[1] > close[1] and rsi < pinbarup ? body[1] > body ? downshadow > 0.8 * body ? downshadow > 2 * upshadow ? 1 : 0 : 0 : 0 : 0
plotshape(pinbar_h, style=shape.triangledown, color=color.new(color.red, 0))
plotshape(pinbar_l, style=shape.triangleup, color=color.new(color.lime, 0), location=location.belowbar)
plotchar(pinbar_h, text='Bearish pinbar', char='', color=color.new(color.red, 0))
plotchar(pinbar_l, text='Bullish pinbar', char='', color=color.new(color.lime, 0), location=location.belowbar)
Leave a Comment