Auto Fib (Fibonacci) Levels Indicator for ThinkorSwim

Fibonacci Uptrend Retracement Scan
Since the market is currently in an uptrend, my assumption is that you'd like to scan for uptrend stocks that have retraced to either the 38.2%, 50%, or 61.8% levels. The way the code is written, it also has the capability to calculate retracement levels for downtrending stocks. That said, I have converted the code base you posted earlier to scan for uptrending stocks that have made a 38.2% retracement.

Code:
# Fibonacci Uptrend Retracement Scan
# tomsk
# 1.3.2020

#hint coefficient_0: 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>

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

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;

def range = a - b;

def value0 = range * coefficient_0;
def value1 = range * coefficient_1;
def value2 = range * coefficient_2;
def value3 = range * coefficient_3;
def value4 = range * coefficient_4;
def value5 = range * coefficient_5;
def value6 = range * coefficient_6;

def condition1 = downward and barnumber >= highnumberall;
def condition2 = upward and barnumber >= lownumberall;

def Retracement0 = if condition1 then highestall(b + value0) else if condition2 then highestall(a - value0) else double.nan;
def Retracement1 = if condition1 then highestall(b + value1) else if condition2 then highestall(a - value1) else double.nan;
def Retracement2 = if condition1 then highestall(b + value2) else if condition2 then highestall(a - value2) else double.nan;
def Retracement3 = if condition1 then highestall(b + value3) else if condition2 then highestall(a - value3) else double.nan;
def Retracement4 = if condition1 then highestall(b + value4) else if condition2 then highestall(a - value4) else double.nan;
def Retracement5 = if condition1 then highestall(b + value5) else if condition2 then highestall(a - value5) else double.nan;
def Retracement6 = if condition1 then highestall(b + value6) else if condition2 then highestall(a - value6) else double.nan;

plot scan = close crosses above retracement2 and upward;

# End Fibonacci Uptrend Retracement Scan


In the event you'd like to scan for deeper retracement levels,, all you got to do is to revise the following line to reflect the level you'd like to scan for. The 50% retracement level is held by the variable retracement3 while that for 61.8% is help by the variable retracement4. Scanning the S&P 500 at the 38.2% retracement level, these is currently only 1 result. At the 50%, there are 2 results.

Code:
plot scan = close crosses above retracement2 and upward;
How does it know the time frame where the fibonacci is plotted from? If on the daily is it calculating from the most recent pivot high and low?
 
How does it know the time frame where the fibonacci is plotted from? If on the daily is it calculating from the most recent pivot high and low?
The post that you quoted is written for a scan. Scans filter on whatever aggregation you set in the scan hacker.
 
I want to display only the price on the right sided bubble instead of displaying both price & fib %. How can i modify this code to show only the price? @SleepyZ

Code:
AddChartBubble(show_bubbles_right and (downward and BarNumber() == HighestAll(BarNumber())), retracement1, Concat( (coefficient_1 * 100), "%\n") + Concat( "$", Round(retracement1, 2)), createcolor(51,153,255), yes);
AddChartBubble(show_bubbles_right and (upward and BarNumber() == HighestAll(BarNumber())), retracement1, Concat( (coefficient_1 * 100), "%\n") + Concat( "$", Round(retracement1, 2)), createcolor(51,153,255), yes);
 
I want to display only the price on the right sided bubble instead of displaying both price & fib %. How can i modify this code to show only the price? @SleepyZ

Code:
AddChartBubble(show_bubbles_right and (downward and BarNumber() == HighestAll(BarNumber())), retracement1, Concat( (coefficient_1 * 100), "%\n") + Concat( "$", Round(retracement1, 2)), createcolor(51,153,255), yes);
AddChartBubble(show_bubbles_right and (upward and BarNumber() == HighestAll(BarNumber())), retracement1, Concat( (coefficient_1 * 100), "%\n") + Concat( "$", Round(retracement1, 2)), createcolor(51,153,255), yes);

This should work. I have not tested it as I do not know what script you used.

Ruby:
AddChartBubble(show_bubbles_right and (downward and BarNumber() == HighestAll(BarNumber())), retracement1, Concat( "$", Round(retracement1, 2)), createcolor(51,153,255), yes);
AddChartBubble(show_bubbles_right and (upward and BarNumber() == HighestAll(BarNumber())), retracement1, Concat( "$", Round(retracement1, 2)), createcolor(51,153,255), yes);
 
Hello everyone,

I need help. Im not skilled with coding at all and have an idea for an indicator for auto fibs. I want to build an indicator that plots the days (or time aggregations) high and low, that adjusts as time progresses. Also want the 50% of in between the lines as well as the 61.8% 32.8% and the PT of -23, -68 and -100 (the topline is considered the 0 line). obviously there would need to be two versions, one for longs, and one for shorts. Anyone come across this before?
Thanks a million
 
Hello everyone,

I need help. Im not skilled with coding at all and have an idea for an indicator for auto fibs. I want to build an indicator that plots the days (or time aggregations) high and low, that adjusts as time progresses. Also want the 50% of in between the lines as well as the 61.8% 32.8% and the PT of -23, -68 and -100 (the topline is considered the 0 line). obviously there would need to be two versions, one for longs, and one for shorts. Anyone come across this before?
Thanks a million

The followiing link has multiple options for how to display fibonacci lines. If you see one that is close to what you want, then it would help if you would post a chart image using one with whatever you would like changed and/or added.

https://usethinkscript.com/threads/auto-fib-fibonacci-levels-indicator-for-thinkorswim.14/post-93927
 
