Auto Fib (Fibonacci) Levels Indicator for ThinkorSwim

hi @BenTen i was hoping to have some help with this custom code to be turned into a scanner, i would like to scan for stocks that entering oversold in green. i have attached the code and a photo.

Code:
##############################
# Monkey Bar Section
# TOS MB study used copyright TD Ameritrade
# version : 1.0 
# Chris Glander author
##########
# version : 1.1, 1.2 minor bug revisions
##########
# version : 1.3 
#   1) added rounding to the ticksize for all values
#   2) placed bubbles in last period into the expansion area in order to see the last data bar
##########
# version : 1.4
#   1) multiple changes to make production ready
##########
# version : 1.5
#   1) allow for the use of the previous period Fibs if needed
#   2) use color names versus GetColor numbers
# version : 1.51
#   1) moved last set of Fib Bubbles to furthest right in expansion area without using an offset
##############################

declare once_per_bar;
input useYest_Fibs_again = no;
input aggregationPeriod = {"1 min", "2 min", "3 min", "4 min", "5 min", "10 min", "15 min", "20 min", default "30 min", "1 hour", "2 hours", "4 hours", "Day", "2 Days", "3 Days", "4 Days", "Week", "Month", "Quarter", "Year"};
input timePerProfile = {CHART, MINUTE, HOUR, default DAY, WEEK, MONTH, "OPT EXP", BAR, YEAR};
# show or not show the current day Fibs
input show_Current_Period_Fibs = yes;
input showOnlyLastPeriod = no;
# all colors based on GetColor constants 0 - 9
input Fibs_Color = {default "Neon Salmon", "Cyan", "Purple", "Light Gray", "Yellow", "Orange", "Green", "Gray", "Light Yellow", "White"};
# whether to show prices and percent of the Fib
input show_Fib_bubbles = yes;
# upward extension of some Fibs from the main set
input dupe_Fibs_up = yes;
# downward extension of some Fibs from the main set
input dupe_Fibs_down = yes;
# This shows the prior day data and Fibs used to generate current day data
input showInitFibData = no;
input showInitFibs = no;
input Fibs_Init_Color = {"Neon Salmon", "Cyan", "Purple", "Light Gray", "Yellow", default "Orange", "Green", "Gray", "Light Yellow", "White"};
input showClouds = yes;
# do not modify below here
input pricePerRowHeightMode = {default AUTOMATIC, TICKSIZE, CUSTOM};
input customRowHeight = .25;
input multiplier = 1;
input onExpansion = no;
input profiles = 10000;
input showMonkeyBar = no;
input showThePlayground = no;
input thePlaygroundPercent = 1;
# opacity change to 40% or more to see monkeybars
input opacity = 0;
input emphasizeFirstDigit = no;
input markOpenPrice = no;
input markClosePrice = no;
input volumeShowStyle = MonkeyVolumeShowStyle.NONE;
input showVolumeVA = no;
input showVolumePoc = no;
input theVolumePercent = 70;
input showInitialBalance = no;
input initialBalanceRange = 3;
input MB_calc_or_mid = {default MID, CALC};

script Math {
    input value = 0.00;
    plot MRound = Round(value / TickSize(), 0) * TickSize();
}

def na = Double.NaN;
def bn = BarNumber();
def period;
def yyyymmdd = GetYYYYMMDD();
def seconds = SecondsFromTime(0);
def year = GetYear();
def month = year * 12 + GetMonth();
def day_number = DaysFromDate(First(yyyymmdd)) + GetDayOfWeek(First(yyyymmdd));
def dom = GetDayOfMonth(yyyymmdd);
def dow = GetDayOfWeek(yyyymmdd - dom + 1);
def expthismonth = (if dow > 5 then 27 else 20) - dow;
def exp_opt = month + (dom > expthismonth);
def periodMin = Floor(seconds / 60 + day_number * 24 * 60);
def periodHour = Floor(seconds / 3600 + day_number * 24);
def periodDay = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;
def periodWeek = Floor(day_number / 7);
def periodMonth = month - First(month);
def periodQuarter = Ceil(month / 3) - First(Ceil(month / 3));
def periodYear = year - First(year);

def Fib_Color;
switch (Fibs_Color) {
case "Neon Salmon":
    Fib_Color = 2;
case "Cyan":
    Fib_Color = 1;
case "Purple":
    Fib_Color = 0;
case "Light Gray":
    Fib_Color = 3;
case "Yellow":
    Fib_Color = 4;
case "Orange":
    Fib_Color = 5;
case "Green":
    Fib_Color = 6;
case "Gray":
    Fib_Color = 7;
case "Light Yellow":
    Fib_Color = 8;
case "White":
    Fib_Color = 9;
}

def Fib_Init_Color;
switch (Fibs_Init_Color) {
case "Neon Salmon":
    Fib_Init_Color = 2;
case "Cyan":
    Fib_Init_Color = 1;
case "Purple":
    Fib_Init_Color = 0;
case "Light Gray":
    Fib_Init_Color = 3;
case "Yellow":
    Fib_Init_Color = 4;
case "Orange":
    Fib_Init_Color = 5;
case "Green":
    Fib_Init_Color = 6;
case "Gray":
    Fib_Init_Color = 7;
case "Light Yellow":
    Fib_Init_Color = 8;
case "White":
    Fib_Init_Color = 9;
}

switch (timePerProfile) {
case CHART:
    period = 0;
case MINUTE:
    period = periodMin;
case HOUR:
    period = periodHour;
case DAY:
    period = periodDay;
case WEEK:
    period = periodWeek;
case MONTH:
    period = periodMonth;
case "OPT EXP":
    period = exp_opt - First(exp_opt);
case BAR:
    period = BarNumber() - 1;
case YEAR:
    period = periodYear;
}

def count = CompoundValue(1, if period != period[1] then (GetValue(count, 1) + period - period[1]) % multiplier else GetValue(count, 1), 0);
def cond = CompoundValue(1, count < count[1] + period - period[1], yes);

#plot cnd = cond;

def height;
switch (pricePerRowHeightMode) {
case AUTOMATIC:
    height = PricePerRow.AUTOMATIC;
case TICKSIZE:
    height = PricePerRow.TICKSIZE;
case CUSTOM:
    height = customRowHeight;
}

def timeInterval;
def aggMultiplier;
switch (aggregationPeriod) {
case "1 min":
    timeInterval = periodMin;
    aggMultiplier = 1;
case "2 min":
    timeInterval = periodMin;
    aggMultiplier = 2;
case "3 min":
    timeInterval = periodMin;
    aggMultiplier = 3;
case "4 min":
    timeInterval = periodMin;
    aggMultiplier = 4;
case "5 min":
    timeInterval = periodMin;
    aggMultiplier = 5;
case "10 min":
    timeInterval = periodMin;
    aggMultiplier = 10;
case "15 min":
    timeInterval = periodMin;
    aggMultiplier = 15;
case "20 min":
    timeInterval = periodMin;
    aggMultiplier = 20;
case "30 min":
    timeInterval = periodMin;
    aggMultiplier = 30;
case "1 hour":
    timeInterval = periodHour;
    aggMultiplier = 1;
case "2 hours":
    timeInterval = periodHour;
    aggMultiplier = 2;
case "4 hours":
    timeInterval = periodHour;
    aggMultiplier = 4;
case "Day":
    timeInterval = periodDay;
    aggMultiplier = 1;
case "2 Days":
    timeInterval = periodDay;
    aggMultiplier = 2;
case "3 Days":
    timeInterval = periodDay;
    aggMultiplier = 3;
case "4 Days":
    timeInterval = periodDay;
    aggMultiplier = 4;
case "Week":
    timeInterval = periodWeek;
    aggMultiplier = 1;
case "Month":
    timeInterval = periodMonth;
    aggMultiplier = 1;
case "Quarter":
    timeInterval = periodQuarter;
    aggMultiplier = 1;
case "Year":
    timeInterval = periodYear;
    aggMultiplier = 1;
}

