input periodsback = 1;
def HD = if IsNaN(close) then HD[1] else high(period = "DAY")[periodsback];
def LD = if IsNaN(close) then LD[1] else low(period = "DAY" )[periodsback];
plot HighD = if IsNaN(high(period = "DAY")[-1]) then HD else Double.NaN;
plot LowD = if IsNaN(low(period = "DAY")[-1]) then LD else Double.NaN;
HighD.SetDefaultColor (Color.GREEN);
HighD.SetPaintingStrategy(PaintingStrategy.DASHES);
LowD.SetDefaultColor(Color.RED);
LowD.SetPaintingStrategy(PaintingStrategy.DASHES);
def HW = if IsNaN(close) then HW[1] else high(period = "WEEK" )[periodsback];
def LW = if IsNaN(close) then LW[1] else low(period = "WEEK" )[periodsback];
plot HighW = if IsNaN(high(period = "WEEK")[-1]) then HW else Double.NaN;
plot LowW = if IsNaN(low(period = "WEEK")[-1]) then LW else Double.NaN;
HighW.SetDefaultColor (Color.GREEN);
HighW.SetPaintingStrategy(PaintingStrategy.DASHES);
LowW.SetDefaultColor(Color.RED);
LowW.SetPaintingStrategy(PaintingStrategy.DASHES);
def HM = if IsNaN(close) then HM[1] else high(period = "MONTH" )[periodsback];
def LM = if IsNaN(close) then LM[1] else low(period = "MONTH" )[periodsback];
plot HighM = if IsNaN(high(period = "MONTH")[-1]) then HM else Double.NaN;
plot LowM = if IsNaN(low(period = "MONTH")[-1]) then LM else Double.NaN;
HighM.SetDefaultColor (Color.GREEN);
HighM.SetPaintingStrategy(PaintingStrategy.DASHES);
LowM.SetDefaultColor(Color.RED);
LowM.SetPaintingStrategy(PaintingStrategy.DASHES);
def HQ = if IsNaN(close) then HQ[1] else high(period = "QUARTER" )[periodsback];
def LQ = if IsNaN(close) then LQ[1] else low(period = "QUARTER" )[periodsback];
plot HighQ = if IsNaN(high(period = "QUARTER")[-1]) then HQ else Double.NaN;
plot LowQ = if IsNaN(low(period = "QUARTER")[-1]) then LQ else Double.NaN;
HighQ.SetDefaultColor (Color.GREEN);
HighQ.SetPaintingStrategy(PaintingStrategy.DASHES);
LowQ.SetDefaultColor(Color.RED);
LowQ.SetPaintingStrategy(PaintingStrategy.DASHES);
def HY = if IsNaN(close) then HY[1] else high(period = "YEAR" )[periodsback];
def LY = if IsNaN(close) then LY[1] else low(period = "YEAR" )[periodsback];
plot HighY = if IsNaN(high(period = "YEAR")[-1]) then HY else Double.NaN;
plot LowY = if IsNaN(low(period = "YEAR")[-1]) then LY else Double.NaN;
HighY.SetDefaultColor (Color.GREEN);
HighY.SetPaintingStrategy(PaintingStrategy.DASHES);
LowY.SetDefaultColor(Color.RED);
LowY.SetPaintingStrategy(PaintingStrategy.DASHES);
input bubbles = yes;
input Highbubblemover = 2;
def b = Highbubblemover;
def b1 = b + 1;
input Lowbubblemover = 7;
def bm = Lowbubblemover;
def bm1 = bm + 1;
AddChartBubble(bubbles and IsNaN(close[b]) and !IsNaN(close[b1]) and
HighD[b1], HighD[b1], "HD\n" + AsText(HighD[b1]), HighD.TakeValueColor());
AddChartBubble(bubbles and IsNaN(close[bm]) and !IsNaN(close[bm1]) and
LowD[bm1], LowD[bm1], "LD\n" + AsText(LowD[bm1]), LowD.TakeValueColor(), no);
AddChartBubble(bubbles and IsNaN(close[b]) and !IsNaN(close[b1]) and
HighW[b1], HighW[b1], "HW\n" + AsText(HighW[b1]), HighW.TakeValueColor());
AddChartBubble(bubbles and IsNaN(close[bm]) and !IsNaN(close[bm1]) and
LowW[bm1], LowW[bm1], "LW\n" + AsText(LowW[bm1]), LowW.TakeValueColor(), no);
AddChartBubble(bubbles and IsNaN(close[b]) and !IsNaN(close[b1]) and
HighM[b1], HighM[b1], "HM\n" + AsText(HighM[b1]), HighM.TakeValueColor());
AddChartBubble(bubbles and IsNaN(close[bm]) and !IsNaN(close[bm1]) and
LowM[bm1], LowM[bm1], "LM\n" + AsText(LowM[bm1]), LowM.TakeValueColor(), no);
AddChartBubble(bubbles and IsNaN(close[b]) and !IsNaN(close[b1]) and
HighQ[b1], HighQ[b1], "HQ\n" + AsText(HighQ[b1]), HighQ.TakeValueColor());
AddChartBubble(bubbles and IsNaN(close[bm]) and !IsNaN(close[bm1]) and
LowQ[bm1], LowQ[bm1], "LQ\n" + AsText(LowQ[bm1]), LowQ.TakeValueColor(), no);
AddChartBubble(bubbles and IsNaN(close[b]) and !IsNaN(close[b1]) and
HighY[b1], HighY[b1], "HY\n" + AsText(HighY[b1]), HighY.TakeValueColor());
AddChartBubble(bubbles and IsNaN(close[bm]) and !IsNaN(close[bm1]) and
LowY[bm1], LowY[bm1], "LY\n" + AsText(LowY[bm1]), LowY.TakeValueColor(), no);