Two raw price series can share a pane, but sharing one price scale may flatten the smaller series. A separate scale preserves the price units. Percentage changes answer a different question: how much each asset moved over a defined interval. A ratio also has a different meaning and is not a percentage return.
Complete Pine Script v6 indicator: returns over chart barspinescript
//@version=6
indicator("Two-Symbol Rolling Returns", overlay=false, precision=2)
sec_ticker = input.symbol("NASDAQ:QQQ", "Comparison Symbol")
lookback = input.int(20, "Lookback in chart bars", minval=1)
sec_close = request.security(sec_ticker, timeframe.period, close,
gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off,
ignore_invalid_symbol=true)
pct_change(float current, float previous) =>
not na(current) and not na(previous) and previous != 0 ?
100.0 * (current / previous - 1.0) : na
chart_pct = pct_change(close, close[lookback])
sec_pct = pct_change(sec_close, sec_close[lookback])
plot(chart_pct, "Chart Return (%)", color=color.blue, linewidth=2)
plot(sec_pct, "Comparison Return (%)", color=color.orange, linewidth=2)
hline(0, "Zero Return", color=color.gray)