0% found this document useful (0 votes)
20 views2 pages

AUTOFIBO

Uploaded by

inacioluis950
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)
20 views2 pages

AUTOFIBO

Uploaded by

inacioluis950
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/ 2

instrument { name = "AUTOFIBO", icon="indicators:ADX", overlay = true }

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

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 = "gray", type = input.color },


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

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

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