def agg_count = CompoundValue(1, if timeInterval != timeInterval[1] then (GetValue(agg_count, 1) + timeInterval - timeInterval[1]) % aggMultiplier else GetValue(agg_count, 1), 0);
def agg_cond = CompoundValue(1,  agg_count < agg_count[1] + timeInterval - timeInterval[1], yes);
def digit = CompoundValue(1, if cond then 1 else agg_cond + GetValue(digit, 1), 1);

profile monkey = MonkeyBars(digit, "startNewProfile" = cond, "onExpansion" = onExpansion,
"numberOfProfiles" = profiles, "pricePerRow" = height, "the playground percent" = thePlaygroundPercent,
"emphasize first digit" = emphasizeFirstDigit, "volumeProfileShowStyle" = volumeShowStyle, "volumePercentVA" = theVolumePercent,
"show initial balance" = showInitialBalance, "initial balance range" = initialBalanceRange);

def con = CompoundValue(1, onExpansion, no);
def mbar = Math(CompoundValue(1, if IsNaN(monkey.GetPointOfControl()) and con then GetValue(mbar, 1) else monkey.GetPointOfControl(), monkey.GetPointOfControl())).MRound;
def hPG =  Math(CompoundValue(1, if IsNaN(monkey.GetHighestValueArea()) and con then GetValue(hPG, 1) else monkey.GetHighestValueArea(), monkey.GetHighestValueArea())).MRound;
def lPG =  Math(CompoundValue(1, if IsNaN(monkey.GetLowestValueArea()) and con then GetValue(lPG, 1) else monkey.GetLowestValueArea(), monkey.GetLowestValueArea())).MRound;
def mPG =  Math((hPG + lPG) * .5).MRound;
def mb_used = if MB_calc_or_mid == MB_calc_or_mid."MID" then mPG else mbar;
def hProfile = Math(CompoundValue(1, if IsNaN(monkey.GetHighest()) and con then GetValue(hProfile, 1) else monkey.GetHighest(), monkey.GetHighest())).MRound;
def lProfile = Math(CompoundValue(1, if IsNaN(monkey.GetLowest()) and con then GetValue(lProfile, 1) else monkey.GetLowest(), monkey.GetLowest())).MRound;
def midProfile = Math((hProfile + lProfile) * .5).MRound;
def rgProfile = hProfile - lProfile;

def isNew = mbar != mbar[1] or mPG != mPG[1] or midProfile != midProfile[1];
def isNewbn = if isNew then bn else isNewbn[1];
def highestNewbn = HighestAll(isNewbn);
def highest_bn = HighestAll(bn);
def inLastPeriod = if useYest_Fibs_again then bn >= highestNewbn else bn > highestNewbn;
def last_data_bar = if !IsNaN(close) and IsNaN(close[-1]) then bn else last_data_bar[1];
#def highest_db = HighestAll(last_data_bar) + offset;
def use_prev_fibs = inLastPeriod and useYest_Fibs_again;

plot ProfileHigh = if showInitFibData then hProfile else na;
plot ProfileLow = if showInitFibData then lProfile else na;
plot ProfileMid = if showInitFibData then midProfile else na;
plot ProfileRange = if showInitFibData then rgProfile else na;
plot PGHigh = if showInitFibData then hPG else na;
plot PGLow = if showInitFibData then lPG else na;
plot MB_Calc = if showInitFibData then mbar else na;
plot PGMid =  if showInitFibData then mPG else na;
plot MB = if showInitFibData then mb_used else na;
MB.SetHiding(!showInitFibData);
ProfileHigh.SetHiding(!showInitFibData);
ProfileLow.SetHiding(!showInitFibData);
ProfileMid.SetHiding(!showInitFibData);
DefineGlobalColor("Monkey Bar", GetColor(4));
DefineGlobalColor("The Playground", GetColor(3));
DefineGlobalColor("Open Price", GetColor(1));
DefineGlobalColor("Close Price", GetColor(1));
DefineGlobalColor("Volume", GetColor(8));
DefineGlobalColor("Volume Value Area", GetColor(2));
DefineGlobalColor("Volume Point of Control", GetColor(3));
DefineGlobalColor("Initial Balance", GetColor(7));

monkey.Show(Color.RED, if showMonkeyBar then GlobalColor("Monkey Bar") else Color.CURRENT,
 if showThePlayground then GlobalColor("The Playground") else Color.CURRENT,
 opacity, if markOpenPrice then GlobalColor("Open Price") else Color.CURRENT,
 if markClosePrice then GlobalColor("Close Price") else Color.CURRENT,
 if showInitialBalance then GlobalColor("Initial Balance") else Color.CURRENT,
 GlobalColor("Volume"),
 if showVolumeVA then GlobalColor("Volume Value Area") else Color.CURRENT,
 if showVolumePoc then GlobalColor("Volume Point of Control") else Color.CURRENT);
MB.SetDefaultColor(GlobalColor("Monkey Bar"));
MB.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PGHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PGLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PGHigh.SetDefaultColor(GlobalColor("The Playground"));
PGLow.SetDefaultColor(GlobalColor("The Playground"));
ProfileHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileHigh.SetDefaultColor(GetColor(3));
ProfileLow.SetDefaultColor(GetColor(3));
ProfileMid.SetDefaultColor(GetColor(9));

AddChartBubble(isNew and showInitFibData and show_Fib_bubbles, MB, "MB|" + AsPrice(MB), MB.TakeValueColor());
AddChartBubble(isNew and showInitFibData and show_Fib_bubbles, ProfileHigh, "ProfileHigh|" + AsPrice(ProfileHigh), ProfileHigh.TakeValueColor());
AddChartBubble(isNew and showInitFibData and show_Fib_bubbles, ProfileLow, "ProfileLow|" + AsPrice(ProfileLow), ProfileLow.TakeValueColor());
AddChartBubble(isNew and showInitFibData and show_Fib_bubbles, ProfileMid, "ProfileMid|" + AsPrice(ProfileMid), ProfileMid.TakeValueColor());

##############################
#Fib Section
##############################
# generate the initial Fibs for then next day
def Pct200 = Math(if mb_used < midProfile then lProfile - 2 * (midProfile - mb_used) else hProfile + 2 * (mb_used - midProfile)).MRound;
def F0 = if Pct200 < midProfile then midProfile else Pct200;
def F100 = if Pct200 > midProfile then midProfile else Pct200;
def fibRg = AbsValue(F0 - F100);

