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

SCRIPT

The document defines inputs for a Relative Strength Index (RSI) indicator including period lengths, averages, and overbought/oversold levels. It also defines inputs for fast, slow, and trend moving averages including period lengths, averages, and visibility. The indicator plots RSI, fast MA, slow MA, and trend MA lines if their visibility is set to true. It also plots shape signals for buy and sell when RSI crosses above and below the overbought and oversold levels and the candle closes in relation to the moving averages.

Uploaded by

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

SCRIPT

The document defines inputs for a Relative Strength Index (RSI) indicator including period lengths, averages, and overbought/oversold levels. It also defines inputs for fast, slow, and trend moving averages including period lengths, averages, and visibility. The indicator plots RSI, fast MA, slow MA, and trend MA lines if their visibility is set to true. It also plots shape signals for buy and sell when RSI crosses above and below the overbought and oversold levels and the candle closes in relation to the moving averages.

Uploaded by

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

instrument {

name = 'TBS',
short_name = 'TBS',
overlay = true
}
RSI_period = input(10,"RSI period",input.integer,1,1000,1)
RSI_average = input(1,"RSI average", input.string_selection,averages.titles)
RSI_title = input(1,"RSI title", input.string_selection,inputs.titles)
RSI_OVB1 = input(50,"RSI OVB1",input.double,0.01,100,1,false)
RSI_OVB2 = input(70,"RSI OVB2",input.double,0.01,100,1,false)
RSI_OVS1 = input(50,"RSI OVS1",input.double,0.01,100,1,false)
RSI_OVS2 = input(30,"RSI OVS2",input.double,0.01,100,1,false)

MaFast_period = input(5,"Ma Fast period",input.integer,1,1000,1)


MaFast_average = input(1,"Ma Fast average", input.string_selection,averages.titles)
MaFast_title = input(1,"Ma Fast title", input.string_selection,inputs.titles)

MaSlow_period = input(10,"Ma Slow period",input.integer,1,1000,1)


MaSlow_average = input(2,"Ma Slow average", input.string_selection,averages.titles)
MaSlow_title = input(1,"Ma Slow title", input.string_selection,inputs.titles)

MaTrend_period = input(20,"Ma Trend period",input.integer,1,1000,5)


MaTrend_average = input(2,"Ma Trend average",
input.string_selection,averages.titles)
MaTrend_title = input(1,"Ma Trend title", input.string_selection,inputs.titles)

input_group {
"Ma Fast Line",
colorFast = input { default = "#ff56e8", type = input.color },
widthFast = input { default = 1, type = input.line_width},
visibleFast = input { default = true, type = input.plot_visibility }
}

input_group {
"Ma Slow Line",
colorSlow = input { default = "#2d2af7", type = input.color },
widthSlow = input { default = 2, type = input.line_width},
visibleSlow = input { default = true, type = input.plot_visibility }
}

input_group {
"Ma Trend Line",
colorTrend = input { default = "#f74200", type = input.color },
widthTrend = input { default = 3, type = input.line_width},
visibleTrend = input { default = true, type = input.plot_visibility }
}

input_group {
"Buy RSI X Out",
colorBuy = input { default = "lime", type = input.color },
visibleBuy = input { default = true, type = input.plot_visibility }
}

input_group {
"Sell RSI X Out",
colorSell = input { default = "orangered", type = input.color },
visibleSell = input { default = true, type = input.plot_visibility }
}
input_group {
"Buy RSI X In",
colorBuy1 = input { default = "lime", type = input.color },
visibleBuy1 = input { default = true, type = input.plot_visibility }
}

input_group {
"Sell RSI X In",
colorSell1 = input { default = "orangered", type = input.color },
visibleSell1 = input { default = true, type = input.plot_visibility }
}

instrument { name = "TBS", overlay = true }


