0% found this document useful (0 votes)
271 views4 pages

Bulb Indicator

This document defines a study for displaying buy and sell signals using RSI indicators. It calculates RSI values and determines if the asset is overbought or oversold. Labels and lines are drawn on the chart to mark price levels and signal changes between overbought and oversold states. The labels and lines are updated on each bar to reflect the current RSI levels and price movements.

Uploaded by

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

Bulb Indicator

This document defines a study for displaying buy and sell signals using RSI indicators. It calculates RSI values and determines if the asset is overbought or oversold. Labels and lines are drawn on the chart to mark price levels and signal changes between overbought and oversold states. The labels and lines are updated on each bar to reflect the current RSI levels and price movements.

Uploaded by

bicolorfifeiro88
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

//@version=4

study(title = "BULB indicator",


shorttitle = "BULB indicator",
overlay = true,
precision = 4,
linktoseries = false,
max_bars_back = 1000,
max_lines_count = 500)

recommendation = input(true, title = "BULB")

rsiSource = close
rsiLength = 13
rsiOverbought = 70
rsiOvesold = 30

rsiValue = rsi(rsiSource, rsiLength)

isOverbought = rsiValue >= rsiOverbought


isOversold = rsiValue <= rsiOvesold

var laststate = 0

var hh = low
var ll = high

var label labelll = na


var label labelhh = na

var line line_up = na


var line line_down = na

var last_actual_label_hh_price = 0.0


var last_actual_label_ll_price = 0.0
obLabelText() =>
if(last_actual_label_hh_price < high)
"sell"
else
"sell"

osLabelText() =>
if(last_actual_label_ll_price < low)
"buy"
else
"buy"

createOverBoughtLabel(isIt) =>
if(isIt)
label.new(x=bar_index, y=na ,yloc=yloc.price, style=label.style_label_down,
color=#F70700, size=size.normal, text=obLabelText(), textcolor = color.white)
else
label.new(x=bar_index, y=na ,yloc=yloc.price, style=label.style_label_up,
color=#22E139, size=size.normal, text=osLabelText(), textcolor = color.white)

moveOversoldLabel() =>
label.set_x(labelll, bar_index)
label.set_y(labelll, low)
label.set_text(labelll, osLabelText())
line.set_x1(line_down, bar_index)
line.set_y1(line_down, low)

moveOverBoughtLabel() =>
label.set_x(labelhh, bar_index)
label.set_y(labelhh, high)
label.set_text(labelhh, obLabelText())
line.set_x1(line_up, bar_index)
line.set_y1(line_up, high)

if(laststate == 2 and isOverbought and recommendation)


hh := high
labelhh := createOverBoughtLabel(true)
last_actual_label_ll_price := label.get_y(labelll)
labelll_ts = label.get_x(labelll)
labelll_price = label.get_y(labelll)
line_up := line.new(x1=bar_index, y1=high, x2=labelll_ts, y2=labelll_price, width=1)
if(laststate == 1 and isOversold and recommendation)
ll := low
labelll := createOverBoughtLabel(false)
last_actual_label_hh_price := label.get_y(labelhh)
labelhh_ts = label.get_x(labelhh)
labelhh_price = label.get_y(labelhh)
line_down := line.new(x1=bar_index, y1=high, x2=labelhh_ts, y2=labelhh_price, width=1)

if(isOverbought and recommendation)


if(high >= hh)
hh := high
moveOverBoughtLabel()
laststate := 1

if(isOversold and recommendation)


if(low <= ll)
ll := low
moveOversoldLabel()
laststate := 2

if(laststate == 1 and isOverbought and recommendation)


if(hh <= high)
hh := high
moveOverBoughtLabel()

if(laststate == 2 and isOversold and recommendation)


if(low <= ll)
ll := low
moveOversoldLabel()

if(laststate == 1 and recommendation)


if(hh <= high)
hh := high
moveOverBoughtLabel()

if(laststate == 2 and recommendation)


if(ll >= low)
ll := low
moveOversoldLabel()

You might also like