The followiing link has multiple options for how to display fibonacci lines. If you see one that is close to what you want, then it would help if you would post a chart image using one with whatever you would like changed and/or added.

https://usethinkscript.com/threads/auto-fib-fibonacci-levels-indicator-for-thinkorswim.14/post-93927

I did make one improvement to the linked script and is updated below. It will now flip the high/low from 0/1 when high is latest bar and 1/0 when low is latest. The fib lines between 0/1 will flip also.

The image is a Range chart with the developing rthrs high/low Fib code and cyan/red lines representing the daily regular trading hours opens/closes.
Capture.jpg
Ruby:
#FibChoices v2
#Request usethinkscript.com @theelderwand to duplicate a swimdicators video's chart's indicator
#BLT 20191224

#v1 20191228 per request @zeek, changed time range method so that timerange_begin/timerange_end inputs would allow for post close of prior day, current day premarket, and custom user time ranges, with the Fibonacci lines drawn across the entire chart.


input method = {default aggregation, developing_reg_thrs, developing_ext_thrs, time_range};

input aggregation              = AggregationPeriod.DAY;
input aggregation_periodsback  = 0;

input timerange_begin  = 0930;
input timerange_end    = 1600;
# Examples: pre-market setting: 0000,0929; previous close through pre-market: 1600,0929;
# intraday opening range: 0930,1030

input display_upper_extended_fibs = no;
input display_lower_extended_fibs = no;


input showchart_bubbles = yes;
input bubble_option     = {default fiblevel, pricelevel};
input bubblemover       = 1; #used to move the bubble left and right

def bn = BarNumber();
#Time Range - Determines High/Low Where TimeRange_Begin Times are Between 1600 and 2359 Following the Prior Day's Close
def globexOpen   = if (if GetDayOfWeek(GetYYYYMMDD()) == 1 then SecondsFromTime(timerange_begin) >= 0 else SecondsFromTime(timerange_begin) >= 0) or SecondsFromTime(timerange_end) < 0 then 1 else 0;
def globexReset  = if globexOpen and !globexOpen[1] then 1 else 0;
def globexHigh   = CompoundValue(1, If((high > globexHigh[1] and globexOpen) or globexReset, high, globexHigh[1]), high);
def globexLow    = CompoundValue(1, If((low < globexLow[1] and globexOpen) or globexReset, low, globexLow[1]), low);
def globexhighbn = if high == (globexHigh) then bn else globexhighbn[1];
def globexlowbn  = if low == (globexLow) then bn else globexlowbn[1];

#Time Range - Determines High/Low with TimeRange_Begin Times From 0000 for PreMarket, Current Day or Intraday Pereiods
def day     = GetDay() == GetLastDay();
def lastday = if day and SecondsFromTime(timerange_begin) >= 0 then bn else Double.NaN;
def hhamt   = if day and bn == LowestAll(lastday) then high else if SecondsFromTime(timerange_end) <= 0 then Max(high, hhamt[1]) else hhamt[1];
def hhbn    = if high == (hhamt) then bn else hhbn[1];
def llamt   = if day and bn == LowestAll(lastday)  then low else if SecondsFromTime(timerange_end) <= 0 then Min(low, llamt[1]) else llamt[1];
def llbn    = if low == (llamt) then bn else llbn[1];

#Fibonacci High/Lows Determined based upon input method selected
def hh;
def ll;

switch (method){
#
case aggregation:
    hh = high(period = aggregation)[aggregation_periodsback];
    ll = low(period = aggregation)[aggregation_periodsback];
#
case developing_reg_thrs:
    hh = if GetTime() crosses above RegularTradingStart(GetYYYYMMDD()) then high else if GetTime() > RegularTradingStart(GetYYYYMMDD()) and high > hh[1] then high else hh[1];
    ll = if GetTime() crosses above RegularTradingStart(GetYYYYMMDD()) then low else if GetTime() > RegularTradingStart(GetYYYYMMDD()) and low < ll[1] then low else ll[1];
#
case developing_ext_thrs:
    hh = if GetTime() crosses above RegularTradingEnd(GetYYYYMMDD()) then high else if high > hh[1] then high else hh[1];
    ll = if GetTime() crosses above RegularTradingEnd(GetYYYYMMDD()) then low else if low < ll[1] then low else ll[1];
#
case time_range:
#Lines will display across the entire chart
    hh = if Between(timerange_begin, 1600, 2359) then HighestAll(if BarNumber() == HighestAll(globexhighbn) then globexHigh else Double.NaN) else HighestAll(if bn == HighestAll(hhbn) then (hhamt) else Double.NaN);
    ll = if Between(timerange_begin, 1600, 2359) then LowestAll(if BarNumber() == HighestAll(globexlowbn) then globexLow else Double.NaN) else LowestAll(if bn == HighestAll(llbn) then llamt else Double.NaN);

}


#Fibonacci Line Plots
def fib1 = .236;
def fib2 = .382;
def fib3 = .500;
def fib4 = .618;
def fib5 = .764;

def range  = hh - ll;
def f1   = ll + range * fib1;
def f2   = ll + range * fib2;
def f3   = ll + range * fib3;
def f4   = ll + range * fib4;
def f5   = ll + range * fib5;
def hh1  = hh;
def ll1  = ll;
def ff1  = f1;
def ff2  = f2;
def ff3  = f3;
def ff4  = f4;
def ff5  = f5;

input fib_line_choice = {default horizontal, points, dashes};
def paintingStrategy = if fib_line_choice == fib_line_choice.horizontal then PaintingStrategy.HORIZONTAL else if fib_line_choice == fib_line_choice.points then PaintingStrategy.POINTS else PaintingStrategy.DASHES;