period = input (5, "front.period", input.integer, 1)
shift = input (1, "front.newind.offset", input.double, 0.01, 300, 0.01)
fn = input (averages.ema, "front.newind.average", input.string_selection,
averages.titles)
input_group {
"front.top line",
upper_line_visible = input { default = true, type = input.plot_visibility },
upper_line_color = input { default = "#21B190", type = input.color },
upper_line_width = input { default = 1, type = input.line_width }
}
input_group {
"front.middle line",
middle_line_visible = input { default = true, type = input.plot_visibility },
middle_line_color = input { default = rgba(33,177,144,0.6), type =
input.color },
middle_line_width = input { default = 1, type = input.line_width }
}
input_group {
"front.bottom line",
lower_line_visible = input { default = true, type = input.plot_visibility },
lower_line_color = input { default = "#21B190", type = input.color },
lower_line_width = input { default = 1, type = input.line_width }
}
input_group {
"front.newind.adx.fill",
fill_visible = input { default = true, type = input.plot_visibility },
fill_color = input { default = rgba(33,177,144,0.08), type = input.color },
}
local averageFunction = averages [fn]
middle = averageFunction (hlc3, period)
offset = rma(tr, period) * shift
upper = middle + offset
lower = middle - offset
if fill_visible then
fill { first = upper, second = lower, color = fill_color }
end
if upper_line_visible then
plot (upper, "Upper", upper_line_color, upper_line_width)
end
if lower_line_visible then
plot (lower, "Lower", lower_line_color, lower_line_width)
end
if middle_line_visible then
plot (middle, "Middle", middle_line_color, middle_line_width)
end
local avgFast = averages[MaFast_average]
local titleFast = inputs[MaFast_title]

local avgSlow = averages[MaSlow_average]


local titleSlow = inputs[MaSlow_title]

local avgTrend = averages[MaTrend_average]


local titleTrend = inputs[MaTrend_title]

local avgRSI = averages[RSI_average]


local titleRSI = inputs[RSI_title]

if visibleFast == true then


plot(avgFast(titleFast,MaFast_period),"Ma Fast",colorFast,widthFast)
end

if visibleSlow == true then


plot(avgSlow(titleSlow,MaSlow_period),"Ma Slow",colorSlow,widthSlow)
end

if visibleTrend == true then


plot(avgTrend(titleTrend,MaTrend_period),"Ma Trend",colorTrend,widthTrend)
end

candle_time = {"1s", "5s", "10s", "15s", "30s", "1m", "2m", "5m", "10m", "15m",
"30m", "1H", "2H", "4H", "8H", "12H", "1D", "1W", "1M", "1Y"}
candle_time_res = input(6,"Candle check
resolution",input.string_selection,candle_time)

sec = security (current_ticker_id, candle_time[candle_time_res])

delta = titleRSI - titleRSI[1]


up = avgRSI(max(delta,0), RSI_period)
down = avgRSI(max(-delta,0), RSI_period)
RS = up/down

RES = 100 - 100/(1+ RS)

if (sec ~= nil) and (sec.open_time == open_time) then

Mafast0 = avgFast(titleFast,MaFast_period) --Ma Fast bar 0


Mafast1 = Mafast0[1] --Ma Fast bar 1

MaSlow0 = avgSlow(titleSlow,MaSlow_period) --Ma Slow bar 0


MaSlow1 = MaSlow0[1] --Ma Slow bar 1

MaTrend0 = avgTrend(titleTrend,MaTrend_period) --Ma Trend 0


Matrend1 = MaTrend0[1] --Ma Trend 1

if(visibleBuy == true) then


plot_shape(RES[1] < RSI_OVB1 and RES > RSI_OVB1 and close > Mafast0 and
Mafast0 > MaSlow0 and MaSlow0 > MaTrend0,
"COMPRA",
shape_style.flag,
shape_size.huge,
colorBuy,
shape_location.belowbar,
0,
"COMPRA",
colorBuy
)
end

if(visibleSell == true) then


plot_shape(RES[1] > RSI_OVS1 and RES < RSI_OVS1 and close < Mafast0 and
Mafast0 < MaSlow0 and MaSlow0 < MaTrend0,
"VENTA",
shape_style.arrowdown,
shape_size.huge,
colorSell,
shape_location.abovebar,
0,
"VENTA",
colorSell
)
end

if(visibleBuy1 == true) then


plot_shape(RES[1] < RSI_OVS2 and RES > RSI_OVS2,
"COMPRA",
shape_style.flag,
shape_size.huge,
colorBuy1,
shape_location.belowbar,
0,
"COMPRA",
colorBuy1
)
end

if(visibleSell1 == true) then


plot_shape(RES[1] > RSI_OVB2 and RES < RSI_OVB2 ,
"VENTA",
shape_style.arrowdown,
shape_size.huge,
colorSell1,
shape_location.abovebar,
0,
"VENTA",
colorSell1
)
end

end

You might also like