def Fneg100a = Math(F0 + fibRg).MRound;
def Fneg80a = Math(F0 + .8 * fibRg).MRound;
def Fneg50a = Math(F0 + .5 * fibRg).MRound;
def Fneg20a = Math(F0 + .2 * fibRg).MRound;
def F0a = Math(F0).MRound;
def F20a = Math(F0 - .2 * fibRg).MRound;
def F50a = Math(F0 - .5 * fibRg).MRound;
def F80a = Math(F0 - .8 * fibRg).MRound;
def F100a = Math(F100).MRound;
;
def F120a = Math(F0 - 1.2 * fibRg).MRound;
def F150a = Math(F0 - 1.5 * fibRg).MRound;
def F180a = Math(F0 - 1.8 * fibRg).MRound;
def F200a = Math(F0 - 2 * fibRg).MRound;
;

plot init200Mark = if !showInitFibData then na else Pct200;
plot Fibneg100a = if !showInitFibs then na else Fneg100a;
plot Fibneg80a = if !showInitFibs then na else Fneg80a;
plot Fibneg50a = if !showInitFibs then na else Fneg50a;
plot Fibneg20a = if !showInitFibs then na else Fneg20a;
plot Fib0a = if !showInitFibs then na else F0a;
plot Fib20a = if !showInitFibs then na else F20a;
plot Fib50a = if !showInitFibs then na else F50a;
plot Fib80a = if !showInitFibs then na else F80a;
plot Fib100a = if !showInitFibs then na else F100;
plot Fib120a = if !showInitFibs then na else F120a;
plot Fib150a = if !showInitFibs then na else F150a;
plot Fib180a = if !showInitFibs then na else F180a;
plot Fib200a = if !showInitFibs then na else F200a;

init200Mark.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
init200Mark.SetDefaultColor(GetColor(9));
Fibneg100a.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fibneg100a.AssignValueColor(GetColor(Fib_Init_Color));
Fibneg80a.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fibneg80a.AssignValueColor(GetColor(Fib_Init_Color));
Fibneg50a.SetPaintingStrategy(PaintingStrategy.DASHES);
Fibneg50a.AssignValueColor(GetColor(Fib_Init_Color));
Fibneg20a.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fibneg20a.AssignValueColor(GetColor(Fib_Init_Color));
Fib0a.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib0a.AssignValueColor(GetColor(Fib_Init_Color));
Fib20a.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib20a.AssignValueColor(GetColor(Fib_Init_Color));
Fib50a.SetPaintingStrategy(PaintingStrategy.DASHES);
Fib50a.AssignValueColor(GetColor(Fib_Init_Color));
Fib80a.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib80a.AssignValueColor(GetColor(Fib_Init_Color));
Fib100a.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib100a.AssignValueColor(GetColor(Fib_Init_Color));
Fib120a.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib120a.AssignValueColor(GetColor(Fib_Init_Color));
Fib150a.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib150a.AssignValueColor(GetColor(Fib_Init_Color));
Fib180a.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib180a.AssignValueColor(GetColor(Fib_Init_Color));
Fib200a.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib200a.AssignValueColor(GetColor(Fib_Init_Color));
AddChartBubble(isNew and showInitFibData and show_Fib_bubbles, init200Mark, AsPercent(2) + " Extension|" + AsPrice(init200Mark), init200Mark.TakeValueColor());
AddChartBubble(isNew and showInitFibs and show_Fib_bubbles, Fibneg100a, AsPercent(-1) + "|" + AsPrice(Fibneg100a), Fibneg100a.TakeValueColor());
AddChartBubble(isNew and showInitFibs and show_Fib_bubbles, Fibneg80a,  AsPercent(-.8) + "|" + AsPrice(Fibneg80a), Fibneg80a.TakeValueColor());
AddChartBubble(isNew and showInitFibs and show_Fib_bubbles, Fibneg50a,  AsPercent(-.5) + "|" + AsPrice(Fibneg50a), Fibneg50a.TakeValueColor());
AddChartBubble(isNew and showInitFibs and show_Fib_bubbles, Fibneg20a,  AsPercent(-.2) + "|" + AsPrice(Fibneg20a), Fibneg20a.TakeValueColor());
AddChartBubble(isNew and showInitFibs and show_Fib_bubbles, Fib0a,  AsPercent(0) + "|" + AsPrice(Fib0a), Fib0a.TakeValueColor());
AddChartBubble(isNew and showInitFibs and show_Fib_bubbles, Fib20a,  AsPercent(.2) + "|" + AsPrice(Fib20a), Fib20a.TakeValueColor());
AddChartBubble(isNew and showInitFibs and show_Fib_bubbles, Fib50a,  AsPercent(.5) + "|" + AsPrice(Fib50a), Fib50a.TakeValueColor());
AddChartBubble(isNew and showInitFibs and show_Fib_bubbles, Fib80a,  AsPercent(.8) + "|" + AsPrice(Fib80a), Fib80a.TakeValueColor());
AddChartBubble(isNew and showInitFibs and show_Fib_bubbles, Fib100a,  AsPercent(1) + "|" + AsPrice(Fib100a), Fib100a.TakeValueColor());
AddChartBubble(isNew and showInitFibs and show_Fib_bubbles, Fib120a,  AsPercent(1.2) + "|" + AsPrice(Fib120a), Fib120a.TakeValueColor());
AddChartBubble(isNew and showInitFibs and show_Fib_bubbles, Fib150a,  AsPercent(1.5) + "|" + AsPrice(Fib150a), Fib150a.TakeValueColor());
AddChartBubble(isNew and showInitFibs and show_Fib_bubbles, Fib180a,  AsPercent(1.8) + "|" + AsPrice(Fib180a), Fib180a.TakeValueColor());
AddChartBubble(isNew and showInitFibs and show_Fib_bubbles, Fib200a,  AsPercent(2) + "|" + AsPrice(Fib200a), Fib200a.TakeValueColor());

# "move over" the previously calculated Fibs to the new day

def FbRange = if inLastPeriod then FbRange[1] else if isNew then fibRg[1] else FbRange[1];
def prevFibRg = if inLastPeriod then prevFibRg[1] else FbRange;
def Fbneg100 = if inLastPeriod then Fbneg100[1] else if isNew then Fneg100a[1] else Fbneg100[1];
def Fbneg80 = if inLastPeriod then Fbneg80[1] else if isNew then Fneg80a[1] else Fbneg80[1];
def Fbneg50 = if inLastPeriod then Fbneg50[1] else if isNew then Fneg50a[1] else Fbneg50[1];
def Fbneg20 = if inLastPeriod then Fbneg20[1] else if isNew then Fneg20a[1] else Fbneg20[1];
def Fb0 = if inLastPeriod then Fb0[1] else if isNew then F0a[1] else Fb0[1];
def Fb20 = if inLastPeriod then Fb20[1] else if isNew then F20a[1] else Fb20[1];
def Fb50 = if inLastPeriod then Fb50[1] else if isNew then F50a[1] else Fb50[1];
def Fb80 = if inLastPeriod then Fb80[1] else if isNew then F80a[1] else Fb80[1];
def Fb100 = if inLastPeriod then Fb100[1] else if isNew then F100a[1] else Fb100[1];
def Fb120 = if inLastPeriod then Fb120[1] else if isNew then F120a[1] else Fb120[1];
def Fb150 = if inLastPeriod then Fb150[1] else if isNew then F150a[1] else Fb150[1];
def Fb180 = if inLastPeriod then Fb180[1] else if isNew then F180a[1] else Fb180[1];
def Fb200 = if inLastPeriod then Fb200[1] else if isNew then F200a[1] else Fb200[1];


