0% found this document useful (0 votes)
10 views3 pages

Forecast RSI

The document defines an indicator for calculating the Relative Strength Index (RSI), K% and D% values. It takes a data series as input, calculates RSI and smoothing values, and plots the RSI, K% and D% lines along with overbought and oversold bands.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

Forecast RSI

The document defines an indicator for calculating the Relative Strength Index (RSI), K% and D% values. It takes a data series as input, calculates RSI and smoothing values, and plots the RSI, K% and D% lines along with overbought and oversold bands.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 3

instrument { name = “Forecast RSIr" }

period = input (14, "front.period", input.integer, 1)


source = input (1, "front.ind.source", input.string_selection,
inputs.titles)
input_group {
"front.ind.dpo.generalline",
color = input { default = "#DB4931", type = input.color },
width = input { default = 1, type = input.line_width}
}
input_group {
"front.platform.baseline",
zero_color = input { default = rgba(255,255,255,0.15), type =
input.color },
zero_width = input { default = 1, type = input.line_width },
zero_visible = input { default = true, type = input.plot_visibility }
}
if zero_visible then
hline (0, "", zero_color, zero_width)
end
local sourceSeries = inputs [source]
cfo = (sourceSeries - linreg (sourceSeries, period, 0)) / sourceSeries
plot (cfo, "CFO", color, width)

input_group {
"RSI",
rsi_period = input (14, "front.period", input.integer, 1)
}

input_group {
"%K",
k_period = input (14, "front.period", input.integer, 1),
smooth = input (3, "front.platform.smothing", input.integer, 1),

source = input (1, "front.ind.source", input.string_selection,


inputs.titles),

k_color = input { default = "#56CEFF", type = input.color },


k_width = input { default = 1, type = input.line_width}
}
input_group {
"%D",
d_period = input (3, "front.period", input.integer, 1),

d_color = input { default = "#FF7700", type = input.color },


d_width = input { default = 1, type = input.line_width}
}

input_group {
"front.newind.supportlines",
overbought = input (80, "front.overbought", input.double, 1, 100, 1,
false),
oversold = input (20, "front.oversold", input.double, 1, 100, 1, false),

overbought_color = input { default = rgba(37,225,84,0.50), type =


input.color },
oversold_color = input { default = rgba(255,108,88,0.50), type =
input.color },
bg_color = input { default = rgba(255,255,255,0.05), type =
input.color },

support_width = input { default = 1, type = input.line_width}


}

local sourceSeries = inputs [source]

delta = sourceSeries - sourceSeries [1]

up = ssma (max (delta, 0), rsi_period)


down = ssma (max (-delta, 0), rsi_period)

rs = up / down
rsi = 1 - 1 / (1 + rs)

ll = lowest (rsi, k_period)


rk = (rsi - ll) / (highest (rsi, k_period) - ll)

k = sma (rk, smooth) * 100


d = sma (k, d_period)
fill_area (overbought, oversold, "", bg_color)

hline { value = overbought, color = overbought_color, width =


support_width, style = style.dash_line }
hline { value = oversold, color = oversold_color, width = support_width,
style = style.dash_line }

plot (k, "%K", k_color, k_width)


plot (d, "%D", d_color, d_width)

hline { value = 90, color = rgba(255,255,255,0), show_label = false }


hline { value = 10, color = rgba(255,255,255,0), show_label = false }

You might also like