Auto Fib (Fibonacci) Levels Indicator for ThinkorSwim

Can anyone convert this tradingview script of Auto Fibonacci Retracement?. It is has proved to be very useful. Searching similar to this one on thinkorswim but had no luck. If anyone can convert will be helpful.

Code:
//@version=4
study("Auto Fib Retracement", overlay=true)

// pivots threshold
threshold_multiplier = input(title="Deviation", type=input.float, defval=3, minval=0)
dev_threshold = atr(10) / close * 100 * threshold_multiplier

depth = input(title="Depth", type=input.integer, defval=10, minval=1)
var extendLeft = input(false, "Extend Lines Left")
var extendRight = input(true, "Extend Lines Right")

var extending = extend.none
if extendLeft and extendRight
    extending := extend.both
if extendLeft and not extendRight
    extending := extend.left
if not extendLeft and extendRight
    extending := extend.right

reverse = input(false, "Reverse")
prices = input(true, "Prices")
levels = input(true, "Levels")
levelsFormat = input("Values", "Levels Format", options = ["Values", "Percent"])
labelsPosition = input("Left", "Labels Position", options = ["Left", "Right"])

var line lineLast = na
var int iLast = 0
var int iPrev = 0
var float pLast = 0
var isHighLast = false // otherwise the last pivot is a low pivot

pivots(src, length, isHigh) =>
    l2 = length * 2
    c = nz(src[length])
    ok = true
    for i = 0 to l2
        if isHigh and src[i] > c
            ok := false

        if not isHigh and src[i] < c
            ok := false
    if ok
        [bar_index[length], c]
    else
        [int(na), float(na)]
[iH, pH] = pivots(high, depth / 2, true)
[iL, pL] = pivots(low, depth / 2, false)

calc_dev(base_price, price) =>
    100 * (price - base_price) / price

pivotFound(dev, isHigh, index, price) =>
    if isHighLast == isHigh and not na(lineLast)
        // same direction
        if isHighLast ? price > pLast : price < pLast
            line.set_xy2(lineLast, index, price)
            [lineLast, isHighLast]
        else
            [line(na), bool(na)]
    else // reverse the direction (or create the very first line)
        if abs(dev) > dev_threshold
            // price move is significant
            id = line.new(iLast, pLast, index, price, color=color.gray, width=1, style=line.style_dashed)
            [id, isHigh]
        else
            [line(na), bool(na)]

if not na(iH)
    dev = calc_dev(pLast, pH)
    [id, isHigh] = pivotFound(dev, true, iH, pH)
    if not na(id)
        if id != lineLast
            line.delete(lineLast)
        lineLast := id
        isHighLast := isHigh
        iPrev := iLast
        iLast := iH
        pLast := pH
else
    if not na(iL)
        dev = calc_dev(pLast, pL)
        [id, isHigh] = pivotFound(dev, false, iL, pL)
        if not na(id)
            if id != lineLast
                line.delete(lineLast)
            lineLast := id
            isHighLast := isHigh
            iPrev := iLast
            iLast := iL
            pLast := pL

_draw_line(price, col) =>
    var id = line.new(iLast, price, bar_index, price, color=col, width=1, extend=extending)
    if not na(lineLast)
        line.set_xy1(id, line.get_x1(lineLast), price)
        line.set_xy2(id, line.get_x2(lineLast), price)


