My Triple Supertrend
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © aryhidayat12

//@version=4
study("My Triple Supertrend", overlay=true, resolution="", resolution_gaps=true)

atrPeriod = input(10, "ATR Length")
factor = input(1, "Factor")

[supertrend, direction] = supertrend(factor, atrPeriod)

bodyMiddle = plot((open + close) / 2, display=display.none)
upTrend = plot(direction < 0 ? supertrend : na, "Up Trend", color = color.green, style=plot.style_linebr)
downTrend = plot(direction < 0? na : supertrend, "Down Trend", color = color.red, style=plot.style_linebr)

fill(bodyMiddle, upTrend, color.new(color.green, 90), fillgaps=false)
fill(bodyMiddle, downTrend, color.new(color.red, 90), fillgaps=false)

atrPeriod2 = input(11, "ATR Length")
factor2 = input(2, "Factor")

[supertrend2, direction2] = supertrend(factor2, atrPeriod2)


upTrend2 = plot(direction2 < 0 ? supertrend2 : na, "Up Trend", color = color.green, style=plot.style_linebr)
downTrend2 = plot(direction2 < 0? na : supertrend2, "Down Trend", color = color.red, style=plot.style_linebr)

atrPeriod3 = input(12, "ATR Length")
factor3 = input(3, "Factor")

[supertrend3, direction3] = supertrend(factor3, atrPeriod3)


upTrend3 = plot(direction3 < 0 ? supertrend3 : na, "Up Trend", color = color.green, style=plot.style_linebr)
downTrend3 = plot(direction3 < 0? na : supertrend3, "Down Trend", color = color.red, style=plot.style_linebr)