def bubble_bar = if showOnlyLastPeriod then highest_bn else if bn < HighestAll(isNewbn) then isNewbn else highest_bn;
def show_Fibs = if show_Current_Period_Fibs then if !showOnlyLastPeriod then yes else
                     if bn >= HighestAll(isNewbn) then yes else no else no ;
def Fib_bubbles_on = show_Fibs and show_Fib_bubbles and bn == bubble_bar;

# extended upwards
plot Fib0up = if !(show_Fibs and dupe_Fibs_up) then na else Math(Fbneg100 + 2 * FbRange).MRound;
plot Fib20up = if !(show_Fibs and dupe_Fibs_up) then na else Math(Fbneg100 + 1.8 * FbRange).MRound;
plot Fib50up = if !(show_Fibs and dupe_Fibs_up) then na else Math(Fbneg100 + 1.5 * FbRange).MRound;
plot Fib80up = if !(show_Fibs and dupe_Fibs_up) then na else Math(Fbneg100 + 1.2 * FbRange).MRound;
plot Fib100up = if !(show_Fibs and dupe_Fibs_up) then na else Math(Fbneg100 + FbRange).MRound;
plot Fib120up = if !(show_Fibs and dupe_Fibs_up) then na else Math(Fbneg100 + .8 * FbRange).MRound;
plot Fib150up = if !(show_Fibs and dupe_Fibs_up) then na else Math(Fbneg100 + .5 * FbRange).MRound;
plot Fib180up = if !(show_Fibs and dupe_Fibs_up) then na else Math(Fbneg100 + .2 * FbRange).MRound;
# regular plots
plot Fibneg100 = if !show_Fibs then na else Fbneg100;
plot Fibneg80 = if !show_Fibs then na else Fbneg80;
plot Fibneg50 = if !show_Fibs then na else Fbneg50;
plot Fibneg20 = if !show_Fibs then na else Fbneg20;
plot Fib0 = if !show_Fibs then na else Fb0;
plot Fib20 = if !show_Fibs then na else Fb20;
plot Fib50 = if !show_Fibs then na else Fb50;
plot Fib80 = if !show_Fibs then na else Fb80;
plot Fib100 = if !show_Fibs then na else Fb100;
plot Fib120 = if !show_Fibs then na else Fb120;
plot Fib150 = if !show_Fibs then na else Fb150;
plot Fib180 = if !show_Fibs then na else Fb180;
plot Fib200 = if !show_Fibs then na else Fb200;
# extended downward
plot Fib180dn = if !(show_Fibs and dupe_Fibs_down) then na else Math(Fib200 - .2 * FbRange).MRound;
plot Fib150dn = if !(show_Fibs and dupe_Fibs_down) then na else Math(Fib200 - .5 * FbRange).MRound;
plot Fib120dn = if !(show_Fibs and dupe_Fibs_down) then na else Math(Fib200 - .8 * FbRange).MRound;
plot Fib100dn = if !(show_Fibs and dupe_Fibs_down) then na else Math(Fib200 - FbRange).MRound;
plot Fib80dn = if !(show_Fibs and dupe_Fibs_down) then na else Math(Fib200 - 1.2 * FbRange).MRound;
plot Fib50dn = if !(show_Fibs and dupe_Fibs_down) then na else Math(Fib200 - 1.5 * FbRange).MRound;
plot Fib20dn = if !(show_Fibs and dupe_Fibs_down) then na else Math(Fib200 - 1.8 * FbRange).MRound;
plot Fib0dn = if !(show_Fibs and dupe_Fibs_down) then na else Math(Fib200 - 2 * FbRange).MRound;

Fib0up.HideBubble();
Fib20up.HideBubble();
Fib50up.HideBubble();
Fib80up.HideBubble();
Fib100up.HideBubble();
Fib120up.HideBubble();
Fib150up.HideBubble();
Fib180up.HideBubble();
Fibneg100.HideBubble();
Fibneg80.HideBubble();
Fibneg50.HideBubble();
Fibneg20.HideBubble();
Fib0.HideBubble();
Fib20.HideBubble();
Fib50.HideBubble();
Fib80.HideBubble();
Fib100.HideBubble();
Fib120.HideBubble();
Fib150.HideBubble();
Fib180.HideBubble();
Fib200.HideBubble();
Fib180dn.HideBubble();
Fib150dn.HideBubble();
Fib120dn.HideBubble();
Fib100dn.HideBubble();
Fib80dn.HideBubble();
Fib50dn.HideBubble();
Fib20dn.HideBubble();
Fib0dn.HideBubble();

Fib0up.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib20up.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib50up.SetPaintingStrategy(PaintingStrategy.DASHES);
Fib80up.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib100up.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib120up.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib150up.SetPaintingStrategy(PaintingStrategy.DASHES);
Fib180up.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib0up.AssignValueColor(GetColor(Fib_Color));
Fib20up.AssignValueColor(GetColor(Fib_Color));
Fib50up.AssignValueColor(GetColor(Fib_Color));
Fib80up.AssignValueColor(GetColor(Fib_Color));
Fib100up.AssignValueColor(GetColor(Fib_Color));
Fib120up.AssignValueColor(GetColor(Fib_Color));
Fib150up.AssignValueColor(GetColor(Fib_Color));
Fib180up.AssignValueColor(GetColor(Fib_Color));
Fibneg100.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fibneg100.AssignValueColor(GetColor(Fib_Color));
Fibneg80.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fibneg80.AssignValueColor(GetColor(Fib_Color));
Fibneg50.SetPaintingStrategy(PaintingStrategy.DASHES);
Fibneg50.AssignValueColor(GetColor(Fib_Color));
Fibneg20.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fibneg20.AssignValueColor(GetColor(Fib_Color));
Fib0.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib0.AssignValueColor(GetColor(Fib_Color));
Fib20.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib20.AssignValueColor(GetColor(Fib_Color));
Fib50.SetPaintingStrategy(PaintingStrategy.DASHES);
Fib50.AssignValueColor(GetColor(Fib_Color));
Fib80.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib80.AssignValueColor(GetColor(Fib_Color));
Fib100.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib100.AssignValueColor(GetColor(Fib_Color));
Fib120.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib120.AssignValueColor(GetColor(Fib_Color));
Fib150.SetPaintingStrategy(PaintingStrategy.DASHES);
Fib150.AssignValueColor(GetColor(Fib_Color));
Fib180.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib180.AssignValueColor(GetColor(Fib_Color));
Fib200.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib200.AssignValueColor(GetColor(Fib_Color));
Fib0dn.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib20dn.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib50dn.SetPaintingStrategy(PaintingStrategy.DASHES);
Fib80dn.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib100dn.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib120dn.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib150dn.SetPaintingStrategy(PaintingStrategy.DASHES);
Fib180dn.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Fib0dn.AssignValueColor(GetColor(Fib_Color));
Fib20dn.AssignValueColor(GetColor(Fib_Color));
Fib50dn.AssignValueColor(GetColor(Fib_Color));
Fib80dn.AssignValueColor(GetColor(Fib_Color));
Fib100dn.AssignValueColor(GetColor(Fib_Color));
Fib120dn.AssignValueColor(GetColor(Fib_Color));
Fib150dn.AssignValueColor(GetColor(Fib_Color));
Fib180dn.AssignValueColor(GetColor(Fib_Color));