plot hhp = hh1;
hhp.SetPaintingStrategy(paintingStrategy);
hhp.SetDefaultColor(Color.GREEN);
hhp.SetLineWeight(1);

plot llp =  ll1;
llp.SetPaintingStrategy(paintingStrategy);
llp.SetDefaultColor(Color.RED);
llp.SetLineWeight(1);

plot f1p =  ff1;
f1p.SetPaintingStrategy(paintingStrategy);
f1p.SetDefaultColor(Color.YELLOW);
f1p.SetLineWeight(1);

plot f2p =  ff2;
f2p.SetPaintingStrategy(paintingStrategy);
f2p.SetDefaultColor(Color.YELLOW);
f2p.SetLineWeight(1);

plot f3p =  ff3;
f3p.SetPaintingStrategy(paintingStrategy);
f3p.SetDefaultColor(Color.WHITE);
f3p.SetLineWeight(1);

plot f4p = ff4;
f4p.SetPaintingStrategy(paintingStrategy);
f4p.SetDefaultColor(Color.YELLOW);
f4p.SetLineWeight(1);

plot f5p =  ff5;
f5p.SetPaintingStrategy(paintingStrategy);
f5p.SetDefaultColor(Color.YELLOW);
f5p.SetLineWeight(1);

#Fibonacci - Upper Extended Fib Lines
plot uhhp = if display_upper_extended_fibs == no then Double.NaN else range + hh1;
uhhp.SetPaintingStrategy(paintingStrategy);
uhhp.SetDefaultColor(Color.GREEN);
uhhp.SetLineWeight(1);

plot uf1p = if  display_upper_extended_fibs == no then Double.NaN else range + ff1;
uf1p.SetPaintingStrategy(paintingStrategy);
uf1p.SetDefaultColor(Color.YELLOW);
uf1p.SetLineWeight(1);

plot uf2p = if  display_upper_extended_fibs == no then Double.NaN else range + ff2;
uf2p.SetPaintingStrategy(paintingStrategy);
uf2p.SetDefaultColor(Color.YELLOW);
uf2p.SetLineWeight(1);

plot uf3p = if  display_upper_extended_fibs == no then Double.NaN else range + ff3;
uf3p.SetPaintingStrategy(paintingStrategy);
uf3p.SetDefaultColor(Color.WHITE);
uf3p.SetLineWeight(1);

plot uf4p = if  display_upper_extended_fibs == no then Double.NaN else range + ff4;
uf4p.SetPaintingStrategy(paintingStrategy);
uf4p.SetDefaultColor(Color.YELLOW);
uf4p.SetLineWeight(1);

plot uf5p = if  display_upper_extended_fibs == no then Double.NaN else range + ff5;
uf5p.SetPaintingStrategy(paintingStrategy);
uf5p.SetDefaultColor(Color.YELLOW);
uf5p.SetLineWeight(1);

#Fibonacci - Lower Extended Fib Lines
plot Lllp = if  display_lower_extended_fibs == no then Double.NaN else ll - range;
Lllp.SetPaintingStrategy(paintingStrategy);
Lllp.SetDefaultColor(Color.RED);
Lllp.SetLineWeight(1);

plot Lf1p = if  display_lower_extended_fibs == no then Double.NaN else ll - range * fib1;
Lf1p.SetPaintingStrategy(paintingStrategy);
Lf1p.SetDefaultColor(Color.YELLOW);
Lf1p.SetLineWeight(1);

plot Lf2p = if display_lower_extended_fibs == no then Double.NaN else ll - range * fib2;
Lf2p.SetPaintingStrategy(paintingStrategy);
Lf2p.SetDefaultColor(Color.YELLOW);
Lf2p.SetLineWeight(1);

plot Lf3p = if display_lower_extended_fibs == no then Double.NaN else ll - range * fib3;
Lf3p.SetPaintingStrategy(paintingStrategy);
Lf3p.SetDefaultColor(Color.WHITE);
Lf3p.SetLineWeight(1);

plot Lf4p = if  display_lower_extended_fibs == no then Double.NaN else ll - range * fib4;
Lf4p.SetPaintingStrategy(paintingStrategy);
Lf4p.SetDefaultColor(Color.YELLOW);
Lf4p.SetLineWeight(1);

plot Lf5p = if display_lower_extended_fibs == no then Double.NaN else ll - range * fib5;
Lf5p.SetPaintingStrategy(paintingStrategy);
Lf5p.SetDefaultColor(Color.YELLOW);
Lf5p.SetLineWeight(1);

#Bubbles Displaying Fib Levels in Right Expansion
def n   = bubblemover;
def n1  = n + 1;
def xx=if highestall(hhbn[n1]) < highestall(llbn[n1]) then 1 else 0;
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), hhp[n1], if highestall(hhbn[n1]) < highestall(llbn[n1]) then 1 else 0, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), ff1[n1], if xx[n1]==0 then .764 else .236, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), ff2[n1], if xx[n1]==0 then .618 else .382, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), ff3[n1], fib3[n1], Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), ff4[n1], if xx[n1]==0 then .382 else .618, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), ff5[n1], if xx[n1]==0 then .236 else .764, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), llp[n1], if highestall(hhbn) < highestall(llbn) then 0 else 1, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), uf1p[n1], 1 + fib1, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), uf2p[n1], 1 + fib2, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), uf3p[n1], 1 + fib3, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), uf4p[n1], 1 + fib4, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), uf5p[n1], 1 + fib5, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), Lf1p[n1], -fib1, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), Lf2p[n1], -fib2, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), Lf3p[n1], -fib3 , Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), Lf4p[n1], -fib4, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), Lf5p[n1], -fib5, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), uhhp[n1], 2, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), Lllp[n1], -1, Color.GRAY, yes);

