Pair Viewer
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © elio27

//@version=5
indicator("Pair Viewer", overlay=false, precision=8, max_lines_count=500)

// Inputs
sym1 = input.symbol(defval="", title="Ticker #1", confirm=true)
sym2 = input.symbol(defval="", title="Ticker #2", confirm=true)
view = input.string(defval="Candles", title="View as", options=["Candles", "HLOC Cloud"])
upColor = input.color(defval=#089981, title="Up color")
downColor = input.color(defval=#F23645, title="Down color")

// Main Process
pair = str.format("{0}/{1}", sym1, sym2)        // Formatting the pair as "Ticker1 / Ticker2"
pairH = request.security(pair, timeframe.period, high)      // High of Pair on current candle
pairL = request.security(pair, timeframe.period, low)       // Low of Pair on current candle
pairO = request.security(pair, timeframe.period, open)      // Open of Pair on current candle
pairC = request.security(pair, timeframe.period, close)     // Close of Pair on current candle

barColor = pairC > pairO ? upColor : downColor      // Color selection helper

// Ouptut methods

// Candle Visualization
if view == "Candles"
    line.new(x1=bar_index, x2=bar_index, y1=pairO, y2=pairC, width=5, color = barColor)     // Candle Body
    line.new(x1=bar_index, x2=bar_index, y1=pairL, y2=pairH, width=1, color = barColor)     // Candle Wick

// Cloud Visualization
cloud = view == "HLOC Cloud"        // Boolean simplification
highLine = plot(cloud ? pairH : na, color=color.white, title="Cloud : High Line")
lowLine = plot(cloud ? pairL : na, color=color.white, title="Cloud : Low Line")
plot(pairC, color=cloud ? barColor : color.new(barColor,100), linewidth=2, title="Cloud : Close Line")
fill(lowLine, highLine, color=color.new(barColor, 80), title="Cloud : Background Color")

var output = line.new(x1=bar_index,x2=bar_index,y1=close,y2=close,color=color.red, style=line.style_dotted, extend=extend.right)
line.set_color(output, barColor)
line.set_x1(output, bar_index)
line.set_x2(output, bar_index+1)
line.set_y1(output, pairC)
line.set_y2(output, pairC)