_draw_label(price, txt, txtColor) =>
    x = labelsPosition == "Left" ? line.get_x1(lineLast) : not extendRight ? line.get_x2(lineLast) : bar_index
    labelStyle = labelsPosition == "Left" ? label.style_label_right : label.style_label_left
    align = labelsPosition == "Left" ? text.align_right : text.align_left
    labelsAlignStrLeft = txt + '\n ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏ \n'
    labelsAlignStrRight = '       ' + txt + '\n ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏ \n'
    labelsAlignStr = labelsPosition == "Left" ? labelsAlignStrLeft : labelsAlignStrRight
    var id = label.new(x=x, y=price, text=labelsAlignStr, textcolor=txtColor, style=labelStyle, textalign=align, color=#00000000)
    label.set_xy(id, x, price)
    label.set_text(id, labelsAlignStr)
    label.set_textcolor(id, txtColor)

_wrap(txt) =>
    "(" + tostring(txt, "#.##") + ")"

_label_txt(level, price) =>
    l = levelsFormat == "Values" ? tostring(level) : tostring(level * 100) + "%"
    (levels ? l : "") + (prices ? _wrap(price) : "")

_crossing_level(sr, r) =>
    (r > sr and r < sr[1]) or (r < sr and r > sr[1])

startPrice = reverse ? line.get_y1(lineLast) : pLast
endPrice = reverse ? pLast : line.get_y1(lineLast)

iHL = startPrice > endPrice
diff = (iHL ? -1 : 1) * abs(startPrice - endPrice)

level_0 = input(true, "0")
color_0 = input(#787b86, "0 Level Color")
float m = 0
r = startPrice + diff * m
if level_0
    _draw_line(r, color_0)
    _draw_label(r, _label_txt(m, r), color_0)
alertcondition(_crossing_level(close, r), "Autofib 0 crossing!", "Autofib: {{ticker}} crossing level 0.")

level_0236 = input(true, "0.236")
color_0236 = input(#f44336, "0.236 Level Color")
m := 0.236
r := startPrice + diff * m
if level_0236
    _draw_line(r, color_0236)
    _draw_label(r, _label_txt(m, r), color_0236)
alertcondition(_crossing_level(close, r), "Autofib 0.236 crossing!", "Autofib: {{ticker}} crossing level 0.236.")

level_0382 = input(true, "0.382")
color_0382 = input(#81c784, "0.382 Level Color")
m := 0.382
r := startPrice + diff * m
if level_0382
    _draw_line(r, color_0382)
    _draw_label(r, _label_txt(m, r), color_0382)
alertcondition(_crossing_level(close, r), "Autofib 0.382 crossing!", "Autofib: {{ticker}} crossing level 0.382.")

level_05 = input(true, "0.5")
color_05 = input(#4caf50, "0.5 Level Color")
m := 0.5
r := startPrice + diff * m
if level_05
    _draw_line(r, color_05)
    _draw_label(r, _label_txt(m, r), color_05)
alertcondition(_crossing_level(close, r), "Autofib 0.5 crossing!", "Autofib: {{ticker}} crossing level 0.5.")

level_0618 = input(true, "0.618")
color_0618 = input(#009688, "0.618 Level Color")
m := 0.618
r := startPrice + diff * m
if level_0618
    _draw_line(r, color_0618)
    _draw_label(r, _label_txt(m, r), color_0618)
alertcondition(_crossing_level(close, r), "Autofib 0.618 crossing!", "Autofib: {{ticker}} crossing level 0.618.")

level_065 = input(false, "0.65")
color_065 = input(#009688, "0.65 Level Color")
m := 0.65
r := startPrice + diff * m
if level_065
    _draw_line(r, color_065)
    _draw_label(r, _label_txt(m, r), color_065)
alertcondition(_crossing_level(close, r), "Autofib 0.65 crossing!", "Autofib: {{ticker}} crossing level 0.65.")

level_0786 = input(true, "0.786")
color_0786 = input(#64b5f6, "0.786 Level Color")
m := 0.786
r := startPrice + diff * m
if level_0786
    _draw_line(r, color_0786)
    _draw_label(r, _label_txt(m, r), color_0786)
alertcondition(_crossing_level(close, r), "Autofib 0.786 crossing!", "Autofib: {{ticker}} crossing level 0.786.")

level_1 = input(true, "1")
color_1 = input(#787b86, "1 Level Color")
m := 1
r := startPrice + diff * m
if level_1
    _draw_line(r, color_1)
    _draw_label(r, _label_txt(m, r), color_1)
alertcondition(_crossing_level(close, r), "Autofib 1 crossing!", "Autofib: {{ticker}} crossing level 1.")

level_1272 = input(true, "1.272")
color_1272 = input(#81c784, "1.272 Level Color")
m := 1.272
r := startPrice + diff * m
if level_1272
    _draw_line(r, color_1272)
    _draw_label(r, _label_txt(m, r), color_1272)
alertcondition(_crossing_level(close, r), "Autofib 1.272 crossing!", "Autofib: {{ticker}} crossing level 1.272.")

level_1414 = input(true, "1.414")
color_1414 = input(#f44336, "1.414 Level Color")
m := 1.414
r := startPrice + diff * m
if level_1414
    _draw_line(r, color_1414)
    _draw_label(r, _label_txt(m, r), color_1414)
alertcondition(_crossing_level(close, r), "Autofib 1.414 crossing!", "Autofib: {{ticker}} crossing level 1.414.")

level_1618 = input(true, "1.618")
color_1618 = input(#2196f3, "1.618 Level Color")
m := 1.618
r := startPrice + diff * m
if level_1618
    _draw_line(r, color_1618)
    _draw_label(r, _label_txt(m, r), color_1618)
alertcondition(_crossing_level(close, r), "Autofib 1.618 crossing!", "Autofib: {{ticker}} crossing level 1.618.")

level_165 = input(false, "1.65")
color_165 = input(#2196f3, "1.65 Level Color")
m := 1.65
r := startPrice + diff * m
if level_165
    _draw_line(r, color_165)
    _draw_label(r, _label_txt(m, r), color_165)
alertcondition(_crossing_level(close, r), "Autofib 1.65 crossing!", "Autofib: {{ticker}} crossing level 1.65.")

level_2618 = input(false, "2.618")
color_2618 = input(#f44336, "2.618 Level Color")
m := 2.618
r := startPrice + diff * m
if level_2618
    _draw_line(r, color_2618)
    _draw_label(r, _label_txt(m, r), color_2618)
alertcondition(_crossing_level(close, r), "Autofib 2.618 crossing!", "Autofib: {{ticker}} crossing level 2.618.")

level_265 = input(false, "2.65")
color_265 = input(#f44336, "2.65 Level Color")
m := 2.65
r := startPrice + diff * m
if level_265
    _draw_line(r, color_265)
    _draw_label(r, _label_txt(m, r), color_265)
alertcondition(_crossing_level(close, r), "Autofib 2.65 crossing!", "Autofib: {{ticker}} crossing level 2.65.")

level_3618 = input(false, "3.618")
color_3618 = input(#9c27b0, "3.618 Level Color")
m := 3.618
r := startPrice + diff * m
if level_3618
    _draw_line(r, color_3618)
    _draw_label(r, _label_txt(m, r), color_3618)
alertcondition(_crossing_level(close, r), "Autofib 3.618 crossing!", "Autofib: {{ticker}} crossing level 3.618.")

level_365 = input(false, "3.65")
color_365 = input(#9c27b0, "3.65 Level Color")
m := 3.65
r := startPrice + diff * m
if level_365
    _draw_line(r, color_365)
    _draw_label(r, _label_txt(m, r), color_365)
alertcondition(_crossing_level(close, r), "Autofib 3.65 crossing!", "Autofib: {{ticker}} crossing level 3.65.")

level_4236 = input(false, "4.236")
color_4236 = input(#e91e63, "4.236 Level Color")
m := 4.236
r := startPrice + diff * m
if level_4236
    _draw_line(r, color_4236)
    _draw_label(r, _label_txt(m, r), color_4236)
alertcondition(_crossing_level(close, r), "Autofib 4.236 crossing!", "Autofib: {{ticker}} crossing level 4.236.")

level_n0236 = input(false, "-0.236")
color_n0236 = input(#f44336, "-0.236 Level Color")
m := -0.236
r := startPrice + diff * m
if level_n0236
    _draw_line(r, color_n0236)
    _draw_label(r, _label_txt(m, r), color_n0236)
alertcondition(_crossing_level(close, r), "Autofib -0.236 crossing!", "Autofib: {{ticker}} crossing level -0.236.")

level_n0382 = input(false, "-0.382")
color_n0382 = input(#81c784, "-0.382 Level Color")
m := -0.382
r := startPrice + diff * m
if level_n0382
    _draw_line(r, color_n0382)
    _draw_label(r, _label_txt(m, r), color_n0382)
alertcondition(_crossing_level(close, r), "Autofib -0.382 crossing!", "Autofib: {{ticker}} crossing level -0.382.")

level_n0618 = input(false, "-0.618")
color_n0618 = input(#009688, "-0.618 Level Color")
m := -0.618
r := startPrice + diff * m
if level_n0618
    _draw_line(r, color_n0618)
    _draw_label(r, _label_txt(m, r), color_n0618)
alertcondition(_crossing_level(close, r), "Autofib -0.618 crossing!", "Autofib: {{ticker}} crossing level -0.618.")

level_n065 = input(false, "-0.65")
color_n065 = input(#009688, "-0.65 Level Color")
m := -0.65
r := startPrice + diff * m
if level_n065
    _draw_line(r, color_n065)
    _draw_label(r, _label_txt(m, r), color_n065)
alertcondition(_crossing_level(close, r), "Autofib -0.65 crossing!", "Autofib: {{ticker}} crossing level -0.65.")[/i][/i]
Does anyone know how to convert this tradingview auto Fibonacci script into thinkorswim script?. Help will be greatly appreciated. Thank you.
 
You stated "yesterdays previous close" so you want the close from 2 days ago? I assume you meant the prior days close, here you go.

Previous Day Close Label with red/green color

Code:
def PriorDayClose = if GetDay() == GetLastDay() then PriorDayClose[1] else close;
AddLabel(1, "PriorDayClose : " + PriorDayClose ,  if PriorDayClose <close then color.green else color.red);

Hey dude, any idea how to implicate these fib % labels based on the previous day's close to turn green when completed?

Code:
declare hide_on_daily;

def PrevClose = close(period = AggregationPeriod.Day)[1];

plot level1 = PrevClose * 1.9;
plot level2 = PrevClose * 2.2;
plot level3 = PrevClose * 2.8;
plot level4 = PrevClose * 3.4;
plot level5 = PrevClose * 4.6;   

AddLabel(1, "90% = " + Round(level1,2), Color.White);
AddLabel(1, "120% = " + Round(level2,2), Color.White);
AddLabel(1, "180% = " + Round(level3,2), Color.White);
AddLabel(1, "240% = " + Round(level4,2), Color.White);
AddLabel(1, "360% = " + Round(level5,2), Color.White);

# End Levels Based on Previous Daily Close

unknown.png
 
This study by Mobius plots both the Whole Chart Fibonacci along with the secondary set. Typically known as First and Second Wave Fibonacci set.

Code:
# Fibonacci Lines From Pivots
# Mobius
# V01.02.2013
# Other technical studies can be found on MyTrade: Mobius

declare Once_per_bar;
input numBars = 55; #hint numbars: Second Wave suggested 21, 34, 55, 89, 144
input showValues = no; #hint showValues: User choice
input showBarNumbers = no; #hint showBarNumbers: User choice
input TrendResistanceStart = 0; #hint TrendResistanceStart: User input value
input TrendResistanceEnd = 0; #hint TrendResistanceEnd: User input value
input TrendSupportStart = 0; #hint TrednSupportStart: User input value
input TrendSupportEnd = 0; #hint TrendSupportEnd: User input value
input BubbleOn = yes; #hint BubbleOn: User choice
# Study Definitions
   def o = open;
   def h = high;
   def l = low;
   def c = close;
   def bar = BarNumber();
   def yearstart = GetYear() * 10000 + 101;
   def tradingDays = CountTradingDays(yearstart, GetYYYYMMDD());
   def Coeff_1 = .236;
   def Coeff_2 = .382;
   def Coeff_3 = .500;
   def Coeff_4 = .618;
   def Coeff_5 = .786;

# First Wave Fibonacci Retracement
script Fibs {
    input C0 = 0.000;
    def o = open;
    def h = high;
    def l = low;
# Get highest and lowest on chart
    def a = HighestAll(h);
    def b = LowestAll(l);
# Get the bar numbers at the highest and lowest points
    def barnumber = BarNumber();
    def c = if h == a
          then barnumber
          else Double.NaN;
    def d = if l == b
          then barnumber
          else Double.NaN;
    def highnumber = CompoundValue(1, if IsNaN(c)
                                    then highnumber[1]
                                    else c, c);
    def highnumberall = HighestAll(highnumber);
    def lownumber = CompoundValue(1, if IsNaN(d)
                                   then lownumber[1]
                                   else d, d);
    def lownumberall = LowestAll(lownumber);
# Determine Slope Delta
    def upward = highnumberall > lownumberall;
    def downward = highnumberall < lownumberall;
# Define X
    def x = AbsValue(lownumberall - highnumberall );
# Get Slope for either direction
    def slope = (a - b) / x;
    def slopelow = (b - a) / x;
# Get Day
    def day = GetDay();
    def month = GetMonth();
    def year = GetYear();
    def lastDay = GetLastDay();
    def lastmonth = GetLastMonth();
    def lastyear = GetLastYear();
    def isToday = If(day == lastDay and
                   month == lastmonth and
                   year == lastyear, 1, 0);
    def istodaybarnumber = HighestAll(if isToday
                                    then barnumber
                                    else Double.NaN);
# Calculations for line between extremes
    def line = b + (slope * (barnumber - lownumber));
    def linelow = a + (slopelow * (barnumber - highnumber));
    def currentlinelow = if barnumber <= lownumberall
                       then linelow
                       else Double.NaN;
    def currentline = if barnumber <= highnumberall
                  then line
                  else Double.NaN;
    def FibFan =  if downward
                then currentlinelow
                else if upward
                then currentline
                else Double.NaN;
# Rise of line between Extremes
   def range =  a - b;
  plot Fib1 = fold i = 1 to 100
              with p = FibFan
              while (downward and
                    barnumber >= highnumberall and
                    barnumber <= istodaybarnumber)
                    or
                    (upward and
                    barnumber >= lownumberall and
                    barnumber <= istodaybarnumber)            
              do if downward
                 then HighestAll((b + (range *  C0)))
                 else if upward
                 then HighestAll(a - (range * C0))
                 else Double.NaN;
}
# Start Plot Sequence
input C0 = 0.000;
input C1 = .236;
input C2 = .382;
input C3 = .500;
input C4 = .618;
input C5 = .786;
input C6 = 1.000;

   def TotalBars = HighestAll(bar);
   def HHbar = if high == highestAll(high)
               then bar
               else HHbar[1];
   def LLbar = if low == lowestAll(low)
               then bar
               else LLbar[1];
   def firstBar = if HHbar > LLbar
                  then LLbar
                  else if HHbar < LLbar
                  then HHbar
                  else Double.NaN;
   def BubbleLocation =  bar == HighestAll(firstbar);
  plot fib1 = Round(fibs(C0 = C0), 3);
       fib1.SetDefaultColor(Color.Red);
AddChartBubble((if BubbleOn then BubbleLocation else double.nan), fib1
              , (c0 * 100) + "%  $" + fib1, color.gray, yes);
  plot fib2 = Round(fibs(C0 = C1), 3);
       fib2.SetDefaultColor(Color.Red);
AddChartBubble((if BubbleOn then BubbleLocation else double.nan), fib2
               , (c1 * 100) + "%  $" + fib2, color.gray, yes);
  plot fib3 = Round(fibs(C0 = C2), 3);
       fib3.SetDefaultColor(Color.Red);
AddChartBubble((if BubbleOn then BubbleLocation else double.nan), fib3
               , concat( (c2 * 100), "%"), color.gray, yes);
  plot fib4 = Round(fibs(C0 = C3), 3);
       fib4.SetDefaultColor(Color.Red);
AddChartBubble((if BubbleOn then BubbleLocation else double.nan), fib4
               , (c3 * 100) + "%  $" + fib4, color.gray, yes);
  plot fib5 = Round(fibs(C0 = C4), 3);
       fib5.SetDefaultColor(Color.Red);
AddChartBubble((if BubbleOn then BubbleLocation else double.nan), fib5
               , (c4 * 100) + "%  $" + fib5 , color.gray, yes);
  plot fib6 = Round(fibs(C0 = C5), 3);
       fib6.SetDefaultColor(Color.Red);
AddChartBubble((if BubbleOn then BubbleLocation else double.nan), fib6
               , (c5 * 100) + "%  $" + fib6, color.gray, yes);
  plot fib7 = Round(fibs(C0 = C6), 3);
       fib7.SetDefaultColor(Color.Red);
AddChartBubble((if BubbleOn then BubbleLocation else double.nan), fib7
               , (c6 * 100) + "%  $" + fib7, color.gray, yes);
# Second Wave Fib Series
   def UserSetResistance = TrendResistanceStart > 0 and
                           TrendResistanceEnd > 0;
   def UserSetSupport = TrendSupportStart > 0 and
                        TrendSupportEnd > 0;
def PH;
def PL;
   def isHigherThanNextBars = fold i = 1 to numBars + 1
                              with p = 1
                              while p
                              do h > GetValue(h, -i);
       PH = if UserSetResistance and
             ( bar == TrendResistanceStart or
               bar == TrendResistanceEnd )
            then h
            else if !UserSetResistance and
                    (bar > numBars and
                     h == Highest(h, numBars) and
                     isHigherThanNextBars)
            then h
            else Double.NaN;
   def isLowerThanNextBars = fold j = 1 to numBars + 1
                             with q = 1
                             while q
                             do l < GetValue(low, -j);
       PL = if UserSetSupport and
             ( bar == TrendSupportStart or
               bar == TrendSupportEnd )
            then l
            else if !UserSetSupport and
                    (bar > numBars and
                     l == Lowest(l, numBars) and
                     isLowerThanNextBars)
            then l
            else Double.NaN;
   def PHBar = if UserSetResistance
               then TrendResistanceEnd
               else if !IsNaN(PH)
               then bar
               else PHBar[1];
   def PLBar = if UserSetSupport
               then TrendSupportEnd
               else if !IsNaN(PL)
               then bar
               else PLBar[1];
   def PHL = if !IsNaN(PH)
             then PH
             else PHL[1];
   def priorPHBar = if UserSetResistance
                    then TrendResistanceStart
                    else if PHL != PHL[1]
                    then PHBar[1]
                    else priorPHBar[1];
   def PLL = if !IsNaN(PL)
             then PL
             else PLL[1];
   def priorPLBar = if UserSetSupport
                    then TrendSupportStart
                    else if PLL != PLL[1]
                    then PLBar[1]
                    else priorPLBar[1];
   def isFinalTwoHighPivots = bar >= HighestAll(priorPHBar);
   def isFinalTwoLowPivots = bar >= HighestAll(priorPLBar);
   def ResistanceFinishOffset = if isFinalTwoHighPivots
                                then bar - PHBar
                                else 0;
   def ResistanceStartOffset = if isFinalTwoHighPivots
                               then bar - priorPHBar
                               else 0;
   def ResistanceSlope = (GetValue(PH, ResistanceFinishOffset) -
                          GetValue(PH, ResistanceStartOffset)) /
                         (PHBar - priorPHBar);
   def SupportFinishOffset = if isFinalTwoLowPivots
                             then bar - PLBar
                             else 0;
   def SupportStartOffset = if isFinalTwoLowPivots
                            then bar - priorPLBar
                            else 0;
   def SupportSlope = (GetValue(PL, SupportFinishOffset) -
                       GetValue(PL, SupportStartOffset)) /
                            (PLBar - priorPLBar);
   def ResistanceExtend = if bar == HighestAll(PHBar)
                          then 1
                          else ResistanceExtend[1];
   def SupportExtend = if bar == HighestAll(PLBar)
                       then 1
                       else SupportExtend[1];
  plot pivotHigh = if isFinalTwoHighPivots
                   then PH
                   else Double.NaN;
   def pivotHighLine = if PHL > 0 and
                          isFinalTwoHighPivots
                       then PHL
                       else double.NaN;
  plot ResistanceLine = pivotHigh;
  plot ResistanceExtension = if ResistanceExtend
                             then (bar - PHBar) * ResistanceSlope + PHL
                             else Double.NaN;
  plot pivotLow = if isFinalTwoLowPivots
                  then PL
                  else Double.NaN;
   def pivotLowLine = if PLL > 0 and
                         isFinalTwoLowPivots
                      then PLL
                      else double.NaN;
  plot SupportLine = pivotLow;
  plot SupportExtension = if SupportExtend
                          then (bar - PLBar) * SupportSlope + PLL
                          else Double.NaN;
  plot BN = bar;
  plot A_H = if isNaN(PivotHighline)
             then PivotHighLine[1]
             else HighestAll(PivotHighLine);
       A_H.SetDefaultColor(Color.Yellow);
  plot X_L = if isNaN(PivotLowLine)
             then PivotLowLine[1]
             else LowestAll(PivotLowLine);
       X_L.SetDefaultColor(Color.Yellow);
   def A = A_H;
   def B = X_L;
   def X = ( ((c - X_L) / (A_H - X_L))) + c;
  plot SeventyEight = (((a - b) * Coeff_5) + B);
  plot SixtyOne    = (((a - B) * Coeff_4) + B);
  plot Fifty       = (a + B) * Coeff_3;
  plot ThirtyEight = ((a - B) * Coeff_2) + B;
  plot TwentyThree = ((a - B) * Coeff_1) + B;
       pivotHigh.SetDefaultColor(Color.Yellow);
       pivotHigh.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
       pivotHigh.SetHiding(!showValues);
       pivotLow.SetDefaultColor(Color.Yellow);
       pivotLow.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
       pivotLow.SetHiding(!showValues);
       ResistanceLine.EnableApproximation();
       ResistanceLine.SetDefaultColor(GetColor(5));
       ResistanceExtension.SetDefaultColor(GetColor(5));
       SupportLine.EnableApproximation();
       SupportLine.SetDefaultColor(GetColor(5));
       SupportExtension.SetDefaultColor(GetColor(5));
       BN.SetDefaultColor(GetColor(0));
       BN.SetHiding(!showBarNumbers);
       BN.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
       SeventyEight.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
       SeventyEight.SetDefaultColor(Color.Yellow);
       SixtyOne.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
       SixtyOne.SetDefaultColor(Color.Yellow);
       Fifty.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
       Fifty.SetDefaultColor(Color.Yellow);
       ThirtyEight.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
       ThirtyEight.SetDefaultColor(Color.Yellow);
       TwentyThree.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
       TwentyThree.SetDefaultColor(Color.Yellow);
AddChartBubble(if BubbleOn then isNaN(close[10]) and !isNaN(close[11]) else double.nan,
                                A_H,
                                "Fib " + 1,
                                color.yellow,
                                yes);
AddChartBubble(if BubbleOn then isNaN(close[10]) and !isNaN(close[11]) else double.nan,
                                SeventyEight,
                                "Fib " + Coeff_5,
                                color.yellow,
                                yes);
AddChartBubble(if BubbleOn then isNaN(close[10]) and !isNaN(close[11]) else double.nan,
                                SixtyOne,
                                "Fib " + Coeff_4,
                                color.yellow,
                                yes);
AddChartBubble(if BubbleOn then isNaN(close[10]) and !isNaN(close[11]) else double.nan,
                                Fifty,
                                "Fib " + Coeff_3,
                                color.yellow,
                                yes);
AddChartBubble(if BubbleOn then isNaN(close[10]) and !isNaN(close[11]) else double.nan,
                                ThirtyEight,
                                "Fib " + Coeff_2,
                                color.yellow,
                                yes);
AddChartBubble(if BubbleOn then isNaN(close[10]) and !isNaN(close[11]) else double.nan,
                                TwentyThree,
                                "Fib " + Coeff_1,
                                color.yellow,
                                yes);
AddChartBubble(if BubbleOn then isNaN(close[10]) and !isNaN(close[11]) else double.nan,
                                X_L,
                                "Fib " + 0,
                                color.yellow,
                                yes);

# End Code
@BenTen Is there anyway to obtain the value at the resistance extension and add a label for it?
 
@Bendu Oh, I see what you mean now.

I was only able to add the chart bubble to the resistance trendline.

Put this at the bottom of your script:

Code:
def limit = !IsNaN(close) and IsNaN(close [-1] ) && HighestAll(BarNumber());
AddChartBubble(limit and ResistanceExtension, low, "Value = @ " + Round(ResistanceExtension), Color.light_green, no);
 

See if this might also be something you wanted. Add this code to the bottom of your script. It will place a bubble at the right edge of both of the cyan lines in your chart example.
Code:
def resistanceext_bar = if !isnan(resistanceextension) then barnumber() else resistanceext_bar[1];
AddChartBubble( barnumber()==highestall(resistanceext_bar), (ResistanceExtension), "Resistance = @ " + Round(ResistanceExtension), Color.cyan, no);
def supportext_bar = if !isnan(supportextension) then barnumber() else supportext_bar[1];
AddChartBubble( barnumber()==highestall(supportext_bar), (supportExtension), "Support = @ " + Round(supportExtension), Color.cyan, no);
 
I would like to thank everyone that has posted code or helped others with corrections. Can not begin to explain how much the past post on the site have helped me. I joined around 3 weeks ago and have been able to find the answer to every question I've had to this point which has actually been a little surprising.

I am attempting to change the original script provided by BenTen in a previous thread from Fib Retracement To Fib Extensions. I cant figure out how to change the script to allow for the manual input of bar numbers for the extension measurement and the starting point of the coefficients .
I am measuring between "Low1" and "High1" and starting the ratio at "Startcoefficients ", as listed below. The StartRatio barnumber has to be an input, if not, the target shown by the ratio will not be correct.

input Low1= 1;
input High1 = 20;
input Startcoefficients= 25;

All I am looking for is a little help with where my mistakes are but will not complain if someone is willing to just fix the script. .....The top portion is my attempt at modifying the script and the bottom portion is the original code that was provided by BenTen on a previous thread, -Auto Fib (Fibonacci) Levels Indicator for ThinkorSwim Created by RyanHendricks.-

-----------------------------------------------------------------------------------------------------------------------------------------------------

MODIFIED Auto Fib (Fibonacci) Levels CODE

Code:
input price = close;
input high = high;
input low = low;


input showBarnumbers = yes;
input onExpansion = Yes;
input Extend_to_left = no;

input Coefficient0 = 0.000;
input coefficient_1 = .236;
input Coefficient_2 = .382;
input Coefficient_3 = .500;
input Coefficient_4 = .618;
Input Coefficient_5 = .786;
input Coefficient_6 = 1.000;

input Low1= 1;
input High1 = 20;
input Startcoefficients = 25;


def a = High1 ;
def b = Bottom;
def c = if high == a then High1 else double.nan;
def d = if low == b then High1 else double.nan;

#rec highnumber = compoundValue(1, if IsNaN(c) then highnumber[1] else c, c);
def startbar = a;

#rec lownumber = compoundValue(1, if IsNaN(d) then lownumber[1] else d, d);
def lownumberall = b;

def upward = startbar > lownumberall;
def downward = startbar < lownumberall;

def x = AbsValue(lownumberall - startbar );

def slope = (a - b) / x;
def slopelow = (b - a) / x;

def day = getDay();
def month = getMonth();
def year = getYear();
def lastDay = getLastDay();
def lastmonth = getLastMonth();
def lastyear = getLastYear();
def isToday = if(day == lastDay and month == lastmonth and year == lastyear, 1, 0);


def istodaybarnumber = if isToday then High1 else double.nan;

def line = b + (slope * (High1 - b));
def linelow = a + (slopelow * (High1 - startbar));
def currentlinelow = if High1 <= lownumberall then linelow else double.nan;
def currentline = if High1 <= startbar then line else double.nan;

Plot FibFan =  if  downward then currentlinelow else if upward then currentline else double.nan;
FibFan.SetStyle(Curve.SHORT_DASH);
FibFan.AssignValueColor(Color.DARK_GRAY);
fibfan.hidebubble();

def range =  a - b;
def barnumber = High1;

Plot Retracement0 = if downward and !onexpansion and !extend_to_left and barnumber >= startbar and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient0))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient0)) else if downward and onexpansion and !extend_to_left and barnumber >= startbar then highestall((b + (range *  coefficient0))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient0)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient0))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient0)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient0))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient0)) else double.nan;
Retracement0.assignvaluecolor(Color.DARK_GRAY);
retracement0.hidebubble();

Plot Retracement1 =  if downward and !onexpansion and !extend_to_left and barnumber >= startbar and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_1))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_1)) else if downward and onexpansion and !extend_to_left and barnumber >= startbar then highestall((b + (range *  coefficient_1))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_1)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_1))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_1)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_1))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_1)) else double.nan;
Retracement1.assignvaluecolor(Color.DARK_GRAY);
retracement1.hidebubble();


