Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

instrument { name = "Pivot Points v1", icon="indicators:ADX", overlay = true }

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

input_group {
"Pivot Point",

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


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

input_group {
"Level 1",

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


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

input_group {
"Level 2",

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


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

input_group {
"Level 3",

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


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

local function classic(candle)


p = (candle.high + candle.low + candle.close) / 3

r1 = 2 * p - candle.low
r2 = p + candle.high - candle.low
r3 = candle.high + 2 * (p - candle.low)

s1 = 2 * p - candle.high
s2 = p - candle.high + candle.low
s3 = candle.low - 2 * (candle.high - p)
end

local function fibonacci(candle)


p = (candle.high + candle.low + candle.close) / 3

r1 = p + (candle.high - candle.low) * 0.382


r2 = p + (candle.high - candle.low) * 0.618
r3 = p + (candle.high - candle.low)

s1 = p - (candle.high - candle.low) * 0.382


s2 = p - (candle.high - candle.low) * 0.618
s3 = p - (candle.high - candle.low)
end

local methods = { fibonacci }

local resolution = "1H"


if is_daily then
resolution = "1H"
elseif is_weekly or is_monthly then
resolution = "1W"
end

sec = security (current_ticker_id, resolution)


sec = security (current_ticker_id, "2H")
if sec then
local method = methods [method_id]

method (sec)

plot (p, "Pivot", level_0_color, level_0_width, 0, style.levels,


na_mode.restart)

plot (r1, "R1", level_1_color, level_1_width, 0, style.levels,


na_mode.restart)
plot (r2, "R2", level_2_color, level_2_width, 0, style.levels,
na_mode.restart)
plot (r3, "R3", level_3_color, level_3_width, 0, style.levels,
na_mode.restart)

plot (s1, "S1", level_1_color, level_1_width, 0, style.levels,


na_mode.restart)
plot (s2, "S2", level_2_color, level_2_width, 0, style.levels,
na_mode.restart)
plot (s3, "S3", level_3_color, level_3_width, 0, style.levels,
na_mode.restart)
end

You might also like