In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.
study(title="GOLD/SILVER", shorttitle="GOLD/SILVER", overlay=false) //inputs Sec1Input = input(defval="XAUUSD", title="First security", type=symbol, confirm=true) Sec2Input = input(defval="XAGUSD", title="Second security", type=symbol, confirm=true) //logic sec(s) => security(s, period, close) ratio = (sec(Sec1Input) / sec(Sec2Input)) //plot plot(ratio, color=red, linewidth=3)