Plot Retracement2 =if downward and !onexpansion and !extend_to_left and barnumber >= startbar and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_2))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_2)) else if downward and onexpansion and !extend_to_left and barnumber >= startbar then highestall((b + (range *  coefficient_2))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_2)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_2))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_2)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_2))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_2)) else double.nan;
Retracement2.assignvaluecolor(Color.DARK_GRAY);
retracement2.hidebubble();


Plot Retracement3 = if downward and !onexpansion and !extend_to_left and barnumber >= startbar and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_3))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_3)) else if downward and onexpansion and !extend_to_left and barnumber >= startbar then highestall((b + (range *  coefficient_3))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_3)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_3))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_3)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_3))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_3)) else double.nan;
Retracement3.assignvaluecolor(Color.DARK_GRAY);
retracement3.hidebubble();

Plot Retracement4 = if downward and !onexpansion and !extend_to_left and barnumber >= startbar and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_4))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_4)) else if downward and onexpansion and !extend_to_left and barnumber >= startbar then highestall((b + (range *  coefficient_4))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_4)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_4))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_4)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_4))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_4)) else double.nan;
Retracement4.assignvaluecolor(Color.DARK_GRAY);
retracement4.hidebubble();

Plot Retracement5 = if downward and !onexpansion and !extend_to_left and barnumber >= startbar and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_5))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_5)) else if downward and onexpansion and !extend_to_left and barnumber >= startbar then highestall((b + (range *  coefficient_5))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_5)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_5))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_5)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_5))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_5)) else double.nan;
Retracement5.assignvaluecolor(Color.DARK_GRAY);
retracement5.hidebubble();


