You are on page 1of 2

-----------------------------

instrument { name = "Retraccion de Fibonacci",

icon="https://binariaspro.com/admin/js/plugins/ckeditor/kcfinder/upload/images/
Logopit_1565884057119.png",
overlay = true }

method_id = input (1, "Tipo", input.string_selection, { "Puntos Fibonacci" })

input_group {
"M0",

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


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

input_group {
"Mx",

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


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

input_group {
"Mn",

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


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

input_group {
"Tx",

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


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

local function Puntos_Fibonacci(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 = { Puntos_Fibonacci }


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", Nivel_0_color, Nivel_0_width, 0, style.levels,


na_mode.restart)
plot (Mx, "Mx", Nivel_1_color, Nivel_1_width, 0, style.levels,
na_mode.restart)
plot (Mn, "Mn", Nivel_2_color, Nivel_2_width, 0, style.levels,
na_mode.restart)
plot (Tx1, "Tx", Nivel_3_color, Nivel_3_width, 0, style.levels,
na_mode.restart)
plot (Tx2, "Tx", Nivel_3_color, Nivel_3_width, 0, style.levels,
na_mode.restart)
plot (Tx3, "Tx", Nivel_3_color, Nivel_3_width, 0, style.levels,
na_mode.restart)
plot (Tx4, "Tx", Nivel_3_color, Nivel_3_width, 0, style.levels,
na_mode.restart)

end

-----------------------------

You might also like