Goal:
I'm trying to build a daily seasonality trend script..
Problem:
I normalized each day's close relative to the year's high and low so every day has a value between 0 and 1. Now I'm trying to figure out how to average the same day in previous years to get multiyear average value of the scaled daily close, can't figure this out for the life of me.
End goal is to plot a 15 year (or whatever look back) seasonality graph on the daily TF.
Here is what I have so far, this plots each completed year's trend with each day's value relative to that year's high (1) and low (0). Now I'm trying to figure out how to get the scaledClose variable to represent a multiyear average value instead of just single years.
current_year = input(2020, title="Current Year")
scaledClose = 0.0
yearHigh = security(syminfo.tickerid, "12M", high, lookahead=true)
yearLow = security(syminfo.tickerid, "12M", low, lookahead=true)
if year < current_year
scaledClose := (close - yearLow) / (yearHigh - yearLow)
plot(scaledClose)