You are on page 1of 2

instrument { name = "Retracao em M5 @Midrante", icon="indicators:ADX", overlay =

true }

method_id = input (1, "Type", input.string_selection, { "Pontos da Fibo" })

input_group {
"M0",

level_0_color = input { default = "white", type = input.color },


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

input_group {
"Mx",

level_1_color = input { default = "red", type = input.color },


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

input_group {
"Mn",

level_2_color = input { default = "green", type = input.color },


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

input_group {
"Tx",

level_3_color = input { default = "grey", type = input.color },


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

local function Pontos_da_Fibo(candle)


M0 = (candle.low + candle.high) / 2
Mx = candle.high
Mn = candle.low
if candle.close < candle.open then
Tx1 = M0 + (candle.high - M0) * 0.236
Tx2 = M0 + (candle.high - M0) * 0.618
Tx3 = M0 + (candle.low - M0) * 0.236
Tx4 = M0 + (candle.low - M0) * 0.53
elseif candle.close > candle.open then
Tx1 = M0 + (candle.high - M0) * 0.53
Tx2 = M0 + (candle.high - M0) * 0.236
Tx3 = M0 + (candle.low - M0) * 0.618
Tx4 = M0 + (candle.low - M0) * 0.236
end
end

local methods = { Pontos_da_Fibo }

local resolution = "1D"

if is_daily then
resolution = "1M"
elseif is_weekly or is_monthly then
resolution = "1Y"
end
sec = security (current_ticker_id, resolution)

if sec then
local method = methods [method_id]

method (sec)

plot (M0, "M0", level_0_color, level_0_width, 0, style.levels,


na_mode.restart)
plot (Mx, "Mx", level_1_color, level_1_width, 0, style.levels,
na_mode.restart)
plot (Mn, "Mn", level_2_color, level_2_width, 0, style.levels,
na_mode.restart)
plot (Tx1, "Tx", level_3_color, level_3_width, 0, style.levels,
na_mode.restart)
plot (Tx2, "Tx", level_3_color, level_3_width, 0, style.levels,
na_mode.restart)
plot (Tx3, "Tx", level_3_color, level_3_width, 0, style.levels,
na_mode.restart)
plot (Tx4, "Tx", level_3_color, level_3_width, 0, style.levels,
na_mode.restart)

end

You might also like