# On Pace for % on year?

#### eugchen

##### Member
anyway to create a chart label for on pace for year? for instance, lets say AAPL is up 1% on jan 31. this would have Year gains to be on pace for 12%.

so the formula would be something like this...

(((close-year start price)/year start price)/days so far this year)*365

(close-year start price)/year start price) is basically a YTD performance label.
i dont know how to get "days so far this year). so for Jan 31, need that value to be 31.

this is my code below for YTD.

input price = close;
input length = 1;
input displace = 0;
input Show_Labels = yes;

def newyear = if getYear() != getYear() then 1 else 0;
def yo = compoundValue(1, if newyear then open else yo, open);
def yearopen = yo;
def SMA = Average(price[-displace], length);
def yochange = (sma - yearopen) / yearopen ;

if anyone can help, i appreciate it!

##### Well-known member
VIP
@eugchecn I don't have time to look deep into this issue but thought I should mention that there are 252 trading days in a year, not 365... Charts are based on trading days, not calendar days...

yea true.

#### eugchen

##### Member
For those interested, i was able to get someone at TOS to help me the code. check it out!

def YearOpen = if GetYear() != GetLastYear() then close else YearOpen;

def value = Round(100 * ((close - YearOpen) / YearOpen), 2);

def yearstart = GetYear() * 10000 + 101;

def value2 = round(100 *((((close - YearOpen) / YearOpen) / daysFromDate)*daystillDate));

AddLabel(yes, "Year Pace: " + value2 + "%", if value2 == 0

then Color.LIGHT_GRAY

else if value2 > 0

then CreateColor(51, 204, 0)

else Color.RED);

• 