input TakeProfitPct = .5; #hint, 1 is 1 pct, .5 is 1/2 percent, etc
def takeprofitconverstionLong = 1 + (TakeProfitPct / 100);
AddLabel(1, (takeprofitconverstionLong * close) - close, Color.WHITE);
def takeprofitconverstionshort = 1 - (TakeProfitPct / 100);
AddLabel(1, (takeprofitconverstionshort * close) - close, Color.WHITE);
def bn = BarNumber();
def Latest_bar = if IsNaN(close[-1]) then bn else Latest_bar[1];
def HourH = high(period = AggregationPeriod.HOUR);
def HourL = low(period = AggregationPeriod.HOUR);
def HourH1ba = high(period = AggregationPeriod.HOUR)[1];
def HourL1ba = low(period = AggregationPeriod.HOUR)[1];
def hourlong = close > HourH1ba;
def hourshort = close < HourL1ba;
input Major_bubbleoffset = .0005;
input Major_percentamount = .15;
input Major_revAmount = .2;
input Major_atrreversal = 3.75;
input Major_atrlength = 5;
def zz = ZigZagHighLow("price h" = high, "price l" = low, "percentage reversal" = Major_percentamount, "absolute reversal" = Major_revAmount, "atr length" = Major_atrlength, "atr reversal" = Major_atrreversal);
def reversalAmount = if (close * Major_percentamount / 100) > Max(Major_revAmount < Major_atrreversal * Major_atrlength, Major_revAmount) then (close * Major_percentamount / 100) else if Major_revAmount < Major_atrreversal * Major_atrlength then Major_atrreversal * Major_atrlength else Major_revAmount;
rec zzSave = if !IsNaN(zz) then zz else GetValue(zzSave, 1);
def chg = (if zzSave == high then high else low) - GetValue(zzSave, 1);
def isUp = chg >= 0;
rec isConf = AbsValue(chg) >= reversalAmount or (IsNaN(GetValue(zz, 1)) and GetValue(isConf, 1));
def zzd = if isUp then 1 else 0;
plot zzp = if zzd <= 1 then zz else Double.NaN;
zzp.AssignValueColor(if zzd == 1 then Color.GREEN else if zzd == 0 then Color.RED else Color.DARK_ORANGE);
zzp.SetStyle(Curve.FIRM);
zzp.EnableApproximation();
zzp.SetLineWeight(1);
#Price Change between zigzags
def xxhigh = if zzSave == high then high else xxhigh[1];
def chghigh = high - xxhigh[1];
def xxlow = if zzSave == low then low else xxlow[1];
def chglow = low - xxlow[1];
input showMagnitudeBubbles = yes;
AddChartBubble(showMagnitudeBubbles and !IsNaN(zz) and BarNumber() != 1, if isUp then high * (1 + Major_bubbleoffset) else low * (1 - Major_bubbleoffset) , "$" + chg , if isUp and chghigh > 0 then Color.GREEN else if isUp and chghigh < 0 then Color.RED else if isUp then Color.YELLOW else if !isUp and chglow > 0 then Color.GREEN else if !isUp and chglow < 0 then Color.RED else Color.YELLOW, isUp);
#Price at High/Low
input Major_showBubblesprice = no;
AddChartBubble(Major_showBubblesprice and !IsNaN(zz) and BarNumber() != 1, if isUp then high * (1 + Major_bubbleoffset) else low * (1 - Major_bubbleoffset) , if isUp then "$" + high else "$" + low , if isUp and chghigh > 0 then Color.GREEN else if isUp and chghigh < 0 then Color.RED else if isUp then Color.YELLOW else if !isUp and chglow > 0 then Color.GREEN else if !isUp and chglow < 0 then Color.RED else Color.YELLOW, isUp);