## AO_SupplyDemandCompositeVer2_2
## START CODE
## ZigZagSign TOMO modification, v0.2 written by Linus @Thinkscripter Lounge adapted from
## Thinkorswim ZigZagSign Script
##8.24.13 Mod by Lar to add Supply/Demand Levels (Red Zones are Supply, Green are Demand), ability to enter percentage, amount or atr for reversalAmount (using the greater of the three at any reversal)
##2.20.14 Mod by Linus to hide non-active Supply/Demand Levels.
##2.20.14 Mods by Linus to remove everything but Supply/Demand levels and arrows.
##3.04.14 Mods by Linus to change Supply/Demand levels to start at arrows. (Ver2.1)
##3.12.14 Mods by Linus to fix first Supply/Demand levels to not start at Zero. (Ver2.2)
##6.4.14 Mods by Lar using some of Linus changes to allow showing just today's fibs and to show only a user selectable number of fib extension changes within the chart, along with their applicable bubbles (and b = number of spaces to move bubbles in expansion)
def price = close;
def priceH = high; # swing high
def priceL = low; # swing low
input ATRreversalfactor = 3.0;#Hint ATRreversalfactor: 3 is standard, adjust to whatever instrument/timeframe you are trading.
input ATRlength = 5;#Hint ATRlength: 5 is standard, adjust to whatever instrument/timeframe you are trading
input zigzagpercent = 3.0;#LAR original is 0.2, but modified in testing for 4h charting (may modify further later)
input zigzagamount = .15;
def ATR = reference ATR(length = ATRlength);
def reversalAmount = if (close * zigzagpercent / 100) > Max
(zigzagamount < ATRreversalfactor * ATR, zigzagamount) then
(close * zigzagpercent / 100) else if zigzagamount < ATRreversalfactor * ATR then
ATRreversalfactor * ATR else zigzagamount;
input showSupplyDemand = {Off, default Arrow, Pivot};
input showArrows = no; #orignal by LAR was no
input useAlerts = no; #orignal by LAR was no
#Original TOS ZigZag code Modified by Linus
def barNumber = BarNumber();
def barCount = HighestAll(If(IsNaN(price), 0, barNumber));
rec state = {default init, undefined, uptrend, downtrend};
rec minMaxPrice;
if (GetValue(state, 1) == GetValue(state.init, 0)) {
minMaxPrice = price;
state = state.undefined;
} else if (GetValue(state, 1) == GetValue(state.undefined, 0)) {
if (price <= GetValue(minMaxPrice, 1) - reversalAmount) {
state = state.downtrend;
minMaxPrice = priceL;
} else if (price >= GetValue(minMaxPrice, 1) + reversalAmount) {
state = state.uptrend;
minMaxPrice = priceH;
} else {
state = state.undefined;
minMaxPrice = GetValue(minMaxPrice, 1);
}
} else if (GetValue(state, 1) == GetValue(state.uptrend, 0)) {
if (price <= GetValue(minMaxPrice, 1) - reversalAmount) {
state = state.downtrend;
minMaxPrice = priceL;
} else {
state = state.uptrend;
minMaxPrice = Max(priceH, GetValue(minMaxPrice, 1));
}
} else {
if (price >= GetValue(minMaxPrice, 1) + reversalAmount) {
state = state.uptrend;
minMaxPrice = priceH;
} else {
state = state.downtrend;
minMaxPrice = Min(priceL, GetValue(minMaxPrice, 1));
}
}
def isCalculated = GetValue(state, 0) != GetValue(state, 1) and barNumber >= 1;
def futureDepth = barCount - barNumber;
def tmpLastPeriodBar;
if (isCalculated) {
if (futureDepth >= 1 and GetValue(state, 0) == GetValue(state, -1)) {
tmpLastPeriodBar = fold lastPeriodBarI = 2 to futureDepth + 1 with
lastPeriodBarAcc = 1
while lastPeriodBarAcc > 0
do if (GetValue(state, 0) != GetValue(state, -lastPeriodBarI))
then -lastPeriodBarAcc
else lastPeriodBarAcc + 1;
} else {
tmpLastPeriodBar = 0;
}
} else {
tmpLastPeriodBar = Double.NaN;
}
def lastPeriodBar = if (!IsNaN(tmpLastPeriodBar)) then -AbsValue
(tmpLastPeriodBar) else -futureDepth;
rec currentPriceLevel;
rec currentPoints;
if (state == state.uptrend and isCalculated) {
currentPriceLevel =
fold barWithMaxOnPeriodI = lastPeriodBar to 1 with barWithMaxOnPeriodAcc
= minMaxPrice
do Max(barWithMaxOnPeriodAcc, GetValue(minMaxPrice,
barWithMaxOnPeriodI));
currentPoints =
fold maxPointOnPeriodI = lastPeriodBar to 1 with maxPointOnPeriodAcc =
Double.NaN
while IsNaN(maxPointOnPeriodAcc)
do if (GetValue(priceH, maxPointOnPeriodI) == currentPriceLevel)
then maxPointOnPeriodI
else maxPointOnPeriodAcc;
} else if (state == state.downtrend and isCalculated) {
currentPriceLevel =
fold barWithMinOnPeriodI = lastPeriodBar to 1 with barWithMinOnPeriodAcc
= minMaxPrice
do Min(barWithMinOnPeriodAcc, GetValue(minMaxPrice,
barWithMinOnPeriodI));
currentPoints =
fold minPointOnPeriodI = lastPeriodBar to 1 with minPointOnPeriodAcc =
Double.NaN
while IsNaN(minPointOnPeriodAcc)
do if (GetValue(priceL, minPointOnPeriodI) == currentPriceLevel)
then minPointOnPeriodI
else minPointOnPeriodAcc;
} else if (!isCalculated and (state == state.uptrend or state ==
state.downtrend)) {
currentPriceLevel = GetValue(currentPriceLevel, 1);
currentPoints = GetValue(currentPoints, 1) + 1;
} else {
currentPoints = 1;
currentPriceLevel = GetValue(price, currentPoints);
}
plot "ZZ$" = if (barNumber == barCount or barNumber == 1) then if state ==
state.uptrend then priceH else priceL else if (currentPoints == 0) then
currentPriceLevel else Double.NaN;
rec zzSave = if !IsNaN("ZZ$") then if (barNumber == barCount or barNumber == 1)
then if IsNaN(barNumber[-1]) and state == state.uptrend then priceH else priceL
else currentPriceLevel else GetValue(zzSave, 1);
def chg = (if barNumber == barCount and currentPoints < 0 then priceH else if
barNumber == barCount and currentPoints > 0 then priceL else currentPriceLevel)
- GetValue(zzSave, 1);
def isUp = chg >= 0;
rec isConf = AbsValue(chg) >= reversalAmount or (IsNaN(GetValue("ZZ$", 1)) and
GetValue(isConf, 1));
"ZZ$".EnableApproximation();
"ZZ$".DefineColor("Up Trend", Color.GREEN);
"ZZ$".DefineColor("Down Trend", Color.RED);
"ZZ$".DefineColor("Undefined", Color.DARK_ORANGE);
"ZZ$".AssignValueColor(if !isConf then "ZZ$".Color("Undefined") else if isUp
then "ZZ$".Color("Up Trend") else "ZZ$".Color("Down Trend"));
"ZZ$".SetLineWeight(2);
DefineGlobalColor("Unconfirmed", Color.DARK_ORANGE);
DefineGlobalColor("Up", Color.GREEN);
DefineGlobalColor("Down", Color.RED);
#Showlabel for Confirmed/Unconfirmed Status of Current Zigzag
AddLabel(barNumber != 1, (if isConf then "Confirmed " else "Unconfirmed ") + "ZigZag: " + chg, if !isConf then GlobalColor("Unconfirmed") else if isUp then GlobalColor("Up") else GlobalColor("Down"));
#Arrows
def zzL = if !IsNaN("ZZ$") and state == state.downtrend then priceL else
GetValue(zzL, 1);
def zzH = if !IsNaN("ZZ$") and state == state.uptrend then priceH else GetValue
(zzH, 1);
def dir = CompoundValue(1, if zzL != zzL[1] then 1 else if zzH != zzH[1] then -1
else dir[1], 0);
def signal = CompoundValue(1,
if dir > 0 and low > zzL then
if signal[1] <= 0 then 1 else signal[1]
else if dir < 0 and high < zzH then
if signal[1] >= 0 then -1 else signal[1]
else signal[1]
, 0);
plot U1 = showArrows and signal > 0 and signal[1] <= 0;
U1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
U1.SetDefaultColor(Color.GREEN);
U1.SetLineWeight(4);
plot D1 = showArrows and signal < 0 and signal[1] >= 0;
D1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
D1.SetDefaultColor(Color.RED);
D1.SetLineWeight(4);
Alert(useAlerts and U1, "ZIG-UP", Alert.BAR, Sound.Bell);
Alert(useAlerts and D1, "ZAG-DOWN", Alert.BAR, Sound.Chimes);
#Supply Demand Areas
def idx = if showSupplyDemand == showSupplyDemand.Pivot then 1 else 0;
def rLow;
def rHigh;
if BarNumber() == 1 {
rLow = Double.NaN;
rHigh = Double.NaN;
} else if signal crosses 0 {
rLow = low[idx];
rHigh = high[idx];
} else {
rLow = rLow[1];
rHigh = rHigh[1];
}
plot HighLine = if showSupplyDemand and !IsNaN(close) then rHigh else
Double.NaN;
HighLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
HighLine.AssignValueColor(if signal > 0 then Color.GREEN else Color.RED);
HighLine.HideBubble();
plot LowLine = if showSupplyDemand and !IsNaN(close) then rLow else Double.NaN;
LowLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowLine.AssignValueColor(if signal > 0 then Color.GREEN else Color.RED);
LowLine.HideBubble();
def hlUp = if signal > 0 then HighLine else Double.NaN;
def hlDn = if signal < 0 then HighLine else Double.NaN;
AddCloud(hlUp, LowLine, Color.GREEN, Color.GREEN);
AddCloud(hlDn, LowLine, Color.RED, Color.RED);
#Store Previous Data
def zzsave1 = if !IsNaN(zzSave) then zzSave else zzsave1[1];
def zzsave2 = zzsave1;
rec priorzz1 = if zzsave2 != zzsave2[1] then zzsave2[1] else priorzz1[1];
rec priorzz2 = if priorzz1 != priorzz1[1] then priorzz1[1] else priorzz2[1];
rec priorzz3 = if priorzz2 != priorzz2[1] then priorzz2[1] else priorzz3[1];
rec priorzz4 = if priorzz3 != priorzz3[1] then priorzz3[1] else priorzz4[1];
rec priorzz5 = if priorzz4 != priorzz4[1] then priorzz4[1] else priorzz5[1];
rec priorzz6 = if priorzz5 != priorzz5[1] then priorzz5[1] else priorzz6[1];
rec data = CompoundValue(1, if (zzSave == priceH or zzSave == priceL) then data[1] + 1 else data[1], 0);
def datacount = (HighestAll(data) - data[1]);
input numberextfibstoshow = 2;
input showFibExtLines = yes;
input showtodayonly = no;
def today = if showtodayonly == yes then GetDay() == GetLastDay() else GetDay();
##Down Extensions
#Stop
def extstop = if zzSave == priceH
then high - AbsValue(priorzz2 - priorzz1) * 0
else extstop[1];
plot stop = if datacount <= numberextfibstoshow and today and showFibExtLines and currentPoints != 0 and !IsNaN(extstop) and dir < 0
then extstop[1]
else Double.NaN;
stop.SetPaintingStrategy(PaintingStrategy.DASHES);
stop.SetDefaultColor(Color.RED);
stop.SetLineWeight(1);
stop.HideBubble();
#Entry
def extentry = if zzSave == priceH
then high - AbsValue(priorzz2 - priorzz1) * 0.236
else extentry[1];
plot entry = if datacount <= numberextfibstoshow and today and showFibExtLines and currentPoints != 0 and !IsNaN(extentry) and dir < 0
then extentry[1]
else Double.NaN;
entry.SetPaintingStrategy(PaintingStrategy.DASHES);
entry.SetDefaultColor(Color.RED);
entry.SetLineWeight(1);
entry.HideBubble();
#T1
def extfib2 = if zzSave == priceH
then high - AbsValue(priorzz2 - priorzz1) * 0.618
else extfib2[1];
plot extfib618 = if datacount <= numberextfibstoshow and today and showFibExtLines and currentPoints != 0 and !IsNaN(extfib2) and dir < 0
then extfib2[1]
else Double.NaN;
extfib618.SetPaintingStrategy(PaintingStrategy.DASHES);
extfib618.SetDefaultColor(Color.RED);
extfib618.SetLineWeight(1);
extfib618.HideBubble();
#T2
def extfib1 = if zzSave == priceH
then high - AbsValue(priorzz2 - priorzz1) * 1
else extfib1[1];
plot extfib100 = if datacount <= numberextfibstoshow and today and showFibExtLines and currentPoints != 0 and !IsNaN(extfib1) and dir < 0
then extfib1[1] else Double.NaN;
extfib100.SetPaintingStrategy(PaintingStrategy.DASHES);
extfib100.SetDefaultColor(Color.RED);
extfib100.SetLineWeight(1);
extfib100.HideBubble();
#Diffs
def entrystop = if zzSave == priceH then ((high - AbsValue(priorzz2 - priorzz1) *
0) + (high - AbsValue(priorzz2 - priorzz1) * 0.236)) / 2 else entrystop[1];
plot stopentry = if datacount <= numberextfibstoshow and today and showFibExtLines and currentPoints != 0 and !IsNaN(entrystop) and dir < 0 then entrystop[1] else Double.NaN;
stopentry.SetPaintingStrategy(PaintingStrategy.DASHES);
stopentry.SetDefaultColor(Color.RED);
stopentry.SetLineWeight(1);
stopentry.HideBubble();
def entryT1 = if zzSave == priceH then ((high - AbsValue(priorzz2 - priorzz1) *
0.236) + (high - AbsValue(priorzz2 - priorzz1) * 0.618)) / 2 else entryT1[1];
plot T1entry = if datacount <= numberextfibstoshow and today and showFibExtLines and currentPoints != 0 and !IsNaN(entryT1) and dir < 0 then entryT1[1] else Double.NaN;
T1entry.SetPaintingStrategy(PaintingStrategy.DASHES);
T1entry.SetDefaultColor(Color.RED);
T1entry.SetLineWeight(1);
T1entry.HideBubble();
def T1T2 = if zzSave == priceH
then ((high - AbsValue(priorzz2 - priorzz1) * 0.618) +
(high - AbsValue(priorzz2 - priorzz1) * 1)) / 2
else T1T2[1];
plot DT1T2 = if datacount <= numberextfibstoshow and today and showFibExtLines and currentPoints != 0 and !IsNaN(T1T2) and dir < 0
then T1T2[1] else Double.NaN;
DT1T2.SetPaintingStrategy(PaintingStrategy.DASHES);
DT1T2.SetDefaultColor(Color.RED);
DT1T2.SetLineWeight(1);
DT1T2.HideBubble();
####
def extfib3 = if zzSave == priceH then high - AbsValue(priorzz2 - priorzz1) *
1.618 else extfib3[1];
plot extfib1618 = if datacount <= numberextfibstoshow and today and showFibExtLines and currentPoints != 0 and !IsNaN(extfib3) and dir < 0 then extfib3[1] else Double.NaN;
extfib1618.SetPaintingStrategy(PaintingStrategy.DASHES);
extfib1618.SetDefaultColor(Color.RED);
extfib1618.SetLineWeight(1);
extfib1618.HideBubble();
def extfib4 = if zzSave == priceH then high - AbsValue(priorzz2 - priorzz1) *
2.618 else extfib4[1];
plot extfib2618 = if datacount <= numberextfibstoshow and today and showFibExtLines and currentPoints != 0 and !IsNaN(extfib4) and dir < 0 then extfib4[1] else Double.NaN;
extfib2618.SetPaintingStrategy(PaintingStrategy.DASHES);
extfib2618.SetDefaultColor(Color.RED);
extfib2618.SetLineWeight(1);
extfib2618.HideBubble();
#End Down Extensions
#Up Extensions
#Stop
def extstop_ = if zzSave == priceL
then low + AbsValue(priorzz2 - priorzz1) * 0
else extstop_[1];
plot stop_ = if datacount <= numberextfibstoshow and today and showFibExtLines and currentPoints != 0 and !IsNaN(extstop_) and dir > 0
then extstop_[1]
else Double.NaN;
stop_.SetPaintingStrategy(PaintingStrategy.DASHES);
stop_.SetDefaultColor(Color.RED);
stop_.SetLineWeight(1);
stop_.HideBubble();
#Entry
def extentry_ = if zzSave == priceL
then low + AbsValue(priorzz2 - priorzz1) * 0.236
else extentry_[1];
plot entry_ = if datacount <= numberextfibstoshow and today and showFibExtLines and currentPoints != 0 and !IsNaN(extentry_) and dir > 0
then extentry_[1]
else Double.NaN;
entry_.SetPaintingStrategy(PaintingStrategy.DASHES);
entry_.SetDefaultColor(Color.RED);
entry_.SetLineWeight(1);
entry_.HideBubble();
#T1
def extfib2_ = if zzSave == priceL then low + AbsValue(priorzz2 - priorzz1) *
0.618 else extfib2_[1];
plot extfib618_ = if datacount <= numberextfibstoshow and today and showFibExtLines and currentPoints != 0 and !IsNaN(extfib2_) and dir > 0 then extfib2_[1] else Double.NaN;
extfib618_.SetPaintingStrategy(PaintingStrategy.DASHES);
extfib618_.SetDefaultColor(Color.GREEN);
extfib618_.SetLineWeight(1);
extfib618_.HideBubble();
#T2
def extfib1_ = if zzSave == priceL then low + AbsValue(priorzz2 - priorzz1) * 1
else extfib1_[1];
plot extfib100_ = if datacount <= numberextfibstoshow and today and showFibExtLines and currentPoints != 0 and !IsNaN(extfib1_) and dir > 0 then extfib1_[1] else Double.NaN;
extfib100_.SetPaintingStrategy(PaintingStrategy.DASHES);
extfib100_.SetDefaultColor(Color.GREEN);
extfib100_.SetLineWeight(1);
extfib100_.HideBubble();
#Diffs
def entrystop_ = if zzSave == priceL then ((low + AbsValue(priorzz2 - priorzz1) *
0) + (low + AbsValue(priorzz2 - priorzz1) * 0.236)) / 2 else entrystop_[1];
plot stopentry_ = if datacount <= numberextfibstoshow and today and showFibExtLines and currentPoints != 0 and !IsNaN(entrystop_) and dir > 0 then entrystop_[1] else Double.NaN;
stopentry_.SetPaintingStrategy(PaintingStrategy.DASHES);
stopentry_.SetDefaultColor(Color.RED);
stopentry_.SetLineWeight(1);
stopentry_.HideBubble();
def entryT1_ = if zzSave == priceL then ((low + AbsValue(priorzz2 - priorzz1) *
0.236) + (low + AbsValue(priorzz2 - priorzz1) * 0.618)) / 2 else entryT1_[1];
plot T1entry_ = if datacount <= numberextfibstoshow and today and showFibExtLines and currentPoints != 0 and !IsNaN(entryT1_) and dir > 0 then entryT1_[1] else Double.NaN;
T1entry_.SetPaintingStrategy(PaintingStrategy.DASHES);
T1entry_.SetDefaultColor(Color.RED);
T1entry_.SetLineWeight(1);
T1entry_.HideBubble();
def T1T2_ = if zzSave == priceL
then ((low + AbsValue(priorzz2 - priorzz1) * 0.618) +
(low + AbsValue(priorzz2 - priorzz1) * 1)) / 2
else T1T2_[1];
plot DT1T2_ = if datacount <= numberextfibstoshow and today and showFibExtLines and currentPoints != 0 and !IsNaN(T1T2) and dir > 0
then T1T2_[1] else Double.NaN;
DT1T2_.SetPaintingStrategy(PaintingStrategy.DASHES);
DT1T2_.SetDefaultColor(Color.RED);
DT1T2_.SetLineWeight(1);
DT1T2_.HideBubble();
def extfib3_ = if zzSave == priceL then low + AbsValue(priorzz2 - priorzz1) *
1.618 else extfib3_[1];
plot extfib1618_ = if datacount <= numberextfibstoshow and today and showFibExtLines and currentPoints != 0 and !IsNaN(extfib3_) and dir > 0 then extfib3_[1] else Double.NaN;
extfib1618_.SetPaintingStrategy(PaintingStrategy.DASHES);
extfib1618_.SetDefaultColor(Color.GREEN);
extfib1618_.SetLineWeight(1);
extfib1618_.HideBubble();
def extfib4_ = if zzSave == priceL then low + AbsValue(priorzz2 - priorzz1) *
2.618 else extfib4_[1];
plot extfib2618_ = if datacount <= numberextfibstoshow and today and showFibExtLines and currentPoints != 0 and !IsNaN(extfib4_) and dir > 0 then extfib4_[1] else Double.NaN;
extfib2618_.SetPaintingStrategy(PaintingStrategy.DASHES);
extfib2618_.SetDefaultColor(Color.GREEN);
extfib2618_.SetLineWeight(1);
extfib2618_.HideBubble();
#End Up Extensions
#Bubbles
#Bubbles spacing except Diff bubbles
input b = 2;
def direction = if !isUp then 1 else 0;
#Diff bubbles spacing
input d = 5;
#Down Extensions
AddChartBubble( direction[b + 1] == 1 and showFibExtLines and !IsNaN(close[b + 1]) and IsNaN(close[b]), stop[b + 2], "Stop " + astext(Stop[b + 2]), Color.RED,yes);
AddChartBubble( direction[b + 1] == 1 and showFibExtLines and !IsNaN(close[b + 1]) and IsNaN(close[b]), entry[b + 2], "Entry " + astext(entry[b + 2]), Color.RED, no);
AddChartBubble( direction[b + 1] == 1 and showFibExtLines and !IsNaN(close[b + 1]) and IsNaN(close[b]), extfib2[b + 2], "T1 " + astext(extfib2[b + 2]), Color.RED, no);
AddChartBubble( direction[b + 1] == 1 and showFibExtLines and !IsNaN(close[b + 1]) and IsNaN(close[b]), extfib1[b + 2], "T2 " + astext(extfib1[b + 2]), Color.RED, no);
def Diff1 = (high - AbsValue(priorzz2 - priorzz1) * 0) -
(high - AbsValue(priorzz2 - priorzz1) * 0.236);
def Diff2 = (high - AbsValue(priorzz2 - priorzz1) * 0.236) -
(high - AbsValue(priorzz2 - priorzz1) * 0.618);
def Diff3 = (high - AbsValue(priorzz2 - priorzz1) * 0.618) -
(high - AbsValue(priorzz2 - priorzz1) * 1);
AddChartBubble( direction[d + 1] == 1 and showFibExtLines and !IsNaN(close[d + 1]) and IsNaN(close[d]), stopentry[d + 2], "D1 " + astext(Diff1[d + 2]), Color.white, yes);
AddChartBubble( direction[d + 1] == 1 and showFibExtLines and !IsNaN(close[d + 1]) and IsNaN(close[d]), entryT1[d + 2], "D2 " + astext(Diff2[d + 2]), Color.white, no);
AddChartBubble( direction[d + 1] == 1 and showFibExtLines and !IsNaN(close[d + 1]) and IsNaN(close[d]), DT1T2[d + 2], "D3 " + astext(Diff3[d + 2]), Color.white, no);
AddChartBubble( direction[b + 1] == 1 and showFibExtLines and !IsNaN(close[b + 1]) and IsNaN(close[b]), extfib3[b + 2], "161.8%", Color.RED, no);
AddChartBubble( direction[b + 1] == 1 and showFibExtLines and !IsNaN(close[b + 1]) and IsNaN(close[b]), extfib4[b + 2], "261.8%", Color.RED, no);
#Up Extensions
AddChartBubble( direction[b + 1] == 0 and showFibExtLines and !IsNaN(close[b + 1]) and IsNaN(close[b]), stop_[b + 2], "Stop " + astext(Stop_[b + 2]), Color.green,no);
AddChartBubble( direction[b + 1] == 0 and showFibExtLines and !IsNaN(close[b + 1]) and IsNaN(close[b]), entry_[b + 2], "Entry " + astext(entry_[b + 2]), Color.green, no);
AddChartBubble( direction[b + 1] == 0 and showFibExtLines and !IsNaN(close[b + 1]) and IsNaN(close[b]), extfib2_[b + 2], "T1 " + astext(extfib2_[b + 2]), Color.GREEN, yes);
AddChartBubble( direction[b + 1] == 0 and showFibExtLines and !IsNaN(close[b + 1]) and IsNaN(close[b]), extfib1_[b + 2], "T2 " + astext(extfib1_[b + 2]) , Color.GREEN, yes);
#Diff Extensions
def Diff1_ = (low + AbsValue(priorzz2 - priorzz1) * 0) -
(low + AbsValue(priorzz2 - priorzz1) * 0.236);
def Diff2_ = (low + AbsValue(priorzz2 - priorzz1) * 0.236) -
(low + AbsValue(priorzz2 - priorzz1) * 0.618);
def Diff3_ = (low + AbsValue(priorzz2 - priorzz1) * 0.618) -
(low + AbsValue(priorzz2 - priorzz1) * 1);
AddChartBubble( direction[d + 1] == 0 and showFibExtLines and !IsNaN(close[d + 1]) and IsNaN(close[d]), stopentry_[d + 2], "D1 " + astext(absValue(Diff1_[d + 2])), Color.white, yes);
AddChartBubble( direction[d + 1] == 0 and showFibExtLines and !IsNaN(close[d + 1]) and IsNaN(close[d]), entryT1_[d + 2], "D2 " + astext(absvalue(Diff2_[d + 2])), Color.white, no);
AddChartBubble( direction[d + 1] == 0 and showFibExtLines and !IsNaN(close[d + 1]) and IsNaN(close[d]), DT1T2_[d + 2], "D3 " + astext(absvalue(Diff3_[d + 2])), Color.white, no);
addlabel(1, stopentry_);
AddChartBubble( direction[b + 1] == 0 and showFibExtLines and !IsNaN(close[b + 1]) and IsNaN(close[b]), extfib3_[b + 2], "161.8%", Color.GREEN, yes);
AddChartBubble( direction[b + 1] == 0 and showFibExtLines and !IsNaN(close[b + 1]) and IsNaN(close[b]), extfib4_[b + 2], "261.8%", Color.GREEN, yes);
#