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

//@version=5
indicator("XAUXXX")
metal=input.string("XAU",title="Precious Metal",options=["XAU","XAG","XPT"])                                                                                // Precious metal selection (Gold,Silver,Platinum)
[gold_O,gold_H,gold_L,gold_C]=request.security(metal+"USD",timeframe.period,[open,high,low,close])                                                          // OHLC data of Precious metal priced in USD for long term historical data
str=input.string( "CAD","Desired Currency Prefix",options=["CAD","EUR","JPY","GBP","SEK","AUD","NZD","CHF","INR","CNY","HKD","BRL","MXN","TRY","ZAR","RON"])// 3 Letter currency identifier selection
pair="USD"+str                                                                                                                                              // string for FX pair of USD in selected currency
[fx_O,fx_H,fx_L,fx_C]=request.security(pair    ,timeframe.period,[open,high,low,close])                                                                     // OHLC data for fx pair 

o=fx_O*gold_O                                                                                                                                               // \      OHLC data from the selected metal is multiplied 
h=fx_H*gold_H                                                                                                                                               //  \ _     by the corresponding fx OHLC data to get the 
l=fx_L*gold_L                                                                                                                                               //  /       price of selected precious metal in the desired 
c=fx_C*gold_C                                                                                                                                               // /        currency
                                                                                                                                       
color=o<c?input.color(#acfb00,"Up Candle Color"):input.color(#ff0000,"Down Candle Color")                                                               // Color for use in plotting of candles
plotcandle(o,h,l,c,"Metal Price", color=color,wickcolor=color,bordercolor=color)                                                                             // Plot Candle using the products from multiplying gold OHLC by fx OHLC