#Hiding Fib Line Price Levels Usually Displayed on Right Price Axis
hhp.HideBubble();
llp.HideBubble();
uhhp.HideBubble();
Lllp.HideBubble();
f1p.HideBubble();
f2p.HideBubble();
f3p.HideBubble();
f4p.HideBubble();
f5p.HideBubble();
Lf1p.HideBubble();
Lf2p.HideBubble();
Lf3p.HideBubble();
Lf4p.HideBubble();
Lf5p.HideBubble();
uf1p.HideBubble();
uf2p.HideBubble();
uf3p.HideBubble();
uf4p.HideBubble();
uf5p.HideBubble();
 
Last edited:
I see the fib retracements are drawn low to high. Is it possible to adjust the code to draw high to low, so we can get the fib extensions?
 
@zeek per your request, I modified the time range method so that timerange_begin/timerange_end inputs would allow for post close of prior day, current day premarket, and custom user time ranges, with the Fibonacci lines drawn across the entire chart.

Code:
#FibChoices v1
#Request usethinkscript.com @theelderwand to duplicate a swimdicators video's chart's indicator
#BLT 20191224

#v1 20191228 per request @zeek, changed time range method so that timerange_begin/timerange_end inputs would allow for post close of prior day, current day premarket, and custom user time ranges, with the Fibonacci lines drawn across the entire chart.


input method = {default aggregation, developing_reg_thrs, developing_ext_thrs, time_range};

input aggregation              = AggregationPeriod.DAY;
input aggregation_periodsback  = 0;

input timerange_begin  = 0000;
input timerange_end    = 0929;
# Examples: pre-market setting: 0000,0929; previous close through pre-market: 1600,0929; 
# intraday opening range: 0930,1030

input display_upper_extended_fibs = no;
input display_lower_extended_fibs = no;

input fib1 = .236;
input fib2 = .382;
input fib3 = .500;
input fib4 = .618;
input fib5 = .764;

input showchart_bubbles = yes;
input bubble_option     = {default fiblevel, pricelevel};
input bubblemover       = 1; #used to move the bubble left and right

def bn = BarNumber();
#Time Range - Determines High/Low Where TimeRange_Begin Times are Between 1600 and 2359 Following the Prior Day's Close
def globexOpen   = if (if GetDayOfWeek(GetYYYYMMDD()) == 1 then SecondsFromTime(timerange_begin) >= 0 else SecondsFromTime(timerange_begin) >= 0) or SecondsFromTime(timerange_end) < 0 then 1 else 0;
def globexReset  = if globexOpen and !globexOpen[1] then 1 else 0;
def globexHigh   = CompoundValue(1, If((high > globexHigh[1] and globexOpen) or globexReset, high, globexHigh[1]), high);
def globexLow    = CompoundValue(1, If((low < globexLow[1] and globexOpen) or globexReset, low, globexLow[1]), low);
def globexhighbn = if high == (globexHigh) then bn else globexhighbn[1];
def globexlowbn  = if low == (globexLow) then bn else globexlowbn[1];

#Time Range - Determines High/Low with TimeRange_Begin Times From 0000 for PreMarket, Current Day or Intraday Pereiods
def day     = GetDay() == GetLastDay();
def lastday = if day and SecondsFromTime(timerange_begin) >= 0 then bn else Double.NaN;
def hhamt   = if day and bn == LowestAll(lastday) then high else if SecondsFromTime(timerange_end) <= 0 then Max(high, hhamt[1]) else hhamt[1];
def hhbn    = if high == (hhamt) then bn else hhbn[1];
def llamt   = if day and bn == LowestAll(lastday)  then low else if SecondsFromTime(timerange_end) <= 0 then Min(low, llamt[1]) else llamt[1];
def llbn    = if low == (llamt) then bn else llbn[1];

#Fibonacci High/Lows Determined based upon input method selected
def hh;
def ll;

switch (method){
#
case aggregation:
    hh = high(period = aggregation)[aggregation_periodsback];
    ll = low(period = aggregation)[aggregation_periodsback];
#
case developing_reg_thrs:
    hh = if GetTime() crosses above RegularTradingStart(GetYYYYMMDD()) then high else if GetTime() > RegularTradingStart(GetYYYYMMDD()) and high > hh[1] then high else hh[1];
    ll = if GetTime() crosses above RegularTradingStart(GetYYYYMMDD()) then low else if GetTime() > RegularTradingStart(GetYYYYMMDD()) and low < ll[1] then low else ll[1];
#
case developing_ext_thrs:
    hh = if GetTime() crosses above RegularTradingEnd(GetYYYYMMDD()) then high else if high > hh[1] then high else hh[1];
    ll = if GetTime() crosses above RegularTradingEnd(GetYYYYMMDD()) then low else if low < ll[1] then low else ll[1];
#
case time_range:
#Lines will display across the entire chart
    hh = if Between(timerange_begin, 1600, 2359) then HighestAll(if BarNumber() == HighestAll(globexhighbn) then globexHigh else Double.NaN) else HighestAll(if bn == HighestAll(hhbn) then (hhamt) else Double.NaN);
    ll = if Between(timerange_begin, 1600, 2359) then LowestAll(if BarNumber() == HighestAll(globexlowbn) then globexLow else Double.NaN) else LowestAll(if bn == HighestAll(llbn) then llamt else Double.NaN);

}

