OPEN-SOURCE SCRIPT
RSI

// This source code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org/MPL/2.0/
// © xdecow
//version=5
indicator("RSI", overlay=true)
g_panel = 'Panel Options'
i_orientation = input.string('Vertical', 'Orientation', options = ['Vertical', 'Horizontal'], group = g_panel)
i_position = input.string('Bottom Right', 'Position', options = ['Top Left', 'Top Right', 'Top Center', 'Bottom Left', 'Bottom Right', 'Bottom Center', 'Middle Left', 'Middle Right', 'Middle Center'], group = g_panel)
i_border_width = input.int(1, 'Border Width', minval = 0, maxval = 10, group = g_panel, inline = 'border')
i_color_border = input.color(#000000, '', group = g_panel, inline = 'border')
i_showHeaders = input.bool(true, 'Show Headers', group = g_panel)
i_color_header_bg = input.color(#5d606b, 'Headers Background', group = g_panel, inline = 'header')
i_color_header_text = input.color(color.white, 'Text', group = g_panel, inline = 'header')
i_color_tf_bg = input.color(#2a2e39, 'Timeframe Background', group = g_panel, inline = 'tf')
i_color_tf_text = input.color(color.white, 'Text', group = g_panel, inline = 'tf')
i_debug = input.bool(false, 'Display colors palette (debug)', group = g_panel)
// rsi bg colors
g_rsi = 'RSI Colors'
i_threshold_ob = input.int(70, 'Overbought Threshold', minval=51, maxval=100, group = g_rsi)
i_color_ob = input.color(#128416, 'Overbought Background', inline = 'ob', group = g_rsi)
i_tcolor_ob = input.color(color.white, 'Text', inline = 'ob', group = g_rsi)
i_threshold_uptrend = input.int(60, 'Uptrend Threshold', minval=51, maxval=100, group = g_rsi)
i_color_uptrend = input.color(#2d472e, 'Uptrend Background', inline = 'up', group = g_rsi)
i_tcolor_uptrend = input.color(color.white, 'Text', inline = 'up', group = g_rsi)
i_color_mid = input.color(#131722, 'No Trend Background', group = g_rsi, inline = 'mid')
i_tcolor_mid = input.color(#b2b5be, 'Text', group = g_rsi, inline = 'mid')
i_threshold_downtrend = input.int(40, 'Downtrend Threshold', group = g_rsi, minval=0, maxval=49)
i_color_downtrend = input.color(#5b2e2e, 'Downtrend Background', group = g_rsi, inline = 'down')
i_tcolor_downtrend = input.color(color.white, 'Text', group = g_rsi, inline = 'down')
i_threshold_os = input.int(30, 'Oversold Threshold', minval=0, maxval=49, group = g_rsi)
i_color_os = input.color(#db3240, 'Oversold Background', group = g_rsi, inline = 'os')
i_tcolor_os = input.color(color.white, 'Text', group = g_rsi, inline = 'os')
g_rsi1 = 'RSI #1'
i_rsi1_enabled = input.bool(true, title = 'Enabled', group = g_rsi1)
i_rsi1_tf = input.timeframe('5', 'Timeframe', group = g_rsi1)
i_rsi1_len = input.int(14, 'Length', minval = 1, group = g_rsi1)
i_rsi1_src = input.source(close, 'Source', group = g_rsi1) * 10000
v_rsi1 = i_rsi1_enabled ? request.security(syminfo.tickerid, i_rsi1_tf, ta.rsi(i_rsi1_src, i_rsi1_len)) : na
g_rsi2 = 'RSI #2'
i_rsi2_enabled = input.bool(true, title = 'Enabled', group = g_rsi2)
i_rsi2_tf = input.timeframe('15', 'Timeframe', group = g_rsi2)
i_rsi2_len = input.int(14, 'Length', minval = 1, group = g_rsi2)
i_rsi2_src = input.source(close, 'Source', group = g_rsi2) * 10000
v_rsi2 = i_rsi2_enabled ? request.security(syminfo.tickerid, i_rsi2_tf, ta.rsi(i_rsi2_src, i_rsi2_len)) : na
g_rsi3 = 'RSI #3'
i_rsi3_enabled = input.bool(true, title = 'Enabled', group = g_rsi3)
i_rsi3_tf = input.timeframe('60', 'Timeframe', group = g_rsi3)
i_rsi3_len = input.int(14, 'Length', minval = 1, group = g_rsi3)
i_rsi3_src = input.source(close, 'Source', group = g_rsi3) * 10000
v_rsi3 = i_rsi3_enabled ? request.security(syminfo.tickerid, i_rsi3_tf, ta.rsi(i_rsi3_src, i_rsi3_len)) : na
g_rsi4 = 'RSI #4'
i_rsi4_enabled = input.bool(true, title = 'Enabled', group = g_rsi4)
i_rsi4_tf = input.timeframe('240', 'Timeframe', group = g_rsi4)
i_rsi4_len = input.int(14, 'Length', minval = 1, group = g_rsi4)
i_rsi4_src = input.source(close, 'Source', group = g_rsi4) * 10000
v_rsi4 = i_rsi4_enabled ? request.security(syminfo.tickerid, i_rsi4_tf, ta.rsi(i_rsi4_src, i_rsi4_len)) : na
g_rsi5 = 'RSI #5'
i_rsi5_enabled = input.bool(true, title = 'Enabled', group = g_rsi5)
i_rsi5_tf = input.timeframe('D', 'Timeframe', group = g_rsi5)
i_rsi5_len = input.int(14, 'Length', minval = 1, group = g_rsi5)
i_rsi5_src = input.source(close, 'Source', group = g_rsi5) * 10000
v_rsi5 = i_rsi5_enabled ? request.security(syminfo.tickerid, i_rsi5_tf, ta.rsi(i_rsi5_src, i_rsi5_len)) : na
g_rsi6 = 'RSI #6'
i_rsi6_enabled = input.bool(true, title = 'Enabled', group = g_rsi6)
i_rsi6_tf = input.timeframe('W', 'Timeframe', group = g_rsi6)
i_rsi6_len = input.int(14, 'Length', minval = 1, group = g_rsi6)
i_rsi6_src = input.source(close, 'Source', group = g_rsi6) * 10000
v_rsi6 = i_rsi6_enabled ? request.security(syminfo.tickerid, i_rsi6_tf, ta.rsi(i_rsi6_src, i_rsi6_len)) : na
g_rsi7 = 'RSI #7'
i_rsi7_enabled = input.bool(false, title = 'Enabled', group = g_rsi7)
i_rsi7_tf = input.timeframe('W', 'Timeframe', group = g_rsi7)
i_rsi7_len = input.int(14, 'Length', minval = 1, group = g_rsi7)
i_rsi7_src = input.source(close, 'Source', group = g_rsi7) * 10000
v_rsi7 = i_rsi7_enabled ? request.security(syminfo.tickerid, i_rsi7_tf, ta.rsi(i_rsi7_src, i_rsi7_len)) : na
g_rsi8 = 'RSI #8'
i_rsi8_enabled = input.bool(false, title = 'Enabled', group = g_rsi8)
i_rsi8_tf = input.timeframe('W', 'Timeframe', group = g_rsi8)
i_rsi8_len = input.int(14, 'Length', minval = 1, group = g_rsi8)
i_rsi8_src = input.source(close, 'Source', group = g_rsi8) * 10000
v_rsi8 = i_rsi8_enabled ? request.security(syminfo.tickerid, i_rsi8_tf, ta.rsi(i_rsi8_src, i_rsi8_len)) : na
g_rsi9 = 'RSI #9'
i_rsi9_enabled = input.bool(false, title = 'Enabled', group = g_rsi9)
i_rsi9_tf = input.timeframe('W', 'Timeframe', group = g_rsi9)
i_rsi9_len = input.int(14, 'Length', minval = 1, group = g_rsi9)
i_rsi9_src = input.source(close, 'Source', group = g_rsi9) * 10000
v_rsi9 = i_rsi9_enabled ? request.security(syminfo.tickerid, i_rsi9_tf, ta.rsi(i_rsi9_src, i_rsi9_len)) : na
g_rsi10 = 'RSI #10'
i_rsi10_enabled = input.bool(false, title = 'Enabled', group = g_rsi10)
i_rsi10_tf = input.timeframe('W', 'Timeframe', group = g_rsi10)
i_rsi10_len = input.int(14, 'Length', minval = 1, group = g_rsi10)
i_rsi10_src = input.source(close, 'Source', group = g_rsi10) * 10000
v_rsi10 = i_rsi10_enabled ? request.security(syminfo.tickerid, i_rsi10_tf, ta.rsi(i_rsi10_src, i_rsi10_len)) : na
f_StrPositionToConst(_p) =>
switch _p
'Top Left' => position.top_left
'Top Right' => position.top_right
'Top Center' => position.top_center
'Middle Left' => position.middle_left
'Middle Right' => position.middle_right
'Middle Center' => position.middle_center
'Bottom Left' => position.bottom_left
'Bottom Right' => position.bottom_right
'Bottom Center' => position.bottom_center
=> position.bottom_right
f_timeframeToHuman(_tf) =>
seconds = timeframe.in_seconds(_tf)
if seconds < 60
_tf
else if seconds < 3600
str.tostring(seconds / 60) + 'm'
else if seconds < 86400
str.tostring(seconds / 60 / 60) + 'h'
else
switch _tf
"1D" => "D"
"1W" => "W"
"1M" => "M"
=> str.tostring(_tf)
type TPanel
table src = na
bool vertical_orientation = true
int row = 0
int col = 0
method incCol(TPanel _panel) =>
if _panel.vertical_orientation
_panel.col += 1
else
_panel.row += 1
method incRow(TPanel _panel) =>
if not _panel.vertical_orientation
_panel.col += 1
_panel.row := 0
else
_panel.row += 1
_panel.col := 0
method add(TPanel _panel, string _v1, color _bg1, color _ctext1, string _v2, color _bg2, color _ctext2) =>
table.cell(_panel.src, _panel.col, _panel.row, _v1, text_color = _ctext1, bgcolor = _bg1)
_panel.incCol()
table.cell(_panel.src, _panel.col, _panel.row, _v2, text_color = _ctext2, bgcolor = _bg2)
_panel.incRow()
f_bg(_rsi) =>
c_line = na(_rsi) ? i_color_mid :
_rsi >= i_threshold_ob ? i_color_ob :
_rsi >= i_threshold_uptrend ? i_color_uptrend :
_rsi <= i_threshold_os ? i_color_os :
_rsi <= i_threshold_downtrend ? i_color_downtrend :
i_color_mid
f_rsi_text_color(_rsi) =>
c_line = na(_rsi) ? i_tcolor_mid :
_rsi >= i_threshold_ob ? i_tcolor_ob :
_rsi >= i_threshold_uptrend ? i_tcolor_uptrend :
_rsi <= i_threshold_os ? i_tcolor_os :
_rsi <= i_threshold_downtrend ? i_tcolor_downtrend :
i_tcolor_mid
f_formatRsi(_rsi) => na(_rsi) ? 'N/A' : str.tostring(_rsi, '0.00')
if barstate.islast
v_panel = TPanel.new(vertical_orientation = i_orientation == 'Vertical')
v_max_rows = 20
v_panel.src := table.new(f_StrPositionToConst(i_position), v_max_rows, v_max_rows, border_width = i_border_width, border_color = i_color_border)
if i_showHeaders
v_panel.add('TF', i_color_header_bg, i_color_header_text, 'RSI', i_color_header_bg, i_color_header_text)
if i_rsi1_enabled
v_panel.add(f_timeframeToHuman(i_rsi1_tf), i_color_tf_bg, i_color_tf_text, f_formatRsi(v_rsi1), f_bg(v_rsi1), f_rsi_text_color(v_rsi1))
if i_rsi2_enabled
v_panel.add(f_timeframeToHuman(i_rsi2_tf), i_color_tf_bg, i_color_tf_text, f_formatRsi(v_rsi2), f_bg(v_rsi2), f_rsi_text_color(v_rsi2))
if i_rsi3_enabled
v_panel.add(f_timeframeToHuman(i_rsi3_tf), i_color_tf_bg, i_color_tf_text, f_formatRsi(v_rsi3), f_bg(v_rsi3), f_rsi_text_color(v_rsi3))
if i_rsi4_enabled
v_panel.add(f_timeframeToHuman(i_rsi4_tf), i_color_tf_bg, i_color_tf_text, f_formatRsi(v_rsi4), f_bg(v_rsi4), f_rsi_text_color(v_rsi4))
if i_rsi5_enabled
v_panel.add(f_timeframeToHuman(i_rsi5_tf), i_color_tf_bg, i_color_tf_text, f_formatRsi(v_rsi5), f_bg(v_rsi5), f_rsi_text_color(v_rsi5))
if i_rsi6_enabled
v_panel.add(f_timeframeToHuman(i_rsi6_tf), i_color_tf_bg, i_color_tf_text, f_formatRsi(v_rsi6), f_bg(v_rsi6), f_rsi_text_color(v_rsi6))
if i_rsi7_enabled
v_panel.add(f_timeframeToHuman(i_rsi7_tf), i_color_tf_bg, i_color_tf_text, f_formatRsi(v_rsi7), f_bg(v_rsi7), f_rsi_text_color(v_rsi7))
if i_rsi8_enabled
v_panel.add(f_timeframeToHuman(i_rsi8_tf), i_color_tf_bg, i_color_tf_text, f_formatRsi(v_rsi8), f_bg(v_rsi8), f_rsi_text_color(v_rsi8))
if i_rsi9_enabled
v_panel.add(f_timeframeToHuman(i_rsi9_tf), i_color_tf_bg, i_color_tf_text, f_formatRsi(v_rsi9), f_bg(v_rsi9), f_rsi_text_color(v_rsi9))
if i_rsi10_enabled
v_panel.add(f_timeframeToHuman(i_rsi10_tf), i_color_tf_bg, i_color_tf_text, f_formatRsi(v_rsi10), f_bg(v_rsi10), f_rsi_text_color(v_rsi10))
if i_debug
t = table.new(position.middle_center, 21, 20, border_width = i_border_width, border_color = i_color_border)
v_panel2 = TPanel.new(t, vertical_orientation = i_orientation == 'Vertical')
v_panel2.add('Debug', i_color_header_bg, i_color_header_text, 'Colors', i_color_header_bg, i_color_header_text)
demo = map.new<string, float>()
map.put(demo, 'Overbought', i_threshold_ob)
map.put(demo, 'Uptrend', i_threshold_uptrend)
map.put(demo, 'No Trend', 50)
map.put(demo, 'Downtrend', i_threshold_downtrend)
map.put(demo, 'Oversold', i_threshold_os)
demoKeys = map.keys(demo)
for key in demoKeys
tf = key
rsi = map.get(demo, key)
v_panel2.add(tf, i_color_tf_bg, i_color_tf_text, f_formatRsi(rsi), f_bg(rsi), f_rsi_text_color(rsi))
// © xdecow
//version=5
indicator("RSI", overlay=true)
g_panel = 'Panel Options'
i_orientation = input.string('Vertical', 'Orientation', options = ['Vertical', 'Horizontal'], group = g_panel)
i_position = input.string('Bottom Right', 'Position', options = ['Top Left', 'Top Right', 'Top Center', 'Bottom Left', 'Bottom Right', 'Bottom Center', 'Middle Left', 'Middle Right', 'Middle Center'], group = g_panel)
i_border_width = input.int(1, 'Border Width', minval = 0, maxval = 10, group = g_panel, inline = 'border')
i_color_border = input.color(#000000, '', group = g_panel, inline = 'border')
i_showHeaders = input.bool(true, 'Show Headers', group = g_panel)
i_color_header_bg = input.color(#5d606b, 'Headers Background', group = g_panel, inline = 'header')
i_color_header_text = input.color(color.white, 'Text', group = g_panel, inline = 'header')
i_color_tf_bg = input.color(#2a2e39, 'Timeframe Background', group = g_panel, inline = 'tf')
i_color_tf_text = input.color(color.white, 'Text', group = g_panel, inline = 'tf')
i_debug = input.bool(false, 'Display colors palette (debug)', group = g_panel)
// rsi bg colors
g_rsi = 'RSI Colors'
i_threshold_ob = input.int(70, 'Overbought Threshold', minval=51, maxval=100, group = g_rsi)
i_color_ob = input.color(#128416, 'Overbought Background', inline = 'ob', group = g_rsi)
i_tcolor_ob = input.color(color.white, 'Text', inline = 'ob', group = g_rsi)
i_threshold_uptrend = input.int(60, 'Uptrend Threshold', minval=51, maxval=100, group = g_rsi)
i_color_uptrend = input.color(#2d472e, 'Uptrend Background', inline = 'up', group = g_rsi)
i_tcolor_uptrend = input.color(color.white, 'Text', inline = 'up', group = g_rsi)
i_color_mid = input.color(#131722, 'No Trend Background', group = g_rsi, inline = 'mid')
i_tcolor_mid = input.color(#b2b5be, 'Text', group = g_rsi, inline = 'mid')
i_threshold_downtrend = input.int(40, 'Downtrend Threshold', group = g_rsi, minval=0, maxval=49)
i_color_downtrend = input.color(#5b2e2e, 'Downtrend Background', group = g_rsi, inline = 'down')
i_tcolor_downtrend = input.color(color.white, 'Text', group = g_rsi, inline = 'down')
i_threshold_os = input.int(30, 'Oversold Threshold', minval=0, maxval=49, group = g_rsi)
i_color_os = input.color(#db3240, 'Oversold Background', group = g_rsi, inline = 'os')
i_tcolor_os = input.color(color.white, 'Text', group = g_rsi, inline = 'os')
g_rsi1 = 'RSI #1'
i_rsi1_enabled = input.bool(true, title = 'Enabled', group = g_rsi1)
i_rsi1_tf = input.timeframe('5', 'Timeframe', group = g_rsi1)
i_rsi1_len = input.int(14, 'Length', minval = 1, group = g_rsi1)
i_rsi1_src = input.source(close, 'Source', group = g_rsi1) * 10000
v_rsi1 = i_rsi1_enabled ? request.security(syminfo.tickerid, i_rsi1_tf, ta.rsi(i_rsi1_src, i_rsi1_len)) : na
g_rsi2 = 'RSI #2'
i_rsi2_enabled = input.bool(true, title = 'Enabled', group = g_rsi2)
i_rsi2_tf = input.timeframe('15', 'Timeframe', group = g_rsi2)
i_rsi2_len = input.int(14, 'Length', minval = 1, group = g_rsi2)
i_rsi2_src = input.source(close, 'Source', group = g_rsi2) * 10000
v_rsi2 = i_rsi2_enabled ? request.security(syminfo.tickerid, i_rsi2_tf, ta.rsi(i_rsi2_src, i_rsi2_len)) : na
g_rsi3 = 'RSI #3'
i_rsi3_enabled = input.bool(true, title = 'Enabled', group = g_rsi3)
i_rsi3_tf = input.timeframe('60', 'Timeframe', group = g_rsi3)
i_rsi3_len = input.int(14, 'Length', minval = 1, group = g_rsi3)
i_rsi3_src = input.source(close, 'Source', group = g_rsi3) * 10000
v_rsi3 = i_rsi3_enabled ? request.security(syminfo.tickerid, i_rsi3_tf, ta.rsi(i_rsi3_src, i_rsi3_len)) : na
g_rsi4 = 'RSI #4'
i_rsi4_enabled = input.bool(true, title = 'Enabled', group = g_rsi4)
i_rsi4_tf = input.timeframe('240', 'Timeframe', group = g_rsi4)
i_rsi4_len = input.int(14, 'Length', minval = 1, group = g_rsi4)
i_rsi4_src = input.source(close, 'Source', group = g_rsi4) * 10000
v_rsi4 = i_rsi4_enabled ? request.security(syminfo.tickerid, i_rsi4_tf, ta.rsi(i_rsi4_src, i_rsi4_len)) : na
g_rsi5 = 'RSI #5'
i_rsi5_enabled = input.bool(true, title = 'Enabled', group = g_rsi5)
i_rsi5_tf = input.timeframe('D', 'Timeframe', group = g_rsi5)
i_rsi5_len = input.int(14, 'Length', minval = 1, group = g_rsi5)
i_rsi5_src = input.source(close, 'Source', group = g_rsi5) * 10000
v_rsi5 = i_rsi5_enabled ? request.security(syminfo.tickerid, i_rsi5_tf, ta.rsi(i_rsi5_src, i_rsi5_len)) : na
g_rsi6 = 'RSI #6'
i_rsi6_enabled = input.bool(true, title = 'Enabled', group = g_rsi6)
i_rsi6_tf = input.timeframe('W', 'Timeframe', group = g_rsi6)
i_rsi6_len = input.int(14, 'Length', minval = 1, group = g_rsi6)
i_rsi6_src = input.source(close, 'Source', group = g_rsi6) * 10000
v_rsi6 = i_rsi6_enabled ? request.security(syminfo.tickerid, i_rsi6_tf, ta.rsi(i_rsi6_src, i_rsi6_len)) : na
g_rsi7 = 'RSI #7'
i_rsi7_enabled = input.bool(false, title = 'Enabled', group = g_rsi7)
i_rsi7_tf = input.timeframe('W', 'Timeframe', group = g_rsi7)
i_rsi7_len = input.int(14, 'Length', minval = 1, group = g_rsi7)
i_rsi7_src = input.source(close, 'Source', group = g_rsi7) * 10000
v_rsi7 = i_rsi7_enabled ? request.security(syminfo.tickerid, i_rsi7_tf, ta.rsi(i_rsi7_src, i_rsi7_len)) : na
g_rsi8 = 'RSI #8'
i_rsi8_enabled = input.bool(false, title = 'Enabled', group = g_rsi8)
i_rsi8_tf = input.timeframe('W', 'Timeframe', group = g_rsi8)
i_rsi8_len = input.int(14, 'Length', minval = 1, group = g_rsi8)
i_rsi8_src = input.source(close, 'Source', group = g_rsi8) * 10000
v_rsi8 = i_rsi8_enabled ? request.security(syminfo.tickerid, i_rsi8_tf, ta.rsi(i_rsi8_src, i_rsi8_len)) : na
g_rsi9 = 'RSI #9'
i_rsi9_enabled = input.bool(false, title = 'Enabled', group = g_rsi9)
i_rsi9_tf = input.timeframe('W', 'Timeframe', group = g_rsi9)
i_rsi9_len = input.int(14, 'Length', minval = 1, group = g_rsi9)
i_rsi9_src = input.source(close, 'Source', group = g_rsi9) * 10000
v_rsi9 = i_rsi9_enabled ? request.security(syminfo.tickerid, i_rsi9_tf, ta.rsi(i_rsi9_src, i_rsi9_len)) : na
g_rsi10 = 'RSI #10'
i_rsi10_enabled = input.bool(false, title = 'Enabled', group = g_rsi10)
i_rsi10_tf = input.timeframe('W', 'Timeframe', group = g_rsi10)
i_rsi10_len = input.int(14, 'Length', minval = 1, group = g_rsi10)
i_rsi10_src = input.source(close, 'Source', group = g_rsi10) * 10000
v_rsi10 = i_rsi10_enabled ? request.security(syminfo.tickerid, i_rsi10_tf, ta.rsi(i_rsi10_src, i_rsi10_len)) : na
f_StrPositionToConst(_p) =>
switch _p
'Top Left' => position.top_left
'Top Right' => position.top_right
'Top Center' => position.top_center
'Middle Left' => position.middle_left
'Middle Right' => position.middle_right
'Middle Center' => position.middle_center
'Bottom Left' => position.bottom_left
'Bottom Right' => position.bottom_right
'Bottom Center' => position.bottom_center
=> position.bottom_right
f_timeframeToHuman(_tf) =>
seconds = timeframe.in_seconds(_tf)
if seconds < 60
_tf
else if seconds < 3600
str.tostring(seconds / 60) + 'm'
else if seconds < 86400
str.tostring(seconds / 60 / 60) + 'h'
else
switch _tf
"1D" => "D"
"1W" => "W"
"1M" => "M"
=> str.tostring(_tf)
type TPanel
table src = na
bool vertical_orientation = true
int row = 0
int col = 0
method incCol(TPanel _panel) =>
if _panel.vertical_orientation
_panel.col += 1
else
_panel.row += 1
method incRow(TPanel _panel) =>
if not _panel.vertical_orientation
_panel.col += 1
_panel.row := 0
else
_panel.row += 1
_panel.col := 0
method add(TPanel _panel, string _v1, color _bg1, color _ctext1, string _v2, color _bg2, color _ctext2) =>
table.cell(_panel.src, _panel.col, _panel.row, _v1, text_color = _ctext1, bgcolor = _bg1)
_panel.incCol()
table.cell(_panel.src, _panel.col, _panel.row, _v2, text_color = _ctext2, bgcolor = _bg2)
_panel.incRow()
f_bg(_rsi) =>
c_line = na(_rsi) ? i_color_mid :
_rsi >= i_threshold_ob ? i_color_ob :
_rsi >= i_threshold_uptrend ? i_color_uptrend :
_rsi <= i_threshold_os ? i_color_os :
_rsi <= i_threshold_downtrend ? i_color_downtrend :
i_color_mid
f_rsi_text_color(_rsi) =>
c_line = na(_rsi) ? i_tcolor_mid :
_rsi >= i_threshold_ob ? i_tcolor_ob :
_rsi >= i_threshold_uptrend ? i_tcolor_uptrend :
_rsi <= i_threshold_os ? i_tcolor_os :
_rsi <= i_threshold_downtrend ? i_tcolor_downtrend :
i_tcolor_mid
f_formatRsi(_rsi) => na(_rsi) ? 'N/A' : str.tostring(_rsi, '0.00')
if barstate.islast
v_panel = TPanel.new(vertical_orientation = i_orientation == 'Vertical')
v_max_rows = 20
v_panel.src := table.new(f_StrPositionToConst(i_position), v_max_rows, v_max_rows, border_width = i_border_width, border_color = i_color_border)
if i_showHeaders
v_panel.add('TF', i_color_header_bg, i_color_header_text, 'RSI', i_color_header_bg, i_color_header_text)
if i_rsi1_enabled
v_panel.add(f_timeframeToHuman(i_rsi1_tf), i_color_tf_bg, i_color_tf_text, f_formatRsi(v_rsi1), f_bg(v_rsi1), f_rsi_text_color(v_rsi1))
if i_rsi2_enabled
v_panel.add(f_timeframeToHuman(i_rsi2_tf), i_color_tf_bg, i_color_tf_text, f_formatRsi(v_rsi2), f_bg(v_rsi2), f_rsi_text_color(v_rsi2))
if i_rsi3_enabled
v_panel.add(f_timeframeToHuman(i_rsi3_tf), i_color_tf_bg, i_color_tf_text, f_formatRsi(v_rsi3), f_bg(v_rsi3), f_rsi_text_color(v_rsi3))
if i_rsi4_enabled
v_panel.add(f_timeframeToHuman(i_rsi4_tf), i_color_tf_bg, i_color_tf_text, f_formatRsi(v_rsi4), f_bg(v_rsi4), f_rsi_text_color(v_rsi4))
if i_rsi5_enabled
v_panel.add(f_timeframeToHuman(i_rsi5_tf), i_color_tf_bg, i_color_tf_text, f_formatRsi(v_rsi5), f_bg(v_rsi5), f_rsi_text_color(v_rsi5))
if i_rsi6_enabled
v_panel.add(f_timeframeToHuman(i_rsi6_tf), i_color_tf_bg, i_color_tf_text, f_formatRsi(v_rsi6), f_bg(v_rsi6), f_rsi_text_color(v_rsi6))
if i_rsi7_enabled
v_panel.add(f_timeframeToHuman(i_rsi7_tf), i_color_tf_bg, i_color_tf_text, f_formatRsi(v_rsi7), f_bg(v_rsi7), f_rsi_text_color(v_rsi7))
if i_rsi8_enabled
v_panel.add(f_timeframeToHuman(i_rsi8_tf), i_color_tf_bg, i_color_tf_text, f_formatRsi(v_rsi8), f_bg(v_rsi8), f_rsi_text_color(v_rsi8))
if i_rsi9_enabled
v_panel.add(f_timeframeToHuman(i_rsi9_tf), i_color_tf_bg, i_color_tf_text, f_formatRsi(v_rsi9), f_bg(v_rsi9), f_rsi_text_color(v_rsi9))
if i_rsi10_enabled
v_panel.add(f_timeframeToHuman(i_rsi10_tf), i_color_tf_bg, i_color_tf_text, f_formatRsi(v_rsi10), f_bg(v_rsi10), f_rsi_text_color(v_rsi10))
if i_debug
t = table.new(position.middle_center, 21, 20, border_width = i_border_width, border_color = i_color_border)
v_panel2 = TPanel.new(t, vertical_orientation = i_orientation == 'Vertical')
v_panel2.add('Debug', i_color_header_bg, i_color_header_text, 'Colors', i_color_header_bg, i_color_header_text)
demo = map.new<string, float>()
map.put(demo, 'Overbought', i_threshold_ob)
map.put(demo, 'Uptrend', i_threshold_uptrend)
map.put(demo, 'No Trend', 50)
map.put(demo, 'Downtrend', i_threshold_downtrend)
map.put(demo, 'Oversold', i_threshold_os)
demoKeys = map.keys(demo)
for key in demoKeys
tf = key
rsi = map.get(demo, key)
v_panel2.add(tf, i_color_tf_bg, i_color_tf_text, f_formatRsi(rsi), f_bg(rsi), f_rsi_text_color(rsi))
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.