Plot Retracement6 = if downward and !onexpansion and !extend_to_left and barnumber >= startbar and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and !extend_to_left and barnumber >= startbar then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_6)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_6)) else double.nan;
Retracement6.assignvaluecolor(Color.DARK_GRAY);
retracement6.hidebubble();

plot bars = if showBarnumbers then BarNumber() else Double.NaN;
bars.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);



[B][B][B][B][B][B][B][B][B][B][B][B][B][B][B][B][B][B][B][B][I]Original Auto Fib (Fibonacci) Levels CODE *[/I][/B][/B][/B][/B][/B][/B][/B][/B][/B][/B][/B][/B][/B][/B][/B][/B][/B][/B][/B][/B]

input price = close;
input high = high;
input low = low;
input onExpansion = Yes;
input Extend_to_left = no;
input Coefficient0 = 0.000;
input coefficient_1 = .236;
input Coefficient_2 = .382;
input Coefficient_3 = .500;
input Coefficient_4 = .618;
Input Coefficient_5 = .786;
input Coefficient_6 = 1.000;

def a = HighestAll(high);
def b = LowestAll(low);
def barnumber = barNumber();
def c = if high == a then barnumber else double.nan;
def d = if low == b then barnumber else double.nan;
rec highnumber = compoundValue(1, if IsNaN(c) then highnumber[1] else c, c);
def highnumberall = HighestAll(highnumber);
rec lownumber = compoundValue(1, if IsNaN(d) then lownumber[1] else d, d);
def lownumberall = LowestAll(lownumber);

