I have a custom indicator (below) that I call the Intra year High Low Opening Range ...its calculating the Higest High and Lowest Low that prints during the first 3 weeks of any new calendar year,,,and then plots these values across the charts until these values change the following calendar year. I am trying to have the results of this indicator(a high and low plot value that persists for each year until the next year time period completes) plot in any time frame that I view a chart....,especially daily and weekly time frames which is what I use most. As it works now, it displays the correct values in daily charts but it does not display/persist in weekly charts-it disappears.
input numberdays = 12;
input secondAggregation = AggregationPeriod.DAY;
def agg = AggregationPeriod.DAY;
def hl1bn = if GetYear() != GetYear()[1]
then BarNumber()
else hl1bn[1];
def h1 = if BarNumber() == hl1bn
then high(period = agg)
else if Between(BarNumber(), hl1bn, ((hl1bn) + numberdays))
and high(period = agg) > h1[1]
then high(period = agg)
else h1[1];
def l1 = if BarNumber() == hl1bn
then low(period = agg)
else if Between(BarNumber(), hl1bn, (hl1bn + numberdays))
and low(period = agg) < l1[1]
then low(period = agg)
else l1[1];
plot InsiideintrayearH = if BarNumber() >= (hl1bn + numberdays) then h1 else Double.NaN;
plot InsiideintrayearL = if BarNumber() >= (hl1bn + numberdays) then l1 else Double.NaN;
AddLabel(1, AsPrice(GetYear()) + ":" + " Intra_Year High: " + Round( h1,2) + " Intra_Year Low: " + Round( l1,2), if close > h1 then Color.GREEN else if close < l1 then Color.RED else Color.YELLOW);
Alert(close <= InsiideintrayearL, " Intramonh Breakout Down", Alert.BAR, Sound.Bell);
Alert(close >= InsiideintrayearH, " Intramonh Breakout Up", Alert.BAR, Sound.Bell);
input numberdays = 12;
input secondAggregation = AggregationPeriod.DAY;
def agg = AggregationPeriod.DAY;
def hl1bn = if GetYear() != GetYear()[1]
then BarNumber()
else hl1bn[1];
def h1 = if BarNumber() == hl1bn
then high(period = agg)
else if Between(BarNumber(), hl1bn, ((hl1bn) + numberdays))
and high(period = agg) > h1[1]
then high(period = agg)
else h1[1];
def l1 = if BarNumber() == hl1bn
then low(period = agg)
else if Between(BarNumber(), hl1bn, (hl1bn + numberdays))
and low(period = agg) < l1[1]
then low(period = agg)
else l1[1];
plot InsiideintrayearH = if BarNumber() >= (hl1bn + numberdays) then h1 else Double.NaN;
plot InsiideintrayearL = if BarNumber() >= (hl1bn + numberdays) then l1 else Double.NaN;
AddLabel(1, AsPrice(GetYear()) + ":" + " Intra_Year High: " + Round( h1,2) + " Intra_Year Low: " + Round( l1,2), if close > h1 then Color.GREEN else if close < l1 then Color.RED else Color.YELLOW);
Alert(close <= InsiideintrayearL, " Intramonh Breakout Down", Alert.BAR, Sound.Bell);
Alert(close >= InsiideintrayearH, " Intramonh Breakout Up", Alert.BAR, Sound.Bell);