0% found this document useful (0 votes)
11 views1 page

BB & ATR Indicator for TradingView

This document is a Pine Script code for a trading indicator named 'BB & ATR' that combines Bollinger Bands and Average True Range (ATR). It allows users to input parameters for length and smoothing methods, calculates short and long stop levels, and plots the Bollinger Bands %B. Additionally, it displays the calculated stop levels in a table on the chart.

Uploaded by

rajuverma3011
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views1 page

BB & ATR Indicator for TradingView

This document is a Pine Script code for a trading indicator named 'BB & ATR' that combines Bollinger Bands and Average True Range (ATR). It allows users to input parameters for length and smoothing methods, calculates short and long stop levels, and plots the Bollinger Bands %B. Additionally, it displays the calculated stop levels in a table on the chart.

Uploaded by

rajuverma3011
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

//@version=5

indicator(title="BB & ATR", shorttitle="BBATR", overlay=false)


length = [Link](title="Length", defval=14, minval=1)
smoothing = [Link](title="Smoothing", defval="RMA", options=["RMA", "SMA",
"EMA", "WMA"])
ma_function(source, length) =>
switch smoothing
"RMA" => [Link](source, length)
"SMA" => [Link](source, length)
"EMA" => [Link](source, length)
=> [Link](source, length)
hesapshort=close + (ma_function([Link](true), length)*1.5)
hesaplong=close - (ma_function([Link](true), length)*1.5)
var testTable = [Link](position = position.middle_right, columns = 1, rows = 2,
bgcolor = [Link], border_width = 1)
if [Link]
[Link](table_id = testTable, column = 0, row = 0, text = "Short Stop " +
[Link](hesapshort), bgcolor=[Link],text_color=[Link])
[Link](table_id = testTable, column = 0, row = 1, text = "long Stop " +
[Link](hesaplong), bgcolor=[Link],text_color=[Link])

length2 = [Link](20, minval=1)


src = input(close, title="Source")
mult = [Link](1.0, minval=0.001, maxval=50, title="StdDev")
basis = [Link](src, length2)
dev = mult * [Link](src, length2)
upper = basis + dev
lower = basis - dev
bbr = (src - lower)/(upper - lower)
plot(bbr, "Bollinger Bands %B", color=#26A69A)
band1 = hline(1, "Overbought", color=#787B86, linestyle=hline.style_dashed)
band0 = hline(0, "Oversold", color=#787B86, linestyle=hline.style_dashed)
fill(band1, band0, color=[Link](38, 166, 154, 90), title="Background")

You might also like