AL
Information
Username: | alirezayousefi1011 |
Member since: | 22 Sep 2023 |
Last login: | 03 May 2024 |
Status: | Active |
Activity
Where | Created | Comments |
---|---|---|
Algorithms | 3 | 1 |
Forum Topics | 0 | 0 |
Jobs | 0 | 0 |
Username: | alirezayousefi1011 |
Member since: | 22 Sep 2023 |
Last login: | 03 May 2024 |
Status: | Active |
Where | Created | Comments |
---|---|---|
Algorithms | 3 | 1 |
Forum Topics | 0 | 0 |
Jobs | 0 | 0 |
Convert this code
//@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()