Dollar Index (DXY) Candles [Loxx]
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx

//@version=5
indicator("Dollar Index (DXY) Candles [Loxx]",
     shorttitle="DXYC [Loxx]",
     overlay = true, 
     timeframe="", 
     timeframe_gaps = true)

greencolor = #2DD204  
redcolor = #D2042D 

eurc = request.security("EURUSD", "", close)
euro = request.security("EURUSD", "", open)
eurh = request.security("EURUSD", "", high)
eurl = request.security("EURUSD", "", low)

jpyc = request.security("JPYUSD", "", close)
jpyo = request.security("JPYUSD", "", open)
jpyh = request.security("JPYUSD", "", high)
jpyl = request.security("JPYUSD", "", low)

gbpc = request.security("GBPUSD", "", close)
gbpo = request.security("GBPUSD", "", open)
gbph = request.security("GBPUSD", "", high)
gbpl = request.security("GBPUSD", "", low)

cadc = request.security("CADUSD", "", close)
cado = request.security("CADUSD", "", open)
cadh = request.security("CADUSD", "", high)
cadl = request.security("CADUSD", "", low)

sekc = request.security("SEKUSD", "", close)
seko = request.security("SEKUSD", "", open)
sekh = request.security("SEKUSD", "", high)
sekl = request.security("SEKUSD", "", low)

chfc = request.security("CHFUSD", "", close)
chfo = request.security("CHFUSD", "", open)
chfh = request.security("CHFUSD", "", high)
chfl = request.security("CHFUSD", "", low)

dxyClose = 50.14348112 * math.pow(eurc, -0.576) * math.pow(jpyc, 0.136) * math.pow(gbpc, -0.119) * math.pow(cadc, 0.091) * math.pow(sekc, 0.042) * math.pow(chfc, 0.036)
dxyOpen =  50.14348112 * math.pow(euro, -0.576) * math.pow(jpyo, 0.136) * math.pow(gbpo, -0.119) * math.pow(cado, 0.091) * math.pow(seko, 0.042) * math.pow(chfo, 0.036)
dxyHigh =  50.14348112 * math.pow(eurh, -0.576) * math.pow(jpyh, 0.136) * math.pow(gbph, -0.119) * math.pow(cadh, 0.091) * math.pow(sekh, 0.042) * math.pow(chfh, 0.036)
dxyLow =   50.14348112 * math.pow(eurl, -0.576) * math.pow(jpyl, 0.136) * math.pow(gbpl, -0.119) * math.pow(cadl, 0.091) * math.pow(sekl, 0.042) * math.pow(chfl, 0.036)

plotcandle(dxyOpen, dxyHigh, dxyLow, dxyClose, title='Title', color = dxyOpen < dxyClose ? greencolor : redcolor, wickcolor=color.black)