Tenkan/Kijun Higher Time Frame
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © GiuseppeInzirillo

//@version=5
indicator("Tenkan/Kijun Higher Time Frame", shorttitle="Tenkan/Kijun HTF", overlay=true)

// input declarations
tenkan_len = input.int(9, title="Length")
tenkan_timeframe = input.timeframe("60", "Higher Timeframe")
tenkan_timeframe2 = input.timeframe("240", "Higher Timeframe2")
tenkan_timeframe3 = input.timeframe("D", "Higher Timeframe3")
tenkan_timeframe4 = input.timeframe("W", "Higher Timeframe4")
tenkan_timeframe5 = input.timeframe("M", "Higher Timeframe5")

kijun_len = input.int(26, title="Length")
kijun_timeframe = input.timeframe("60", "Higher Timeframe")
kijun_timeframe2 = input.timeframe("240", "Higher Timeframe2")
kijun_timeframe3 = input.timeframe("D", "Higher Timeframe3")
kijun_timeframe4 = input.timeframe("W", "Higher Timeframe4")
kijun_timeframe5 = input.timeframe("M", "Higher Timeframe5")

tenkan = math.avg(ta.highest(high,tenkan_len), ta.lowest(low, tenkan_len))

tenkan_high = request.security(syminfo.tickerid,tenkan_timeframe,tenkan)
tenkan_high2 = request.security(syminfo.tickerid,tenkan_timeframe2,tenkan)
tenkan_high3 = request.security(syminfo.tickerid,tenkan_timeframe3,tenkan)
tenkan_high4 = request.security(syminfo.tickerid,tenkan_timeframe4,tenkan)
tenkan_high5 = request.security(syminfo.tickerid,tenkan_timeframe5,tenkan)

kijun = math.avg(ta.highest(high,kijun_len), ta.lowest(low, kijun_len))

kijun_high = request.security(syminfo.tickerid,kijun_timeframe,kijun)
kijun_high2 = request.security(syminfo.tickerid,kijun_timeframe2,kijun)
kijun_high3 = request.security(syminfo.tickerid,kijun_timeframe3,kijun)
kijun_high4 = request.security(syminfo.tickerid,kijun_timeframe4,kijun)
kijun_high5 = request.security(syminfo.tickerid,kijun_timeframe5,kijun)

plot(tenkan_high, color=color.gray, title="Tenkan H1", linewidth=1)
plot(tenkan_high2, color=color.orange, title="Tenkan H4", linewidth=2)
plot(tenkan_high3, color=color.maroon, title="Tenkan D", linewidth=3)
plot(tenkan_high4, color=color.olive, title="Tenkan W", linewidth=4)
plot(tenkan_high5, color=color.purple, title="Tenkan M", linewidth=5)

plot(kijun_high, color=color.gray, title="Kijun H1", linewidth=1) 
plot(kijun_high2, color=color.orange, title="Kijun H4", linewidth=2)
plot(kijun_high3, color=color.maroon, title="Kijun D", linewidth=3)
plot(kijun_high4, color=color.olive, title="Kijun W", linewidth=4)
plot(kijun_high5, color=color.purple, title="Kijun M", linewidth=5)