def upward = highnumberall > lownumberall;
def downward = highnumberall < lownumberall;

def x = AbsValue(lownumberall - highnumberall );

def slope = (a - b) / x;
def slopelow = (b - a) / x;

def day = getDay();
def month = getMonth();
def year = getYear();
def lastDay = getLastDay();
def lastmonth = getLastMonth();
def lastyear = getLastYear();
def isToday = if(day == lastDay and month == lastmonth and year == lastyear, 1, 0);
def istodaybarnumber = HighestAll(if isToday then barnumber else double.nan);

def line = b + (slope * (barnumber - lownumber));
def linelow = a + (slopelow * (barnumber - highnumber));

def currentlinelow = if barnumber <= lownumberall then linelow else double.nan;
def currentline = if barnumber <= highnumberall then line else double.nan;

Plot FibFan =  if  downward then currentlinelow else if upward then currentline else double.nan;
FibFan.SetStyle(Curve.SHORT_DASH);
FibFan.AssignValueColor(color.cyan);
fibfan.hidebubble();

def range =  a - b;

Plot Retracement0 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient0))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient0)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient0))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient0)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient0))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient0)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient0))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient0)) else double.nan;
Retracement0.assignvaluecolor(color.cyan);
retracement0.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement0, concat( "$", round(retracement0, 2)), color.cyan, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement0, concat( (coefficient0 * 100), "%"), color.cyan, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement0, concat( (coefficient0 * 100), "%"), color.cyan, yes);