AddChartBubble(Fib_bubbles_on and dupe_Fibs_up, Fib0up,  AsPercent(0) + "|" + AsPrice(Fib0up), Fib0up.TakeValueColor());
AddChartBubble(Fib_bubbles_on and dupe_Fibs_up, Fib20up,  AsPercent(.2) + "|" + AsPrice(Fib20up), Fib20up.TakeValueColor());
AddChartBubble(Fib_bubbles_on and dupe_Fibs_up, Fib50up,  AsPercent(.5) + "|" + AsPrice(Fib50up), Fib50up.TakeValueColor());
AddChartBubble(Fib_bubbles_on and dupe_Fibs_up, Fib80up,  AsPercent(.8) + "|" + AsPrice(Fib80up), Fib80up.TakeValueColor());
AddChartBubble(Fib_bubbles_on and dupe_Fibs_up, Fib100up,  AsPercent(1) + "|" + AsPrice(Fib100up), Fib100up.TakeValueColor());
AddChartBubble(Fib_bubbles_on and dupe_Fibs_up, Fib120up,  AsPercent(1.2) + "|" + AsPrice(Fib120up), Fib120up.TakeValueColor());
AddChartBubble(Fib_bubbles_on and dupe_Fibs_up, Fib150up,  AsPercent(1.5) + "|" + AsPrice(Fib150up), Fib150up.TakeValueColor());
AddChartBubble(Fib_bubbles_on and dupe_Fibs_up, Fib180up,  AsPercent(1.8) + "|" + AsPrice(Fib180up), Fib180up.TakeValueColor());

AddChartBubble(Fib_bubbles_on, Fibneg100, AsPercent(-1) + "|" + AsPrice(Fibneg100), Fibneg100.TakeValueColor());
AddChartBubble(Fib_bubbles_on, Fibneg80,  AsPercent(-.8) + "|" + AsPrice(Fibneg80), Fibneg80.TakeValueColor());
AddChartBubble(Fib_bubbles_on, Fibneg50,  AsPercent(-.5) + "|" + AsPrice(Fibneg50), Fibneg50.TakeValueColor());
AddChartBubble(Fib_bubbles_on, Fibneg20,  AsPercent(-.2) + "|" + AsPrice(Fibneg20), Fibneg20.TakeValueColor());
AddChartBubble(Fib_bubbles_on, Fib0,  AsPercent(0) + "|" + AsPrice(Fib0), Fib0.TakeValueColor());
AddChartBubble(Fib_bubbles_on, Fib20,  AsPercent(.2) + "|" + AsPrice(Fib20), Fib20.TakeValueColor());
AddChartBubble(Fib_bubbles_on, Fib50,  AsPercent(.5) + "|" + AsPrice(Fib50), Fib50.TakeValueColor());
AddChartBubble(Fib_bubbles_on, Fib80,  AsPercent(.8) + "|" + AsPrice(Fib80), Fib80.TakeValueColor());
AddChartBubble(Fib_bubbles_on, Fib100,  AsPercent(1) + "|" + AsPrice(Fib100), Fib100.TakeValueColor());
AddChartBubble(Fib_bubbles_on, Fib120,  AsPercent(1.2) + "|" + AsPrice(Fib120), Fib120.TakeValueColor());
AddChartBubble(Fib_bubbles_on, Fib150,  AsPercent(1.5) + "|" + AsPrice(Fib150), Fib150.TakeValueColor());
AddChartBubble(Fib_bubbles_on, Fib180,  AsPercent(1.8) + "|" + AsPrice(Fib180), Fib180.TakeValueColor());
AddChartBubble(Fib_bubbles_on, Fib200,  AsPercent(2) + "|" + AsPrice(Fib200), Fib200.TakeValueColor());

AddChartBubble(Fib_bubbles_on and dupe_Fibs_down, Fib180dn,  AsPercent(1.8) + "|" + AsPrice(Fib180dn), Fib180dn.TakeValueColor());
AddChartBubble(Fib_bubbles_on and dupe_Fibs_down, Fib150dn,  AsPercent(1.5) + "|" + AsPrice(Fib150dn), Fib150dn.TakeValueColor());
AddChartBubble(Fib_bubbles_on and dupe_Fibs_down, Fib120dn,  AsPercent(1.2) + "|" + AsPrice(Fib120dn), Fib120dn.TakeValueColor());
AddChartBubble(Fib_bubbles_on and dupe_Fibs_down, Fib100dn,  AsPercent(1) + "|" + AsPrice(Fib100dn), Fib100dn.TakeValueColor());
AddChartBubble(Fib_bubbles_on and dupe_Fibs_down, Fib80dn,  AsPercent(.8) + "|" + AsPrice(Fib80dn), Fib80dn.TakeValueColor());
AddChartBubble(Fib_bubbles_on and dupe_Fibs_down, Fib50dn,  AsPercent(.5) + "|" + AsPrice(Fib50dn), Fib50dn.TakeValueColor());
AddChartBubble(Fib_bubbles_on and dupe_Fibs_down, Fib20dn,  AsPercent(.2) + "|" + AsPrice(Fib20dn), Fib20dn.TakeValueColor());
AddChartBubble(Fib_bubbles_on and dupe_Fibs_down, Fib0dn,  AsPercent(0) + "|" + AsPrice(Fib0dn), Fib0dn.TakeValueColor());

AddCloud(if !showClouds then na else Fib0up,if !showClouds then na else Fib20up,color.downtick);

AddCloud(if !showClouds then na else Fib80up,if !showClouds then na else Fib100up,color.uptick);
AddCloud(if !showClouds then na else Fib100up,if !showClouds then na else Fib120up,color.downtick);

AddCloud(if !showClouds then na else Fib180up,if !showClouds then na else Fibneg100,color.uptick);
AddCloud(if !showClouds then na else Fibneg100,if !showClouds then na else Fibneg80,color.downtick);

AddCloud(if !showClouds then na else Fibneg20,if !showClouds then na else Fib0,color.uptick);
AddCloud(if !showClouds then na else Fib0,if !showClouds then na else Fib20,color.downtick);

AddCloud(if !showClouds then na else Fib80,if !showClouds then na else Fib100,color.uptick);
AddCloud(if !showClouds then na else Fib100,if !showClouds then na else Fib120,color.downtick);

AddCloud(if !showClouds then na else Fib180,if !showClouds then na else Fib200,color.uptick);
AddCloud(if !showClouds then na else Fib200,if !showClouds then na else Fib180dn,color.downtick);

AddCloud(if !showClouds then na else Fib120dn,if !showClouds then na else Fib100dn,color.uptick);
AddCloud(if !showClouds then na else Fib100dn,if !showClouds then na else Fib80dn,color.downtick);

AddCloud(if !showClouds then na else Fib20dn,if !showClouds then na else Fib0dn,color.uptick);
 

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

I have a question regarding the OP study, let´s say i use this Auto Fib study on a 180 days hourly chart. Can those levels from the hourly be transferred and plotted onto a intraday chart like a 5min chart for example? Is this possible within thinkscript?
 
I have a question regarding the OP study, let´s say i use this Auto Fib study on a 180 days hourly chart. Can those levels from the hourly be transferred and plotted onto a intraday chart like a 5min chart for example? Is this possible within thinkscript?

After doing some research, it appears it´s possible to do what i am looking for in my request above so i am wondering if someone could help me code this into a study and i am willing to pay you for the job. Let me know and i will share my discord id and we can discuss more details.
 
I modified this code One minute it was working then it just quit. It shows no errors and did work for a while. Can someone take a look and tell me if I broke it???


Code:
#

