From d14066e3e09e494deeea18e374f749886b236fc8 Mon Sep 17 00:00:00 2001 From: moshferatu Date: Thu, 2 Nov 2023 05:46:03 -0700 Subject: [PATCH] Add %B indicator --- %b.pine | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 %b.pine diff --git a/%b.pine b/%b.pine new file mode 100644 index 0000000..ca231cc --- /dev/null +++ b/%b.pine @@ -0,0 +1,19 @@ +// Credit to @kerberos007. +//@version=5 +indicator("%B", shorttitle="%B", overlay=false) + +moving_average = input.int(20, minval=1, title="Moving Average") +std_dev = input(2.0, title="Standard Deviations") +symbol = input("VIX", title="Symbol") + +current_close = request.security(symbol, timeframe.period, close) + +[basis, upper_band, lower_band] = ta.bb(current_close, moving_average, std_dev) + +percentB = (current_close - lower_band) / (upper_band - lower_band) + +plot(percentB, title="%B", color=color.yellow) + +hline(0, "Lower Band", color=color.red, linestyle=hline.style_solid) +hline(0.5, "Middle Band", color=color.gray, linestyle=hline.style_solid) +hline(1, "Upper Band", color=color.lime, linestyle=hline.style_solid) \ No newline at end of file