[go: up one dir, main page]

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

Bandas Value

This document contains the code for a trading indicator that plots Bollinger Bands and signals for buy and sell signals. It takes the close price and calculates a simple moving average with a period of 10 as the base value. It then calculates upper and lower bands as 2 standard deviations above and below the base. It also calculates a 20 period SMA and adds/subtracts 2.5 standard deviations for additional bands. It plots arrow shapes to signal when the close moves in and out of the bands, and additional signals when the bands are broken on a retest.

Uploaded by

Bruno Viveiros
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)
261 views3 pages

Bandas Value

This document contains the code for a trading indicator that plots Bollinger Bands and signals for buy and sell signals. It takes the close price and calculates a simple moving average with a period of 10 as the base value. It then calculates upper and lower bands as 2 standard deviations above and below the base. It also calculates a 20 period SMA and adds/subtracts 2.5 standard deviations for additional bands. It plots arrow shapes to signal when the close moves in and out of the bands, and additional signals when the bands are broken on a retest.

Uploaded by

Bruno Viveiros
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/ 3

instrument { name = "BANDAS + VALUE J.

M", icon="indicators:BB", overlay = true }

input_group {
"COMPRAR",
comprar_color = input {default = "green", type = input.color}
}

input_group {
"VENDER",
vender_color = input {default = "red", type = input.color}
}

sec = security (current_ticker_id, "5m")

if sec and sec.open_time == open_time then

base = sma(open, '10')


high_band = base + (stdev(open, 10) * 2)
low_band = base - (stdev(open, 10) * 2)
media = sma(close, '20')
up_band = media + (stdev(close, 20) * 2.5)
down_band = media - (stdev(close, 20) * 2.5)
expo = ema(close,'100')

--IMPULSOS

plot_shape((open > high_band and close < high_band),


"VENDER",
shape_style.arrowdown,
shape_size.huge,
vender_color,
shape_location.abovebar,
0,
"VENDA",
vender_color)

plot_shape((open < low_band and close > low_band),


"COMPRAR",
shape_style.arrowup,
shape_size.huge,
comprar_color,
shape_location.belowbar,
0,
"COMPRA",
comprar_color)

-- RETRAES

plot_shape((open < up_band and high > up_band and close <= up_band and expo >
up_band),
"VENDER1",
shape_style.arrowdown,
shape_size.huge,
vender_color,
shape_location.abovebar,
0,
"VENDA RT",
vender_color)
plot_shape((open > down_band and low < down_band and close >= down_band and
expo < down_band),
"COMPRAR1",
shape_style.arrowup,
shape_size.huge,
comprar_color,
shape_location.belowbar,
0,
"COMPRA RT",
comprar_color)

end

instrument { name = "BANDAS + VALUE J.M", 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

You might also like