input price = close;
input high = high;
input low = low;
input showPriceBubble = 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;

DefineGlobalColor("PriceBubble", Color.GRAY);
DefineGlobalColor("UpTrendBubble", Color.GRAY);
DefineGlobalColor("DownTrendBubble", Color.GRAY);



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.FIRM);
FibFan.SetDefaultColor(CreateColor(186, 182, 186));
FibFan.HideBubble();

def range =  a - b;

# You can add more retracement levels by copying the entire section below to the next plot section and naming a new coefficient? plus add the new input coefficient & ratio above in the upper most section

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.SetDefaultColor(CreateColor(247, 119, 226));
Retracement0.HideBubble();
AddChartBubble((showPriceBubble == yes and barnumber == istodaybarnumber), Retracement0, Concat( "$", Round(Retracement0, 2)), (GlobalColor("PriceBubble")), yes);
AddChartBubble((downward and barnumber == highnumberall), Retracement0, Concat( (Coefficient0 * 100), "%"),  (GlobalColor("DownTrenBubble")), yes);
AddChartBubble((upward and barnumber == lownumberall), Retracement0, Concat( (Coefficient0 * 100), "%"),  (GlobalColor("UpTrendBubble")), yes);

#copy above and input additional input ratios if desired

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.SetDefaultColor(CreateColor(247, 119, 226));
Retracement1.HideBubble();
AddChartBubble((showPriceBubble == yes and barnumber == istodaybarnumber), Retracement1, Concat( "$", Round(Retracement1, 2)), (GlobalColor("PriceBubble")), yes);
AddChartBubble((downward and barnumber == highnumberall), Retracement1, Concat( (coefficient_1 * 100), "%"), (GlobalColor("DownTrenBubble")), yes);
AddChartBubble((upward and barnumber == lownumberall), Retracement1, Concat( (coefficient_1 * 100), "%"), (GlobalColor("UpTrendBubble")), 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.SetDefaultColor(CreateColor(247, 119, 226));
Retracement2.HideBubble();
AddChartBubble((showPriceBubble == yes and barnumber == istodaybarnumber), Retracement2, Concat( "$", Round(Retracement2, 2)), (GlobalColor("PriceBubble")), yes);
AddChartBubble((downward and barnumber == highnumberall), Retracement2, Concat( (Coefficient_2 * 100), "%"), (GlobalColor("DownTrenBubble")), yes);
AddChartBubble((upward and barnumber == lownumberall), Retracement2, Concat( (Coefficient_2 * 100), "%"), (GlobalColor("UpTrendBubble")), yes);


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.SetDefaultColor(CreateColor(247, 119, 226));
Retracement3.HideBubble();
AddChartBubble(( showPriceBubble == yes and barnumber == istodaybarnumber), Retracement3, Concat( "$", Round(Retracement3, 2)), (GlobalColor("PriceBubble")), yes);
AddChartBubble((downward and barnumber == highnumberall), Retracement3, Concat( (Coefficient_3 * 100), "%"), (GlobalColor("DownTrenBubble")), yes);
AddChartBubble((upward and barnumber == lownumberall), Retracement3, Concat( (Coefficient_3 * 100), "%"), (GlobalColor("UpTrendBubble")), 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.SetDefaultColor(CreateColor(247, 119, 226));
Retracement4.HideBubble();
AddChartBubble((showPriceBubble == yes and barnumber == istodaybarnumber), Retracement4, Concat( "$", Round(Retracement4, 2)), (GlobalColor("PriceBubble")), yes);
AddChartBubble((downward and barnumber == highnumberall), Retracement4, Concat( (Coefficient_4 * 100), "%"), (GlobalColor("DownTrenBubble")), yes);
AddChartBubble((upward and barnumber == lownumberall), Retracement4, Concat( (Coefficient_4 * 100), "%"), (GlobalColor("UpTrendBubble")), 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.SetDefaultColor(CreateColor(247, 119, 226));
Retracement5.HideBubble();
AddChartBubble((showPriceBubble == yes and barnumber == istodaybarnumber), Retracement5, Concat( "$", Round(Retracement5, 2)), (GlobalColor("PriceBubble")), yes);
AddChartBubble((downward and barnumber == highnumberall), Retracement5, Concat( (Coefficient_5 * 100), "%"), (GlobalColor("DownTrenBubble")), yes);
AddChartBubble((upward and barnumber == lownumberall), Retracement5, Concat( (Coefficient_5 * 100), "%"), (GlobalColor("UpTrendBubble")), 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.SetDefaultColor(CreateColor(247, 119, 226));
Retracement6.HideBubble();
AddChartBubble((showPriceBubble == yes and barnumber == istodaybarnumber), Retracement6, Concat( "$", Round(Retracement6, 2)), (GlobalColor("PriceBubble")), yes);
AddChartBubble((downward and barnumber == highnumberall), Retracement6, Concat( (Coefficient_6 * 100), "%"), (GlobalColor("DownTrenBubble")), yes);
AddChartBubble((upward and barnumber == lownumberall), Retracement6, Concat( (Coefficient_6 * 100), "%"), (GlobalColor("UpTrendBubble")), 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");

# Fibonacci Time Series
rec bar1 = if lownumber == BarNumber()
              then BarNumber()
              else bar1[1];
rec bars = if BarNumber()[1] == bar1[1]
              then 2
              else if barnumber[1] > bar1[1]
              then bars[1] + 1
              else 0;
def coeff = Sqrt(5);
def smallest = 5;
def n = Floor(Log(bars * coeff + 0.5) / Log((1 + Sqrt(5)) / 2));
def inSeries = n != n[1] and bars >= smallest;
def Series = if inSeries
                then bars
                else Double.NaN;
AddVerticalLine(Series, "FTS: ( " + Series + ")", Color.LIGHT_ORANGE, Curve.SHORT_DASH);
 
Last edited:
Can anyone help me understand how to read these lines. Sometimes they go like in post, sometimes they both trend down, sometimes they both trend up. If I were to guess, both trending down would mean market is going down, and both going up would mean market gong up. So If thata being true what does the below mean. Sometimes top one goes up and bottom one goes down.
 
That looks like a zigzag indicator. Meaning it normalizes the move of the stock into a line, the line won't change direction until a breaks a threshold. Now there seems to be different lines probably with dofferent threshold inputs thats why some of them "zigzag" more than others.
 
I was referring to the Red lines, one moving down and the other moving up and crossing. there from the Fibonacci
 
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
Where did you get those labels for the Previous Close, VWAP and Moving Averages?
 
Created by RyanHendricks.

Z7hCOks.png


thinkScript Code

Rich (BB code):
#hint Price: Price used in the alerts on crossing retracement lines. <b>(Default is Close)</b>
#hint onExpansion: Determines if the retracement lines are projected past the current bar into the right side expansion <b>(Default is Yes)</b>
#hint Extend_to_left: Determines if the retracement lines are extended to the left side of the chart. <b>(Default is No)</b>

#hint Coefficient0: Retracement Line 0: Retracement from the highest high to the lowest low.<b>(Default is 0%)</b>
#hint Coefficient_1: Retracement Line 1: Retracement from the highest high to the lowest low.<b>(Default is 23.6%)</b>
#hint Coefficient_2: Retracement Line 2: Retracement from the highest high to the lowest low.<b>(Default is 38.2%)</b>
#hint Coefficient_3: Retracement Line 3: Retracement from the highest high to the lowest low.<b>(Default is 50%)</b>
#hint Coefficient_4: Retracement Line 4: Retracement from the highest high to the lowest low.<b>(Default is 61.8%)</b>
#hint Coefficient_5: Retracement Line 5: Retracement from the highest high to the lowest low.<b>(Default is 78.6%)</b>
#hint Coefficient_6: Retracement Line 6: Retracement from the highest high to the lowest low.<b>(Default is 100%)</b>

#wizard input: Price
#wizard text: Inputs: Price:
#wizard input: onExpansion
#wizard text: onExpansion:
#wizard input: Extend_to_left
#wizard text: Extend_to_left:
#wizard input: Coefficient0
#wizard text: Coefficient0:
#wizard input: Coefficient_1
#wizard text: Coefficient_1:
#wizard input: Coefficient_2
#wizard text: Coefficient_2:
#wizard input: Coefficient_3
#wizard text: Coefficient_3:
#wizard input: Coefficient_4
#wizard text: Coefficient_4:
#wizard input: Coefficient_5
#wizard text: Coefficient_5:
#wizard input: Coefficient_6
#wizard text: Coefficient_6:

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.red);
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.red);
retracement0.hidebubble();
#AddChartBubble((barnumber == istodaybarnumber +10), retracement0, concat( "$", round(retracement0, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement0, concat( (coefficient0 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement0, concat( (coefficient0 * 100), "%"), color.red, 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.red);
retracement1.hidebubble();
#AddChartBubble((barnumber == istodaybarnumber+10), retracement1, concat( "$", round(retracement1, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement1, concat( (coefficient_1 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement1, concat( (coefficient_1 * 100), "%"), color.red, 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.red);
retracement2.hidebubble();
#AddChartBubble((barnumber == istodaybarnumber+10), retracement2, concat( "$", round(retracement2, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement2, concat( (coefficient_2 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement2, concat( (coefficient_2 * 100), "%"), color.red, yes);

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+10), retracement3, concat( "$", round(retracement3, 2)), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement3, concat( (coefficient_3 * 100), "%"), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement3, concat( (coefficient_3 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement3, concat( (coefficient_3 * 100), "%"), color.red, 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.red);
retracement4.hidebubble();
#AddChartBubble((barnumber == istodaybarnumber+10), retracement4, concat( "$", round(retracement4, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement4, concat( (coefficient_4 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement4, concat( (coefficient_4 * 100), "%"), color.red, 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.red);
retracement5.hidebubble();
#AddChartBubble((barnumber == istodaybarnumber+10), retracement5, concat( "$", round(retracement5, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement5, concat( (coefficient_5 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement5, concat( (coefficient_5 * 100), "%"), color.red, 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.red);
retracement6.hidebubble();
#AddChartBubble((barnumber == istodaybarnumber+10), retracement6, concat( "$", round(retracement6, 2)), color.red, yes);

AddChartBubble((downward and barnumber == highnumberall), retracement6, concat( (coefficient_6 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement6, concat( (coefficient_6 * 100), "%"), color.red, 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");

Shareable Link

https://tos.mx/Fz8Ss0
is there a way I can display the coefficient on right side , when we draw in chart manually we can configure this but not sure how with code
 
is there a way I can display the coefficient on right side , when we draw in chart manually we can configure this but not sure how with code
never mind
here is the code
AddChartBubble((downward and !IsNaN(close) and IsNaN(close[-1])), retracement1, concat( (coefficient_1 * 100), "%") + concat( "$", round(retracement1, 2)), color.yellow, yes);
AddChartBubble((upward and !IsNaN(close) and IsNaN(close[-1])), retracement1, concat( (coefficient_1 * 100), "%") + concat( "$", round(retracement1, 2)), color.yellow, yes);
 
never mind
here is the code
AddChartBubble((downward and !IsNaN(close) and IsNaN(close[-1])), retracement1, concat( (coefficient_1 * 100), "%") + concat( "$", round(retracement1, 2)), color.yellow, yes);
AddChartBubble((upward and !IsNaN(close) and IsNaN(close[-1])), retracement1, concat( (coefficient_1 * 100), "%") + concat( "$", round(retracement1, 2)), color.yellow, yes);
still it is not right aligned when compare to manual drawing

Let me know possible options
 
if you want to display a variable value on a future bar, you will need a way to look back x bars and read the variable.
one way is, after the condition triggers, start a variable counting. the count number will be an offset for the variable.

retracement1 is the trigger for the bubble. so when it triggers, start a counter.
here is a reference code. replace plot with def.

extend line past last bar
https://usethinkscript.com/threads/extend-target-lines.321/
horserider
Jul 9, 2019
post #2
 
still it is not right aligned when compare to manual drawing

Let me know possible options
See if this helps
Code:
AddChartBubble((downward and barnumber()==highestall(barnumber())), retracement1, concat( (coefficient_1 * 100), "%") + concat( "$", round(retracement1, 2)), color.yellow, yes);
AddChartBubble((upward and barnumber()==highestall(barnumber())), retracement1, concat( (coefficient_1 * 100), "%") + concat( "$", round(retracement1, 2)), color.yellow, yes);
 
FIB FANS, ADDED THE LESSER USED .886 LEVEL, PLOTS FIB FANS FROM THE LOW TO THE HIGH.

Ns8eXLk.png


Code:
##Begin##



#hint: <b>Fibonacci Fan lines</b>\nFibonacci Fan lines are trendlines based on Fibonacci retracement points. Rising fan lines extend up from a trough and pass through retracement based on the advance (lowest low to highest high or on the falling fan lines: highest high to lowest low). These fan lines can then be used to estimate support levels or potential reversal zones. Falling fan lines can then be used to estimate resistance levels or potential reversal zones.



#hint Price: Price used in the alerts on crossing of the fans. <b>(Default is Close)</b>

#hint onExpansion: Determines if the fan lines are projected past the current bar into the right side expansion <b>(Default is Yes)</b>

#hint Coefficient1: Fan Line 1: Trough to 38.2% retracement on rising fans.  \nPeak to 38.2% Coefficient on falling fans. <b>(Default is 38.2%)</b>

#hint Coefficient_2: Fan Line 2: \nTrough to 50% retracement on rising fans.  \nPeak to 50% Coefficient on falling fans. <b>(Default is 50%)</b>

#hint Coefficient_3: Fan Line 3: \nTrough to 61.8% retracement on rising fans.  \nPeak to 61.8% Coefficient on falling fans. <b>(Default is 61.8%)</b>



#wizard input: Price

#wizard text: Inputs: Price:

#wizard input: onExpansion

#wizard text: onExpansion:

#wizard input: Coefficient1

#wizard text: Coefficient1 :

#wizard input: Coefficient_2

#wizard text: Coefficient_2:

#wizard input: Coefficient_3 

#wizard text: Coefficient_3:



input price = close;

input high = high;

input low = low;

input onExpansion = Yes;

input Coefficient1 = .236;

input Coefficient_2 = .382;

input Coefficient_3 = .5;

input Coefficient_4 = .618;

input Coefficient_5 = .786;

input Coefficient_6 = .886;

input Coefficient_7 = 0;


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 low1 =  b + ((b - a) * Coefficient1);

def low2 =  b + ((b - a) * Coefficient_2);

def low3 = b + ((b - a) * Coefficient_3);

def low4 =  b + ((b - a) * Coefficient_4);

def low5 =  b + ((b - a) * Coefficient_5);

def low6 =  b + ((b - a) * Coefficient_6);

def low7 =  b + ((b - a) * Coefficient_7);


def high1 =  a - ((a - b) * Coefficient1);

def high2 =  a - ((a - b) * Coefficient_2);

def high3 = a - ((a - b) * Coefficient_3);

def high4 =  a - ((a - b) * Coefficient_4);

def high5 =  a - ((a - b) * Coefficient_5);

def high6 = a - ((a - b) * Coefficient_6);

def high7 = a - ((a - b) * Coefficient_7);


def x = AbsValue(lownumberall - highnumberall );



def slope = (a - b) / x;

def slope1 = (high1 - b) / x;

def slope2 = (high2 - b) / x;

def slope3 = (high3 - b) / x;

def slope4 = (high4 - b) / x;

def slope5 = (high5 - b) / x;

def slope6 = (high6 - b) / x;

def slope7 = (high7 - b) / x;


def slopelow = (b - a) / x;

def slopelow1 = (low1 - b) / x;

def slopelow2 = (low2 - b) / x;

def slopelow3 = (low3 - b) / x;

def slopelow4 = (low4 - b) / x;

def slopelow5 = (low5 - b) / x;

def slopelow6 = (low6 - b) / x;

def slopelow7 = (low7 - b) / 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 line1 = b + (slope1 * (barnumber - lownumber));

def line2 = b + (slope2 * (barnumber - lownumber));

def line3 = b + (slope3 * (barnumber - lownumber));

def line4 = b + (slope4 * (barnumber - lownumber));

def line5 = b + (slope5 * (barnumber - lownumber));

def line6 = b + (slope6 * (barnumber - lownumber));

def line7 = b + (slope7 * (barnumber - lownumber));


def linelow = a + (slopelow * (barnumber - highnumber));

def line1low = a + (slopelow1 * (barnumber - highnumber));

def line2low = a + (slopelow2 * (barnumber - highnumber));

def line3low = a + (slopelow3 * (barnumber - highnumber));

def line4low = a + (slopelow4 * (barnumber - highnumber));

def line5low = a + (slopelow5 * (barnumber - highnumber));

def line6low = a + (slopelow6 * (barnumber - highnumber));

def line7low = a + (slopelow7 * (barnumber - highnumber));


def currentlinelow = if barnumber <= istodaybarnumber then linelow else Double.NaN;

def currentline1low = if barnumber <= istodaybarnumber then line1low else Double.NaN;

def currentline2low = if barnumber <= istodaybarnumber then line2low else Double.NaN;

def currentline3low = if barnumber <= istodaybarnumber then line3low else Double.NaN;

def currentline4low = if barnumber <= istodaybarnumber then line4low else Double.NaN;

def currentline5low = if barnumber <= istodaybarnumber then line5low else Double.NaN;

def currentline6low = if barnumber <= istodaybarnumber then line6low else Double.NaN;

def currentline7low = if barnumber <= istodaybarnumber then line7low else Double.NaN;


def currentline = if barnumber <= istodaybarnumber then line else Double.NaN;

def currentline1 = if barnumber <= istodaybarnumber then line1 else Double.NaN;

def currentline2 = if barnumber <= istodaybarnumber then line2 else Double.NaN;

def currentline3 = if barnumber <= istodaybarnumber then line3 else Double.NaN;

def currentline4 = if barnumber <= istodaybarnumber then line4 else Double.NaN;

def currentline5 = if barnumber <= istodaybarnumber then line5 else Double.NaN;

def currentline6 = if barnumber <= istodaybarnumber then line6 else Double.NaN;

def currentline7 = if barnumber <= istodaybarnumber then line7 else Double.NaN;


plot FibFan =  if  downward and onExpansion then linelow else if downward then currentlinelow else if upward and onExpansion then line else if upward then currentline else Double.NaN;

FibFan.SetStyle(Curve.SHORT_DASH);

FibFan.AssignValueColor(Color.RED);



plot "Coefficient 1" =  if (downward and onExpansion) then line1low else if downward then currentline1low else if upward and onExpansion then line1 else if upward then currentline1 else Double.NaN;

"Coefficient 1".SetStyle(Curve.FIRM);

"Coefficient 1".AssignValueColor(Color.RED);

plot "Coefficient 2" = if downward and onExpansion then line2low else if downward then currentline2low else if upward and onExpansion then line2 else if upward then currentline2 else Double.NaN;

"Coefficient 2".AssignValueColor(Color.RED);

"Coefficient 2".SetStyle(Curve.FIRM);

plot "Coefficient 3" =  if downward and onExpansion then line3low else if downward then currentline3low else if upward and onExpansion then line3 else if upward then currentline3  else Double.NaN;

"Coefficient 3".AssignValueColor(Color.RED);

"Coefficient 3".SetStyle(Curve.FIRM);

plot "Coefficient 4" =  if (downward and onExpansion) then line4low else if downward then currentline4low else if upward and onExpansion then line4 else if upward then currentline4 else Double.NaN;

"Coefficient 4".SetStyle(Curve.FIRM);

"Coefficient 4".AssignValueColor(Color.RED);

plot "Coefficient 5" = if downward and onExpansion then line5low else if downward then currentline5low else if upward and onExpansion then line5 else if upward then currentline5 else Double.NaN;

"Coefficient 5".AssignValueColor(Color.RED);

"Coefficient 5".SetStyle(Curve.FIRM);

plot "Coefficient 6" =  if downward and onExpansion then line6low else if downward then currentline6low else if upward and onExpansion then line6 else if upward then currentline6  else Double.NaN;

"Coefficient 6".AssignValueColor(Color.RED);

"Coefficient 6".SetStyle(Curve.FIRM);

plot "Coefficient 7" =  if downward and onExpansion then line7low else if downward then currentline7low else if upward and onExpansion then line7 else if upward then currentline7  else Double.NaN;

"Coefficient 7".AssignValueColor(Color.RED);

"Coefficient 7".SetStyle(Curve.FIRM);

addCloud("coefficient 1", "coefficient 2", color.light_red);

addCloud("coefficient 2", "coefficient 3", Color.LIGHT_GREEN);

addCloud("coefficient 3", "coefficient 4", Color.LIGHT_ORANGE);

addCloud("coefficient 4", "coefficient 5", Color.CYAN);

addCloud("coefficient 5", "coefficient 6", Color.VIOLET);

addCloud("coefficient 1", "coefficient 7", Color.LIME);


Alert((price crosses below "Coefficient 1") , "Price crosses below Coefficient 1");

Alert((price crosses below "Coefficient 2") , "Price crosses below Coefficient 2");

Alert((price crosses below "Coefficient 3") , "Price crosses below Coefficient 3");

Alert((price crosses above "Coefficient 4") , "Price crosses above Coefficient 1");

Alert((price crosses above "Coefficient 5") , "Price crosses above Coefficient 2");

Alert((price crosses above "Coefficient 6") , "Price crosses above Coefficient 3");

##End##
Hey German
I have the same ideals as you when It comes to things such as Fibonacci and have been developing something quite interesting, would like to speak to you if you are in the discord server.
 
Hey German
I have the same ideals as you when It comes to things such as Fibonacci and have been developing something quite interesting, would like to speak to you if you are in the discord server.
I have also developed extremely interesting thing using the fibonacci, I am not on discord but you can reach me on Twitter @germanbrito17
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
349 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