#Fibonacci Line Plots
def range  = hh - ll;
def f1   = ll + range * fib1;
def f2   = ll + range * fib2;
def f3   = ll + range * fib3;
def f4   = ll + range * fib4;
def f5   = ll + range * fib5;
def hh1  = hh;
def ll1  = ll;
def ff1  = f1;
def ff2  = f2;
def ff3  = f3;
def ff4  = f4;
def ff5  = f5;

input fib_line_choice = {default horizontal, points, dashes};
def paintingStrategy = if fib_line_choice == fib_line_choice.horizontal then PaintingStrategy.HORIZONTAL else if fib_line_choice == fib_line_choice.points then PaintingStrategy.POINTS else PaintingStrategy.DASHES;

plot hhp = hh1;
hhp.SetPaintingStrategy(paintingStrategy);
hhp.SetDefaultColor(Color.GREEN);
hhp.SetLineWeight(1);

plot llp =  ll1;
llp.SetPaintingStrategy(paintingStrategy);
llp.SetDefaultColor(Color.RED);
llp.SetLineWeight(1);

plot f1p =  ff1;
f1p.SetPaintingStrategy(paintingStrategy);
f1p.SetDefaultColor(Color.YELLOW);
f1p.SetLineWeight(1);

plot f2p =  ff2;
f2p.SetPaintingStrategy(paintingStrategy);
f2p.SetDefaultColor(Color.YELLOW);
f2p.SetLineWeight(1);

plot f3p =  ff3;
f3p.SetPaintingStrategy(paintingStrategy);
f3p.SetDefaultColor(Color.WHITE);
f3p.SetLineWeight(1);

plot f4p = ff4;
f4p.SetPaintingStrategy(paintingStrategy);
f4p.SetDefaultColor(Color.YELLOW);
f4p.SetLineWeight(1);

plot f5p =  ff5;
f5p.SetPaintingStrategy(paintingStrategy);
f5p.SetDefaultColor(Color.YELLOW);
f5p.SetLineWeight(1);

#Fibonacci - Upper Extended Fib Lines
plot uhhp = if display_upper_extended_fibs == no then Double.NaN else range + hh1;
uhhp.SetPaintingStrategy(paintingStrategy);
uhhp.SetDefaultColor(Color.GREEN);
uhhp.SetLineWeight(1);

plot uf1p = if  display_upper_extended_fibs == no then Double.NaN else range + ff1;
uf1p.SetPaintingStrategy(paintingStrategy);
uf1p.SetDefaultColor(Color.YELLOW);
uf1p.SetLineWeight(1);

plot uf2p = if  display_upper_extended_fibs == no then Double.NaN else range + ff2;
uf2p.SetPaintingStrategy(paintingStrategy);
uf2p.SetDefaultColor(Color.YELLOW);
uf2p.SetLineWeight(1);

plot uf3p = if  display_upper_extended_fibs == no then Double.NaN else range + ff3;
uf3p.SetPaintingStrategy(paintingStrategy);
uf3p.SetDefaultColor(Color.WHITE);
uf3p.SetLineWeight(1);

plot uf4p = if  display_upper_extended_fibs == no then Double.NaN else range + ff4;
uf4p.SetPaintingStrategy(paintingStrategy);
uf4p.SetDefaultColor(Color.YELLOW);
uf4p.SetLineWeight(1);

plot uf5p = if  display_upper_extended_fibs == no then Double.NaN else range + ff5;
uf5p.SetPaintingStrategy(paintingStrategy);
uf5p.SetDefaultColor(Color.YELLOW);
uf5p.SetLineWeight(1);

#Fibonacci - Lower Extended Fib Lines
plot Lllp = if  display_lower_extended_fibs == no then Double.NaN else ll - range;
Lllp.SetPaintingStrategy(paintingStrategy);
Lllp.SetDefaultColor(Color.RED);
Lllp.SetLineWeight(1);

plot Lf1p = if  display_lower_extended_fibs == no then Double.NaN else ll - range * fib1;
Lf1p.SetPaintingStrategy(paintingStrategy);
Lf1p.SetDefaultColor(Color.YELLOW);
Lf1p.SetLineWeight(1);

plot Lf2p = if display_lower_extended_fibs == no then Double.NaN else ll - range * fib2;
Lf2p.SetPaintingStrategy(paintingStrategy);
Lf2p.SetDefaultColor(Color.YELLOW);
Lf2p.SetLineWeight(1);

plot Lf3p = if display_lower_extended_fibs == no then Double.NaN else ll - range * fib3;
Lf3p.SetPaintingStrategy(paintingStrategy);
Lf3p.SetDefaultColor(Color.WHITE);
Lf3p.SetLineWeight(1);

plot Lf4p = if  display_lower_extended_fibs == no then Double.NaN else ll - range * fib4;
Lf4p.SetPaintingStrategy(paintingStrategy);
Lf4p.SetDefaultColor(Color.YELLOW);
Lf4p.SetLineWeight(1);

plot Lf5p = if display_lower_extended_fibs == no then Double.NaN else ll - range * fib5;
Lf5p.SetPaintingStrategy(paintingStrategy);
Lf5p.SetDefaultColor(Color.YELLOW);
Lf5p.SetLineWeight(1);