Plot Retracement1 =  if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_1))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_1)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_1))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_1)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_1))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_1)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_1))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_1)) else double.nan;
Retracement1.assignvaluecolor(color.cyan);
retracement1.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement1, concat( "$", round(retracement1, 2)), color.cyan, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement1, concat( (coefficient_1 * 100), "%"), color.cyan, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement1, concat( (coefficient_1 * 100), "%"), color.cyan, yes);

Plot Retracement2 =if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_2))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_2)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_2))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_2)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_2))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_2)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_2))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_2)) else double.nan;
Retracement2.assignvaluecolor(color.cyan);
retracement2.hidebubble();
AddChartBubble("time condition" = (barnumber == istodaybarnumber), "price location" = retracement2, text = Concat( "$", Round(retracement2, 2)), color = Color.CYAN);
AddChartBubble((downward and barnumber == highnumberall), retracement2, concat( (coefficient_2 * 100), "%"), color.cyan, No);
AddChartBubble("time condition" = (upward and barnumber == lownumberall), "price location" = retracement2, text = Concat( (coefficient_2 * 100), "%"), color = Color.CYAN);


Plot Retracement3 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_3))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_3)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_3))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_3)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_3))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_3)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_3))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_3)) else double.nan;
Retracement3.assignvaluecolor(color.red);
retracement3.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement3, concat( "$", round(retracement3, 2)), color.white, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement3, concat( (coefficient_3 * 100), "%"), Color.WHITE, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement3, concat( (coefficient_3 * 100), "%"), Color.WHITE, yes);


