Anyone can help fix the code below by adding Weekly changes? Thank you.
# YTD Return
# Mobius
# 06.15.2015
declare hide_on_intraday;
input price = close;
input length = 1;
input displace = 0;
input Show_Labels = yes;
def newyear = if getYear() != getYear()[1] then 1 else 0;
def newmonth = if getMonth() != getMonth()[1] then 1 else 0;
def yo = compoundValue(1, if newyear then open else yo[1], open);
def mo = compoundValue(1, if newmonth then open else mo[1], open);
def yearopen = yo;
def monthopen = mo;
def SMA = Average(price[-displace], length);
def yochange = (sma - yearopen) / yearopen ;
def mochange = (close - monthopen) / monthopen;
AddLabel(Show_Labels, concat("Year % change = ", AsPercent(yochange)), color.white);
AddLabel(Show_Labels, "Month % change = " + (AsPercent(mochange)), color.white);
# YTD Return
# Mobius
# 06.15.2015
declare hide_on_intraday;
input price = close;
input length = 1;
input displace = 0;
input Show_Labels = yes;
def newyear = if getYear() != getYear()[1] then 1 else 0;
def newmonth = if getMonth() != getMonth()[1] then 1 else 0;
def yo = compoundValue(1, if newyear then open else yo[1], open);
def mo = compoundValue(1, if newmonth then open else mo[1], open);
def yearopen = yo;
def monthopen = mo;
def SMA = Average(price[-displace], length);
def yochange = (sma - yearopen) / yearopen ;
def mochange = (close - monthopen) / monthopen;
AddLabel(Show_Labels, concat("Year % change = ", AsPercent(yochange)), color.white);
AddLabel(Show_Labels, "Month % change = " + (AsPercent(mochange)), color.white);