#Bubbles Displaying Fib Levels in Right Expansion
def n   = bubblemover;
def n1  = n + 1;
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), hhp[n1], 1, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), ff1[n1], fib1, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), ff2[n1], fib2, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), ff3[n1], fib3, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), ff4[n1], fib4, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), ff5[n1], fib5, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), llp[n1], 0, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), uf1p[n1], 1 + fib1, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), uf2p[n1], 1 + fib2, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), uf3p[n1], 1 + fib3, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), uf4p[n1], 1 + fib4, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), uf5p[n1], 1 + fib5, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), Lf1p[n1], -fib1, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), Lf2p[n1], -fib2, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), Lf3p[n1], -fib3 , Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), Lf4p[n1], -fib4, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), Lf5p[n1], -fib5, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), uhhp[n1], 2, Color.GRAY, yes);
AddChartBubble(showchart_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), Lllp[n1], -1, Color.GRAY, yes);

#Hiding Fib Line Price Levels Usually Displayed on Right Price Axis
hhp.HideBubble();
llp.HideBubble();
uhhp.HideBubble();
Lllp.HideBubble();
f1p.HideBubble();
f2p.HideBubble();
f3p.HideBubble();
f4p.HideBubble();
f5p.HideBubble();
Lf1p.HideBubble();
Lf2p.HideBubble();
Lf3p.HideBubble();
Lf4p.HideBubble();
Lf5p.HideBubble();
uf1p.HideBubble();
uf2p.HideBubble();
uf3p.HideBubble();
uf4p.HideBubble();
uf5p.HideBubble();

LOVE THIS! Anyway you can make the lines show only in the regular trading hours please?
 
Rather than modifying the script I used above, I think this script may be more useful and easier to modify to your liking.

Was using this today and realized that the H and L were moving as priced moved higher. I thought it was based on prior days high and low. Is there a way to adjust these levels to prior days levels? Thank you!
 
Was using this today and realized that the H and L were moving as priced moved higher. I thought it was based on prior days high and low. Is there a way to adjust these levels to prior days levels? Thank you!

Not sure which selection you are using, but if it aggregation, then adjust this to what aggregation and periodsback you want to use.
Code:
input aggregation              = AggregationPeriod.DAY;
input aggregation_periodsback  = 0;
 
This should work. I have not tested it as I do not know what script you used.

Ruby:
AddChartBubble(show_bubbles_right and (downward and BarNumber() == HighestAll(BarNumber())), retracement1, Concat( "$", Round(retracement1, 2)), createcolor(51,153,255), yes);
AddChartBubble(show_bubbles_right and (upward and BarNumber() == HighestAll(BarNumber())), retracement1, Concat( "$", Round(retracement1, 2)), createcolor(51,153,255), yes);
Hi SleepyZ, how would I be able to add chart bubble on the Fibfan extreme points. I tried the following, but it put chart bubbles on all bars instead of the high or low Fibfan points. I would appreciate for your help.

AddChartBubble(yes, lowestall(Fibfan), Concat( "$", Round(Highestall(FibFan), 2)), Color.cyan, no);
 
Hi all, new to the forum, I was looking for a way to "ToS-ify" one of my MT4 indicators which led me here.

@SleepyZ - thanks for your Auto_FibPrevDay code, it was exactly what I needed for my project, which is a recreation of a "Bank Trader Strategy" indicator that I've had for years in Metatrader. It looks fancy, but ultimately it's just a different way of using Fib retracements and extensions for buy/sell decisions and profit targets. It was intended for Forex but it seems to work fairly well on Futures as well.

es_bts_20211222.png


Ruby:
#Bank Trader Strategy Study
#Based on Auto_FibPrevDay by SleepyZ on usethinkscript.com - plots high/low from previous day and fib levels based thereon

input ShowTodayOnly = {"No", default "Yes"};
input showbubbles   = yes;
input showBuySellZone = yes;
input bubblemover   = 2; #Hint n: Number of Bars to shift bubble to the right
def bubblemover2   = bubblemover + 3;
def period        = AggregationPeriod.DAY;
def periodWk      = AggregationPeriod.WEEK;
input displace      = 1;

#ADR
def length = 1;

def dayHigh = DailyHighLow(AggregationPeriod.DAY).Dailyhigh;
def dayLow = DailyHighLow(AggregationPeriod.DAY).DailyLow;
def dayrange = dayHigh - dayLow;
def AvgRange = average(DayRange, length);

plot RH = if showtodayonly and !IsNaN(close(period = period)[-1]) then double.nan else open(period = AggregationPeriod.DAY) + (AvgRange/2);
plot RL = if showtodayonly and !IsNaN(close(period = period)[-1]) then double.nan else open(period = AggregationPeriod.DAY) - (AvgRange/2);

RH.SetDefaultColor(Color.CYAN);
RH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RH.SetLineWeight(1);

RL.SetDefaultColor(Color.DARK_RED);
RL.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RL.SetLineWeight(1);

#Yesterday's high/low
plot YH = if showtodayonly and !IsNaN(close(period = period)[-1]) then double.nan else high(period = period)[displace];
plot YL = if showtodayonly and !IsNaN(close(period = period)[-1]) then double.nan else  low(period = period)[displace];
plot OOD = if showtodayonly and !IsNaN(close(period = period)[-1]) then double.nan else open(period = period);

YH.SetDefaultColor(Color.VIOLET);
YH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
YH.SetLineWeight(1);

YL.SetDefaultColor(Color.RED);
YL.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
YL.SetLineWeight(1);

#Open of the day
OOD.SetDefaultColor(Color.WHITE);
OOD.SetPaintingStrategy(PaintingStrategy.LINE);
OOD.SetLineWeight(3);

#Open of the week
plot OOW = open(period = periodWk);

OOW.SetDefaultColor(CreateColor(228,188,0));
OOW.SetPaintingStrategy(PaintingStrategy.POINTS);
OOW.SetLineWeight(3);