Plot Retracement4 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_4))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_4)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_4))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_4)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_4))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_4)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_4))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_4)) else double.nan;
Retracement4.assignvaluecolor(color.cyan);
retracement4.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement4, concat( "$", round(retracement4, 2)), color.cyan, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement4, concat( (coefficient_4 * 100), "%"), color.cyan, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement4, concat( (coefficient_4 * 100), "%"), color.cyan, yes);

Plot Retracement5 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_5))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_5)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_5))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_5)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_5))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_5)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_5))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_5)) else double.nan;
Retracement5.assignvaluecolor(color.cyan);
retracement5.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement5, concat( "$", round(retracement5, 2)), color.cyan, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement5, concat( (coefficient_5 * 100), "%"), color.cyan, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement5, concat( (coefficient_5 * 100), "%"), color.cyan, yes);


Plot Retracement6 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_6)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_6)) else double.nan;
Retracement6.assignvaluecolor(color.cyan);
retracement6.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement6, concat( "$", round(retracement6, 2)), color.cyan, yes);

AddChartBubble((downward and barnumber == highnumberall), retracement6, concat( (coefficient_6 * 100), "%"), color.cyan, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement6, concat( (coefficient_6 * 100), "%"), color.cyan, yes);


alert((price crosses below Retracement0) , "Price crosses below Retracement Line 0");
alert((price crosses above Retracement0) , "Price crosses above Retracement Line 0");
alert((price crosses below Retracement1) , "Price crosses below Retracement Line 1");
alert((price crosses above Retracement1) , "Price crosses above Retracement Line 1");
alert((price crosses below Retracement2) , "Price crosses below Retracement Line 2");
alert((price crosses above Retracement2) , "Price crosses above Retracement Line 2");
alert((price crosses below Retracement3) , "Price crosses below Retracement Line 3");
alert((price crosses above Retracement3) , "Price crosses above Retracement Line 3");
alert((price crosses below Retracement4) , "Price crosses below Retracement Line 4");
alert((price crosses above Retracement4) , "Price crosses above Retracement Line 4");
alert((price crosses below Retracement5) , "Price crosses below Retracement Line 5");
alert((price crosses above Retracement5) , "Price crosses above Retracement Line 5");
alert((price crosses below Retracement6) , "Price crosses below Retracement Line 6");
alert((price crosses above Retracement6) , "Price crosses above Retracement Line 6");
Have you been able to figure this out?

I am also interested in the exact same thing.
 
Want a Fib ARC thinkscript

Reason: No other Fib considers a decay curve

please, Sincerely
 
Last edited by a moderator:
@dmillz Fibonacci Arcs are listed in the Drawing Tools menu at the bottom right of your charts... Third item up from the bottom, on the right side... They draw like bullseye targets... TOS doesn't provide use any functions to draw Arcs via Thinkscript so the short answer to the @Samus Aran is that it can't be done other than manually...
 
Last edited:
Does anyone know how to convert this tradingview auto Fibonacci script into thinkorswim script?. Help will be greatly appreciated. Thank you.
you have better odds of explaining what it does that different from this auto fib in this thread and seeing if someone can alter it to fit your needs.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
233 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top