instrument {
name = 'INDICADOR DE FLUXO',
short_name = 'FLUXO',
overlay = true
MaFast_period = input(10, "Ma Fast period", input.integer, 1, 1000, 1)
MaSlow_period = input(50, "Ma Slow period", input.integer, 1, 1000, 1)
Signal_period = input(14, "Signal period", input.integer, 1, 1000, 1)
RSI_period = input(14, "RSI period", input.integer, 1, 100, 1)
RSI_threshold = input(50, "RSI threshold", input.integer, 1, 100, 1)
ADX_period = input(14, "ADX period", input.integer, 1, 100, 1)
ADX_threshold = input(25, "ADX threshold", input.integer, 1, 100, 1)
input_group {
"Compra",
colorBuy = input { default = "GREEN", type = input.color },
visibleBuy = input { default = true, type = input.plot_visibility }
input_group {
"Venda",
colorSell = input { default = "RED", type = input.color },
visibleSell = input { default = true, type = input.plot_visibility }
-- Cálculo das Médias Móveis Exponenciais
emaFast = ema(close, MaFast_period)
emaSlow = ema(close, MaSlow_period)
-- Cálculo do Diferencial
buffer1 = emaFast - emaSlow
-- Cálculo da Média Móvel Ponderada do Diferencial
buffer2 = wma(buffer1, Signal_period)
-- Cálculo do RSI
rsiValue = rsi(close, RSI_period)
-- Cálculo do ADX
adxValue = adx(ADX_period)
-- Condições de Compra e Venda com RSI e ADX
buyCondition = conditional(buffer1 > buffer2 and rsiValue > RSI_threshold and adxValue >
ADX_threshold)
sellCondition = conditional(buffer1 < buffer2 and rsiValue < RSI_threshold and adxValue <
ADX_threshold)
-- Plotagem das Condições de Compra e Venda
plot_shape(
(buyCondition),
"FLUXO",
shape_style.triangleup,
shape_size.huge,
colorBuy,
shape_location.belowbar,
-1
)
plot_shape(
(sellCondition),
"FLUXO",
shape_style.triangledown,
shape_size.huge,
colorSell,
shape_location.abovebar,
-1
-- Plotagem das Médias Móveis Exponenciais para Visualização
plot(emaFast, "EMA Fast", color.blue)
plot(emaSlow, "EMA Slow", color.red)