instrument{name="Terceira do Movimento", overlay=true}
-- Cores
cor_np_compra = input { default = "#00FF00", type = [Link] }
cor_np_venda = input { default = "#FF0000", type = [Link] }
texto_cor = input { default = "white", type = [Link] }
-- Funes simples
function is_bullish(i) return close[i] > open[i] end
function is_bearish(i) return close[i] < open[i] end
-- Lgica direta com vela 0 usando LOSANGOS
plot_shape(
(is_bearish(2) and is_bullish(1) and is_bullish(0)),
"3VM_COMPRA",
shape_style.diamond,
shape_size.huge,
cor_np_compra,
shape_location.belowbar,
0,
"3VM",
texto_cor
)
plot_shape(
(is_bullish(2) and is_bearish(1) and is_bearish(0)),
"3VM_VENDA",
shape_style.diamond,
shape_size.huge,
cor_np_venda,
shape_location.abovebar,
0,
"3VM",
texto_cor
)
instrument {
name = "Terceira Vela do Movimento",
short_name = 'super',
icon = 'indicators:BB',
overlay = true
}
MaFast_period = input(1,"Ma Fast period",[Link],1,1000,1)
MaValue = input(5,"Ma Value", input.string_selection,[Link])
MaSlow_period = input(34,"Ma Slow period",[Link],1,1000,1)
Signal_period = input(5,"Signal period",[Link],1,1000,1)
input_group {
"Subaruba",
colorBuy = input { default = "green", type = [Link] },
visibleBuy = input { default = true, type = input.plot_visibility }
}
input_group {
"Decareba",
colorSell = input { default = "red", type = [Link] },
visibleSell = input { default = true, type = input.plot_visibility }
}
local titleValue = inputs[MaValue]
-- mdia mvel linear rpida
smaFast = sma(titleValue, MaFast_period)
-- mdia mvel linear devagar
smaSlow = sma(titleValue, MaSlow_period)
-- calculo diferencial - serie
buffer1 = smaFast - smaSlow
-- calculo da mdia mvel ponderada - serie
buffer2 = wma(buffer1, Signal_period)
buyCondition = conditional(buffer1 > buffer2 and buffer1[1] < buffer2[1] and
not (buffer1 < buffer2 and buffer1[1] > buffer2[1]))
buyCondition = conditional(buffer1 > buffer2 and buffer1[1] < buffer2[1])
sellCondition = conditional(buffer1 < buffer2 and buffer1[1] > buffer2[1] and
not (buffer1 > buffer2 and buffer1[1] < buffer2[1]))
sellCondition = conditional(buffer1 < buffer2 and buffer1[1] > buffer2[1] )
plot_shape(
(buyCondition),
"Subaruba",
shape_style.triangleup,
shape_size.huge,
colorBuy,
shape_location.belowbar,
-1,
"Subaruba",
"green"
)
plot_shape(
(sellCondition),
"Decareba",
shape_style.triangledown,
shape_size.huge,
colorSell,
shape_location.abovebar,
-1,
"Decareba",
"red"
)