Deflated - Val
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Makaveli227

//@version=5
indicator("Deflated", overlay=true)
i_date = input.time(timestamp("20 Jul 2021 00:00 +0300"), "Date", confirm = true)
EU_inflation = request.security("QUANDL:ECB/RTD_M_S0_N_P_C_OV_X", "D", close)
US_inflation = request.security("QUANDL:RATEINF/CPI_USA", "D", close)

var Origin_BASE = 0.0
var Origin_EU = 0.0
var Origin_US = 0.0
if time > i_date // GET ORIGIN VALUE
    var oc = close
    Origin_BASE := oc
    if EU_inflation != 0
        var c = EU_inflation//close
	    Origin_EU := c
	if US_inflation != 0
	    var c = US_inflation//close
	    Origin_US := c
//////////////////////// EU
Ratio_EU = Origin_EU / EU_inflation
if Ratio_EU == 0
    Ratio_EU := na
Deflat_EU = close * Ratio_EU
plot(Deflat_EU, "EURO", color.blue)
//////////////////////// US
Ratio_US = Origin_US / US_inflation
if Ratio_US == 0
    Ratio_US := na
Deflat_US = close * Ratio_US
p = plot(Deflat_US, "USA", color.red)

l = label.new(i_date, Origin_BASE, "From", xloc=xloc.bar_time, color=color.rgb(255, 200, 200, 50), yloc = yloc.price)
label.delete(l[1])
//line.new(i_date, Origin_BASE-100, i_date, Origin_BASE+100, xloc=xloc.bar_time)//, extend.both)