#Previous week high/low
def prevWkHigh = high(period = periodWk)[displace];
def prevWkLow =  low(period = periodWk)[displace];

plot PWH = if showtodayonly and !IsNaN(close(period = period)[-1]) then double.nan else prevWkHigh;
plot PWL = if showtodayonly and !IsNaN(close(period = period)[-1]) then double.nan else prevWkLow;

PWH.SetDefaultColor(Color.DARK_ORANGE);
PWH.SetPaintingStrategy(PaintingStrategy.LINE);
PWH.SetLineWeight(3);

PWL.SetDefaultColor(Color.YELLOW);
PWL.SetPaintingStrategy(PaintingStrategy.LINE);
PWL.SetLineWeight(3);

#Fib levels
input F1 = -1.00;
input F2 = -0.618;
input F3 = -0.414;
input F4 = -0.272;
input F5 = 0.236;
input F6 = 0.382;
input F7 = 0.500;
input F8 = 0.618;
input F9 = 0.764;
input F10 = 1.00;
input F11 = 1.272;
input F12 = 1.414;
input F13 = 1.618;
input F14 = 2.00;

#Fib calculations
def rHi =  YH;
def rLo =  YL;

def range  = rHi - rLo;
plot LT4   = rLo + (range * F1);
plot LT3   = rLo + (range * F2);
plot LT2   = rLo + (range * F3);
plot LT1   = rLo + (range * F4);
def BSZ   = rLo + (range * F5);
plot IRL   = rLo + (range * F6);
plot DM   = rLo + (range * F7);
plot IRH   = rLo + (range * F8);
def TBZ   = rLo + (range * F9);
def ZERO  = rLo + (range * F10);
plot HT1  = rLo + (range * F11);
plot HT2  = rLo + (range * F12);
plot HT3  = rLo + (range * F13);
plot HT4  = rLo + (range * F14);

def rangeWk = prevWkHigh - prevWkLow;
plot wLT2 = prevWkLow + (rangeWk * F3);
plot wLT1 = prevWkLow + (rangeWk * F4);
plot wHT1 = prevWkLow + (rangeWk * F11);
plot wTH2 = prevWkLow + (rangeWk * F12);

#Draw the lines
LT4.SetDefaultColor(Color.MAGENTA);
LT4.SetPaintingStrategy(PaintingStrategy.DASHES);
LT4.SetLineWeight(1);

LT3.SetDefaultColor(Color.MAGENTA);
LT3.SetPaintingStrategy(PaintingStrategy.DASHES);
LT3.SetLineWeight(1);

LT2.SetDefaultColor(Color.MAGENTA);
LT2.SetPaintingStrategy(PaintingStrategy.DASHES);
LT2.SetLineWeight(1);

LT1.SetDefaultColor(Color.MAGENTA);
LT1.SetPaintingStrategy(PaintingStrategy.DASHES);
LT1.SetLineWeight(1);

#BSZ.SetDefaultColor(Color.RED);
#BSZ.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
#BSZ.SetLineWeight(1);

IRL.SetDefaultColor(Color.PLUM);
IRL.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
IRL.SetLineWeight(1);

DM.SetDefaultColor(Color.GRAY);
DM.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
DM.SetLineWeight(1);

IRH.SetDefaultColor(Color.DARK_GREEN);
IRH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
IRH.SetLineWeight(1);

#TBZ.SetDefaultColor(Color.BLUE);
#TBZ.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
#TBZ.SetLineWeight(1);

#ZERO.SetDefaultColor(Color.GREEN);
#ZERO.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
#ZERO.SetLineWeight(1);

HT1.SetDefaultColor(Color.GREEN);
HT1.SetPaintingStrategy(PaintingStrategy.DASHES);
HT1.SetLineWeight(1);

HT2.SetDefaultColor(Color.GREEN);
HT2.SetPaintingStrategy(PaintingStrategy.DASHES);
HT2.SetLineWeight(1);

HT3.SetDefaultColor(Color.GREEN);
HT3.SetPaintingStrategy(PaintingStrategy.DASHES);
HT3.SetLineWeight(1);

HT4.SetDefaultColor(Color.GREEN);
HT4.SetPaintingStrategy(PaintingStrategy.DASHES);
HT4.SetLineWeight(1);

wLT2.SetDefaultColor(Color.MAGENTA);
wLT2.SetPaintingStrategy(PaintingStrategy.POINTS);
wLT2.SetLineWeight(1);

wLT1.SetDefaultColor(Color.MAGENTA);
wLT1.SetPaintingStrategy(PaintingStrategy.POINTS);
wLT1.SetLineWeight(1);

wHT1.SetDefaultColor(Color.GREEN);
wHT1.SetPaintingStrategy(PaintingStrategy.POINTS);
wHT1.SetLineWeight(1);

wTH2.SetDefaultColor(Color.GREEN);
wTH2.SetPaintingStrategy(PaintingStrategy.POINTS);
wTH2.SetLineWeight(1);

def   b           = bubblemover;
def   b1          = b + 1;

def   b2          = bubblemover2;
def   b21          = b2 + 1;

