Can anyone please assist in creating Status Labels for this ZigZag indicator
https://usethinkscript.com/threads/zigzag-high-low-stats-for-thinkorswim.1073/
in conjunction with LBR_ThreeTenOscillator:
When ZigZag and LBR_ThreeTenOscillator are in agreement (both bullish), a Green Status Label plots that says: Confirmed
When ZigZag and LBR_ThreeTenOscillator are in agreement (both bearish), a Red Status Label plots that says: Confirmed
When ZigZag and LBR_ThreeTenOscillator are not in agreement, an Orange Status Label plots that says: Unconfirmed
The code for both indicators is below. Thanks very much in advance for any assistance!
# LBR_ThreeTenOscillator
declare lower;
input price = close;
input calculationMode = {default Normal, Alternate};
plot FastLine;
switch (calculationMode) {
case Normal:
FastLine = Average(price, 3) - Average(price, 10);
case Alternate:
FastLine = Average(price - Average(price[3], 3), 2);
}
plot SlowLine = Average(FastLine, 16);
plot Hist = FastLine;
plot ZeroLine = 0;
FastLine.SetDefaultColor(GetColor(1));
SlowLine.SetDefaultColor(GetColor(8));
Hist.DefineColor("Positive", Color.UPTICK);
Hist.DefineColor("Negative", Color.DOWNTICK);
Hist.AssignValueColor(if Hist >= 0 then Hist.color("Positive") else Hist.color("Negative"));
Hist.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Hist.HideTitle();
ZeroLine.SetDefaultColor(GetColor(7));
# ZigZag High Low Stats
# tomsk
# 11.16.2019
# V1.0 - 11.16.2019 - tomsk - Initial release of ZigZag High Low Stats
# Extracted idea from RDMercer's post #369 of a variant of a massive
# Zig Zag High Low Supply Demand study that comprises many different
# components
#
# https://usethinkscript.com/threads/...-signals-for-thinkorswim.183/page-19#post-369
#
# I heavily modified, cleaned up and extracted some interesting Zig Zag statistical information resulting in this study called Zig Zag High
# Low Stats. It displays the following information represented via bubbles at each of the Zig zag turning points
#
# Label for Confirmed/Unconfirmed Status of Current Zigzag
# Price Change between Zigzags
# Price at Zigzag High/Low
# Bar Count between Zigzags
# Volume at Zigzag Reversals
input showBubblesChange = no; # Price Change between Zigzags
input showBubblesPrice = no; # Price at Zigzag High/Low
input showBubblesBarCount = no; # Bar Count between Zigzags
input showBubblesVolume = no; # Volume at Zigzag Reversals
input BubbleOffset = .0005;
input PercentAmount = .01;
input RevAmount = .05;
input ATRreversal = 3.0;
input ATRlength = 5;
def zz = ZigZagHighLow("price h" = high, "price l" = low, "percentage reversal" = PercentAmount,
"absolute reversal" = RevAmount, "atr length" = ATRlength, "atr reversal" = ATRreversal);
def ReversalAmount = if (close * PercentAmount / 100) > Max(RevAmount < ATRreversal * reference ATR(ATRlength), RevAmount)
then (close * PercentAmount / 100)
else if RevAmount < ATRreversal * reference ATR(ATRlength)
then ATRreversal * reference ATR(ATRlength)
else RevAmount;
# Zig Zag Specific Data
def 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;
def isConf = AbsValue(chg) >= ReversalAmount or (IsNaN(GetValue(zz, 1)) and GetValue(isConf, 1));
# Price Change Specific Data
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];
# Bar Count Specific Data
def zzCount = if zzSave[1] != zzSave then 1 else if zzSave[1] == zzSave then zzCount[1] + 1 else 0;
def zzCountHiLo = if zzCountHiLo[1] == 0 and (zzSave == high or zzSave == low) then 1
else if zzSave == high or zzSave == low then zzCountHiLo[1] + 1
else zzCountHiLo[1];
def zzHiLo = if zzSave == high or zzSave == low then zzCountHiLo else zzCountHiLo + 1;
def zzCountHigh = if zzSave == high then zzCount[1] else Double.NaN;
def zzCountLow = if zzSave == low then zzCount[1] else Double.NaN;
# Volume Specific Data
def vol = if BarNumber() == 0 then 0 else volume + vol[1];
def vol1 = if BarNumber() == 1 then volume else vol1[1];
def xxVol = if zzSave == high or zzSave == low then TotalSum(volume) else xxVol[1];
def chgVol = if xxvol - xxVol[1] + vol1 == vol then vol else xxVol - xxVol[1];
# Zig Zag Plot
plot zzp = if isUp <= 1 then zz else Double.NaN;
zzp.AssignValueColor(if isUp then Color.Green else if !isUp then Color.Red else Color.Dark_Orange);
zzp.SetStyle(Curve.FIRM);
zzp.EnableApproximation();
zzp.HideBubble();
# Bubbles
# Price Change between Zigzags
AddChartBubble(showBubblesChange and !IsNaN(zz) and BarNumber() != 1, if isUp then high * (1 + BubbleOffset) else low * (1 - BubbleOffset), "$" + Round(chg, 2), 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 Zigzag High/Low
AddChartBubble(showBubblesPrice and !IsNaN(zz) and BarNumber() != 1, if isUp then high * (1 + BubbleOffset) else low * (1 - 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);
# Bar Count between Zigzags
AddChartBubble(showBubblesBarCount and !IsNaN(zz) and BarNumber() != 1, if isUp then high * (1 + BubbleOffset) else low * (1 - BubbleOffset), if zzSave == high then zzCountHigh else zzCountLow, 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, if isUp then yes else no);
# Volume at Zigzag Reversals
AddChartBubble(showBubblesVolume and !IsNaN(zz) and BarNumber() != 1, if isUp then high * (1 + bubbleoffset) else low * (1 - bubbleoffset), chgVol, 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, if isUp then yes else no);
# End ZigZag High Low Stats
https://usethinkscript.com/threads/zigzag-high-low-stats-for-thinkorswim.1073/
in conjunction with LBR_ThreeTenOscillator:
When ZigZag and LBR_ThreeTenOscillator are in agreement (both bullish), a Green Status Label plots that says: Confirmed
When ZigZag and LBR_ThreeTenOscillator are in agreement (both bearish), a Red Status Label plots that says: Confirmed
When ZigZag and LBR_ThreeTenOscillator are not in agreement, an Orange Status Label plots that says: Unconfirmed
The code for both indicators is below. Thanks very much in advance for any assistance!
# LBR_ThreeTenOscillator
declare lower;
input price = close;
input calculationMode = {default Normal, Alternate};
plot FastLine;
switch (calculationMode) {
case Normal:
FastLine = Average(price, 3) - Average(price, 10);
case Alternate:
FastLine = Average(price - Average(price[3], 3), 2);
}
plot SlowLine = Average(FastLine, 16);
plot Hist = FastLine;
plot ZeroLine = 0;
FastLine.SetDefaultColor(GetColor(1));
SlowLine.SetDefaultColor(GetColor(8));
Hist.DefineColor("Positive", Color.UPTICK);
Hist.DefineColor("Negative", Color.DOWNTICK);
Hist.AssignValueColor(if Hist >= 0 then Hist.color("Positive") else Hist.color("Negative"));
Hist.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Hist.HideTitle();
ZeroLine.SetDefaultColor(GetColor(7));
# ZigZag High Low Stats
# tomsk
# 11.16.2019
# V1.0 - 11.16.2019 - tomsk - Initial release of ZigZag High Low Stats
# Extracted idea from RDMercer's post #369 of a variant of a massive
# Zig Zag High Low Supply Demand study that comprises many different
# components
#
# https://usethinkscript.com/threads/...-signals-for-thinkorswim.183/page-19#post-369
#
# I heavily modified, cleaned up and extracted some interesting Zig Zag statistical information resulting in this study called Zig Zag High
# Low Stats. It displays the following information represented via bubbles at each of the Zig zag turning points
#
# Label for Confirmed/Unconfirmed Status of Current Zigzag
# Price Change between Zigzags
# Price at Zigzag High/Low
# Bar Count between Zigzags
# Volume at Zigzag Reversals
input showBubblesChange = no; # Price Change between Zigzags
input showBubblesPrice = no; # Price at Zigzag High/Low
input showBubblesBarCount = no; # Bar Count between Zigzags
input showBubblesVolume = no; # Volume at Zigzag Reversals
input BubbleOffset = .0005;
input PercentAmount = .01;
input RevAmount = .05;
input ATRreversal = 3.0;
input ATRlength = 5;
def zz = ZigZagHighLow("price h" = high, "price l" = low, "percentage reversal" = PercentAmount,
"absolute reversal" = RevAmount, "atr length" = ATRlength, "atr reversal" = ATRreversal);
def ReversalAmount = if (close * PercentAmount / 100) > Max(RevAmount < ATRreversal * reference ATR(ATRlength), RevAmount)
then (close * PercentAmount / 100)
else if RevAmount < ATRreversal * reference ATR(ATRlength)
then ATRreversal * reference ATR(ATRlength)
else RevAmount;
# Zig Zag Specific Data
def 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;
def isConf = AbsValue(chg) >= ReversalAmount or (IsNaN(GetValue(zz, 1)) and GetValue(isConf, 1));
# Price Change Specific Data
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];
# Bar Count Specific Data
def zzCount = if zzSave[1] != zzSave then 1 else if zzSave[1] == zzSave then zzCount[1] + 1 else 0;
def zzCountHiLo = if zzCountHiLo[1] == 0 and (zzSave == high or zzSave == low) then 1
else if zzSave == high or zzSave == low then zzCountHiLo[1] + 1
else zzCountHiLo[1];
def zzHiLo = if zzSave == high or zzSave == low then zzCountHiLo else zzCountHiLo + 1;
def zzCountHigh = if zzSave == high then zzCount[1] else Double.NaN;
def zzCountLow = if zzSave == low then zzCount[1] else Double.NaN;
# Volume Specific Data
def vol = if BarNumber() == 0 then 0 else volume + vol[1];
def vol1 = if BarNumber() == 1 then volume else vol1[1];
def xxVol = if zzSave == high or zzSave == low then TotalSum(volume) else xxVol[1];
def chgVol = if xxvol - xxVol[1] + vol1 == vol then vol else xxVol - xxVol[1];
# Zig Zag Plot
plot zzp = if isUp <= 1 then zz else Double.NaN;
zzp.AssignValueColor(if isUp then Color.Green else if !isUp then Color.Red else Color.Dark_Orange);
zzp.SetStyle(Curve.FIRM);
zzp.EnableApproximation();
zzp.HideBubble();
# Bubbles
# Price Change between Zigzags
AddChartBubble(showBubblesChange and !IsNaN(zz) and BarNumber() != 1, if isUp then high * (1 + BubbleOffset) else low * (1 - BubbleOffset), "$" + Round(chg, 2), 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 Zigzag High/Low
AddChartBubble(showBubblesPrice and !IsNaN(zz) and BarNumber() != 1, if isUp then high * (1 + BubbleOffset) else low * (1 - 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);
# Bar Count between Zigzags
AddChartBubble(showBubblesBarCount and !IsNaN(zz) and BarNumber() != 1, if isUp then high * (1 + BubbleOffset) else low * (1 - BubbleOffset), if zzSave == high then zzCountHigh else zzCountLow, 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, if isUp then yes else no);
# Volume at Zigzag Reversals
AddChartBubble(showBubblesVolume and !IsNaN(zz) and BarNumber() != 1, if isUp then high * (1 + bubbleoffset) else low * (1 - bubbleoffset), chgVol, 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, if isUp then yes else no);
# End ZigZag High Low Stats
Last edited by a moderator: