Hi,
looking for some help on modifying on an indicator that would draw the previous period's (month & week) high & low with a horizontal line beginning from that specified candle to the right of the chart.
The current indicator only shows the high and low levels drawn beginning at the current month (second screengrab & code below).
Desired output (white lines there for reference)
Current
looking for some help on modifying on an indicator that would draw the previous period's (month & week) high & low with a horizontal line beginning from that specified candle to the right of the chart.
The current indicator only shows the high and low levels drawn beginning at the current month (second screengrab & code below).
Desired output (white lines there for reference)
Current
Code:
input aggregationPeriod1 = aggregationPeriod.WEEK;
input aggregationPeriod2 = aggregationPeriod.MONTH;
input show_lines = yes;
input show_bubbles = yes;
input showOnlyLastPeriod = yes;
input length = 1;
input displace = -1;
input bubble_displace = 2;
def prevOpen2 = open(period = AggregationPeriod.WEEK)[-1];
def priceOpen2 = open(period = AggregationPeriod.WEEK);
plot currentOpenWeek = if !IsNaN(prevOpen2) then Double.NaN else priceOpen2;
currentOpenWeek.SetDefaultColor(Color.CYAN);
currentOpenWeek.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
plot aggPer1High;
plot aggPer1Low;
#fill next next AggPeriod1 with previous period High
def DH1 = HighestAll(if IsNaN(close(period = aggregationPeriod1)[-1]) and !IsNaN(close(period=aggregationPeriod1))
then high(period = aggregationPeriod1)[length]
else Double.NaN);
#fill next next AggPeriod1 with previous period Low
def DL1 = LowestAll(if IsNaN(close[-1]) and !IsNaN(close)
then low(period = aggregationPeriod1)[length]
else Double.NaN);
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod1)[-1]) {
aggPer1High = Double.NaN;
aggPer1Low = Double.NaN;
} else {
aggPer1High = DH1;
aggPer1Low = DL1;
}
aggPer1High.SetDefaultColor(GetColor(4));
aggPer1High.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
aggPer1High.SetHiding(!show_lines);
aggPer1Low.SetDefaultColor(GetColor(4));
aggPer1Low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
aggPer1Low.SetHiding(!show_lines);
def bn = BarNumber();
#AddChartBubble(show_bubbles and bn == HighestAll(bn - bubble_displace), aggPer1High, "w " + Astext(aggPer1High), Color.Light_GREEN);
#AddChartBubble(show_bubbles and bn == HighestAll(bn - bubble_displace), aggPer1Low, "w " + Astext(aggPer1Low), Color.light_RED);
def prevOpen1 = open(period = AggregationPeriod.MONTH)[-1];
def priceOpen1 = open(period = AggregationPeriod.MONTH);
plot currentOpenMonth = if !IsNaN(prevOpen1) then Double.NaN else priceOpen1;
currentOpenMonth.SetDefaultColor(Color.YELLOW);
currentOpenMonth.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
plot aggPer2High;
plot aggPer2Low;
def DH2 = if IsNaN(close(period = aggregationPeriod2)[-1])
then DH2[1]
else Highest(high(period = aggregationPeriod2)[-displace], length);
def DL2 = if IsNaN(close(period = aggregationPeriod2)[-1])
then DL2[1]
else Lowest(low(period = aggregationPeriod2)[-displace], length);
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod2)[-1])
{
aggPer2High = Double.NaN;
aggPer2Low = Double.NaN;
}
else {
aggPer2High = DH2;
aggPer2Low = DL2;
}
aggPer2High.SetDefaultColor(GetColor(4));
aggPer2High.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
aggPer2High.SetHiding(!show_lines);
aggPer2Low.SetDefaultColor(GetColor(4));
aggPer2Low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
aggPer2Low.SetHiding(!show_lines);
#
AddChartBubble(
show_bubbles and bn == HighestAll(bn - bubble_displace),
aggPer2High,
"m" + AsText(aggPer2High),
createColor(0,153,255),yes
);
#AddChartBubble(
# show_bubbles and bn == HighestAll(bn - bubble_displace),
# aggPer1High,
# "w" + AsText(aggPer1High),
# createColor(0,153,153),no
#);
#AddChartBubble(
# show_bubbles and bn == HighestAll(bn - bubble_displace),
# aggPer1low,
# "w" + AsText(aggPer1Low),
# createColor(153,0,255),yes
#);
AddChartBubble(
show_bubbles and bn == HighestAll(bn - bubble_displace),
aggPer2Low,
"m " + AsText(aggPer2Low),
createColor(153,0,255),no
);