#Add bubbles
AddChartBubble(showbubbles == yes and IsNaN(close[b]) and !IsNaN(close[b1]), LT4[b], "LT4", LT4.Takevaluecolor());
AddChartBubble(showbubbles == yes and IsNaN(close[b]) and !IsNaN(close[b1]), LT3[b], "LT3", LT3.Takevaluecolor());
AddChartBubble(showbubbles == yes and IsNaN(close[b]) and !IsNaN(close[b1]), LT2[b], "LT2", LT2.Takevaluecolor());
AddChartBubble(showbubbles == yes and IsNaN(close[b]) and !IsNaN(close[b1]), LT1[b], "LT1", LT1.Takevaluecolor());
#AddChartBubble(showbubbles == yes and IsNaN(close[b]) and !IsNaN(close[b1]), BSZ[b], "BSZ", BSZ.Takevaluecolor());
AddChartBubble(showbubbles == yes and IsNaN(close[b]) and !IsNaN(close[b1]), IRL[b], "IRL", IRL.Takevaluecolor());
AddChartBubble(showbubbles == yes and IsNaN(close[b]) and !IsNaN(close[b1]), DM[b], "DM", DM.Takevaluecolor());
AddChartBubble(showbubbles == yes and IsNaN(close[b]) and !IsNaN(close[b1]), IRH[b], "IRH", IRH.Takevaluecolor());
#AddChartBubble(showbubbles == yes and IsNaN(close[b]) and !IsNaN(close[b1]), TBZ[b], "TBZ", TBZ.Takevaluecolor());
#AddChartBubble(showbubbles == yes and IsNaN(close[b]) and !IsNaN(close[b1]), ZERO[b], "ZERO", ZERO.Takevaluecolor());
AddChartBubble(showbubbles == yes and IsNaN(close[b]) and !IsNaN(close[b1]), HT1[b], "HT1", HT1.Takevaluecolor());
AddChartBubble(showbubbles == yes and IsNaN(close[b]) and !IsNaN(close[b1]), HT2[b], "HT2", HT2.Takevaluecolor());
AddChartBubble(showbubbles == yes and IsNaN(close[b]) and !IsNaN(close[b1]), HT3[b], "HT3", HT3.Takevaluecolor());
AddChartBubble(showbubbles == yes and IsNaN(close[b]) and !IsNaN(close[b1]), HT4[b], "HT4", HT4.Takevaluecolor());
AddChartBubble(showbubbles == yes and IsNaN(close[b]) and !IsNaN(close[b1]), YH[b], "YH", YH.Takevaluecolor());
AddChartBubble(showbubbles == yes and IsNaN(close[b]) and !IsNaN(close[b1]), YL[b], "YL", YL.Takevaluecolor());
AddChartBubble(showbubbles == yes and IsNaN(close[b2]) and !IsNaN(close[b21]), RH[b2], "RH", RH.Takevaluecolor());
AddChartBubble(showbubbles == yes and IsNaN(close[b2]) and !IsNaN(close[b21]), RL[b2], "RL", RL.Takevaluecolor());
AddChartBubble(showbubbles == yes and IsNaN(close[b2]) and !IsNaN(close[b21]), PWH[b2], "PWH", PWH.Takevaluecolor());
AddChartBubble(showbubbles == yes and IsNaN(close[b2]) and !IsNaN(close[b21]), PWL[b2], "PWL", PWL.Takevaluecolor());
AddChartBubble(showbubbles == yes and IsNaN(close[b2]) and !IsNaN(close[b21]), OOD[b2], "OpD", OOD.Takevaluecolor());
AddChartBubble(showbubbles == yes and IsNaN(close[b2]) and !IsNaN(close[b21]), OOW[b2], "OpW", OOW.Takevaluecolor());
AddChartBubble(showbubbles == yes and IsNaN(close[b2]) and !IsNaN(close[b21]), wLT2[b2], "wLT2", wLT2.Takevaluecolor());
AddChartBubble(showbubbles == yes and IsNaN(close[b2]) and !IsNaN(close[b21]), wLT1[b2], "wLT1", wLT1.Takevaluecolor());
AddChartBubble(showbubbles == yes and IsNaN(close[b2]) and !IsNaN(close[b21]), wHT1[b2], "wHT1", wHT1.Takevaluecolor());
AddChartBubble(showbubbles == yes and IsNaN(close[b2]) and !IsNaN(close[b21]), wTH2[b2], "wHT2", wTH2.Takevaluecolor());

#Add shading
AddCloud(if showBuySellZone then TBZ else double.NaN, IRH, color.DARK_GREEN, color.DARK_GREEN);
AddCloud(if showBuySellZone then IRH else double.NaN, IRL, color.GRAY, color.GRAY);
AddCloud(if showBuySellZone then IRL else double.NaN, BSZ, color.DARK_RED, color.DARK_RED);

Ideally I'd like to be able to change the starting time of the fib range, so it can calculate and draw the fibs from different previous trading ranges - I.e. London open from 0300 to 0259, or New York open from 0800 to 0759. If anyone has suggestions on the best way to program that it would be appreciated.
Does this work for $SPY
 
may i know why the fib retracements are drawn low to high for some tickers and reverse for others.

Is it possible to adjust the code to draw low to high, for all tickers ?
 
may i know why the fib retracements are drawn low to high for some tickers and reverse for others.

Is it possible to adjust the code to draw low to high, for all tickers ?
It is on purpose that way. It is drawn depending on whether high is most current or low is most current. It has nothing to do with ticker outside of this condition. If you draw low to high in all conditions, the level will not mean the same. If you are still interested to draw low to high no matter what, I am sure someone can make some adjustments for you.
 
It is on purpose that way. It is drawn depending on whether high is most current or low is most current. It has nothing to do with ticker outside of this condition. If you draw low to high in all conditions, the level will not mean the same. If you are still interested to draw low to high no matter what, I am sure someone can make some adjustments for you.
Could someone please do the adjustment and provide me a script? Appreciate it
 

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
425 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