# This script draws levels based on percentage off high high on the chart.
# Mostly to be used on daily charts, but can below used on any other chart
# Brian Watt's brain child.
input percentOffset1 = 1;
input percentOffset2 = 2;
input percentOffset3 = 3;
input percentOffset4 = 5;
input percentOffset5 = 8;
input userDefinedHigh = 0;
input overideChartHigh = no;
input disableBubbles = no;
def highestHigh = if overideChartHigh then userDefinedHigh else highestAll(high);
plot hh = highestHigh;
hh.setDefaultColor(Color.white);
hh.setPaintingStrategy(PaintingStrategy.LINE);
def bubbleOffset = if high != highestAll(high) then bubbleOffset[1]+1 else bubbleOffset[1];
#addChartBubble(highestHigh == high, high, "HH", Color.white);
plot hhOffset1 = highestHigh * (1- percentOffset1/100);
hhoffset1.setDefaultColor(Color.Green);
hhOffset1.setPaintingStrategy(PaintingStrategy.LINE);
addChartBubble(!disableBubbles and bubbleOffset == bubbleoffset[1] ,hhOffset1, percentOffset1 + "%", Color.yellow);
plot hhOffsetUp1 = highestHigh * (1+ percentOffset1/100);
hhoffsetUp1.setDefaultColor(Color.yellow);
hhOffsetUp1.setPaintingStrategy(PaintingStrategy.LINE);
addChartBubble(!disableBubbles and bubbleOffset == bubbleoffset[1] ,hhOffsetUp1, percentOffset1 + "%", Color.yellow);
plot hhOffset2 = highestHigh * (1- percentOffset2/100);
hhoffset2.setDefaultColor(Color.Light_Green);
hhOffset2.setPaintingStrategy(PaintingStrategy.LINE);
addChartBubble(!disableBubbles and bubbleOffset == bubbleoffset[1] ,hhOffset2, percentOffset2 + "%", Color.yellow);
plot hhOffsetUp2 = highestHigh * (1+ percentOffset2/100);
hhoffsetUp2.setDefaultColor(Color.Light_Green);
hhOffsetUp2.setPaintingStrategy(PaintingStrategy.LINE);
addChartBubble(!disableBubbles and bubbleOffset == bubbleoffset[1] ,hhOffsetUp2, percentOffset2 + "%", Color.yellow);
plot hhOffset3 = highestHigh * (1- percentOffset3/100);
hhoffset3.setDefaultColor(Color.Yellow);
hhOffset3.setPaintingStrategy(PaintingStrategy.Line);
addChartBubble(!disableBubbles and bubbleOffset == bubbleoffset[1] ,hhOffset3, percentOffset3 + "%", Color.Yellow);
plot hhOffsetUp3 = highestHigh * (1+ percentOffset3/100);
hhoffsetUp3.setDefaultColor(Color.Yellow);
hhOffsetUp3.setPaintingStrategy(PaintingStrategy.Line);
addChartBubble(!disableBubbles and bubbleOffset == bubbleoffset[1] ,hhOffsetUp3, percentOffset3 + "%", Color.Yellow);
plot hhOffset4 = highestHigh * (1- percentOffset4/100);
hhoffset4.setDefaultColor(Color.Orange);
hhOffset4.setPaintingStrategy(PaintingStrategy.Line);
addChartBubble(!disableBubbles and bubbleOffset == bubbleoffset[1] ,hhOffset4, percentOffset4 + "%", Color.Orange);
plot hhOffsetUp4 = highestHigh * (1+ percentOffset4/100);
hhoffsetUp4.setDefaultColor(Color.Orange);
hhOffsetUp4.setPaintingStrategy(PaintingStrategy.Line);
addChartBubble(!disableBubbles and bubbleOffset == bubbleoffset[1] ,hhOffsetUp4, percentOffset4 + "%", Color.Orange);
plot hhOffset5 = highestHigh * (1- percentOffset5/100);
hhoffset5.setDefaultColor(Color.green);
hhOffset5.setPaintingStrategy(PaintingStrategy.LINE);
addChartBubble(!disableBubbles and bubbleOffset == bubbleoffset[1] ,hhOffset5, percentOffset5 + "%", Color.yellow);
plot hhOffsetUp5 = highestHigh * (1+ percentOffset5/100);
hhoffsetUp5.setDefaultColor(Color.green);
hhOffsetUp5.setPaintingStrategy(PaintingStrategy.LINE);
addChartBubble(!disableBubbles and bubbleOffset == bubbleoffset[1] ,hhOffsetUp5, percentOffset5 + "%", Color.yellow);