Rumpy's D/W Autofibs For ThinkOrSwim

CashMoney

Member
VIP
Uses yesterday's & last week's high/low to plot auto fibs.
You can toggle them on/off separately as it does become a bit cluttered with both enabled.

6VOg1zk.png


Original code:
https://in.tradingview.com/script/qODMp9LE-Rumpy-s-D-W-Autofibs/
The ThinkOrSwim study can be found in the next post.
 
Last edited by a moderator:

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

Hi,

please help convert this indicator. @samer800 Thank you!

https://in.tradingview.com/script/qODMp9LE-Rumpy-s-D-W-Autofibs/

Code:
//@version=4
study("Rumpy's D/W Autofibs", shorttitle="RUMPYS_DW_AUTOFIBS", overlay=true)
dispdfibs = input(true, title="Display Daily Fibs?")
dispwfibs = input(true, title="Display Weekly Fibs?")

dhigh = security(syminfo.tickerid, "D", high)
dlow = security(syminfo.tickerid, "D", low)
whigh = security(syminfo.tickerid, "W", high)
wlow = security(syminfo.tickerid, "W", low)

newdint = dayofweek != dayofweek[1]
newwint = dayofweek == dayofweek.monday and dayofweek[1] == dayofweek.sunday

dh= 0.0
dh := newdint ? dhigh : dh[1]
dl = 0.0
dl := newdint ? dlow : dl[1]

wh = 0.0
wh := newwint ? whigh : wh[1]
wl = 0.0
wl := newwint ? wlow : wl[1]

//-------------------

d_diff = dh - dl
w_diff = wh - wl

d_236 = d_diff * 0.236
d_382 = d_diff * 0.382
d_500 = d_diff * 0.5
d_618 = d_diff * 0.618
d_786 = d_diff * 0.786
d_1272 = d_diff * 1.272
d_1414 = d_diff * 1.414
d_1618 = d_diff * 1.618
d_2000 = d_diff * 2.000


// Daily internal fibs
dfib1 = plot(dl != dl[1] ? na : dispdfibs ? dl : na, style=plot.style_linebr, color=color.red, linewidth=2, title="Daily Bottom")
dfib2 = plot(dl != dl[1] ? na : dispdfibs ? dl + d_236 : na, style=plot.style_linebr, color=color.gray, linewidth=1, title="Daily .236")
dfib3 = plot(dl != dl[1] ? na : dispdfibs ? dl + d_382 : na, style=plot.style_linebr, color=color.gray, linewidth=1, title="Daily .382")
dfib4 = plot(dl != dl[1] ? na : dispdfibs ? dl + d_500 : na, style=plot.style_linebr, color=color.yellow, linewidth=1, title="Daily .5")
dfib5 = plot(dl != dl[1] ? na : dispdfibs ? dl + d_618 : na, style=plot.style_linebr, color=color.gray, linewidth=1, title="Daily .618")
dfib6 = plot(dl != dl[1] ? na : dispdfibs ? dl + d_786 : na, style=plot.style_linebr, color=color.gray, linewidth=1, title="Daily .786")
dfib7 = plot(dl != dl[1] ? na : dispdfibs ? dh : na, style=plot.style_linebr, color=color.lime, linewidth=2, title="Daily Top")

//--------------------

// Daily upper fibs
dfib8 = plot(dl != dl[1] ? na : dispdfibs ? dl + d_1272 : na, style=plot.style_linebr, color=color.gray, linewidth=1, title="Daily Upper 1.272")
dfib9 = plot(dl != dl[1] ? na : dispdfibs ? dl + d_1414 : na, style=plot.style_linebr, color=color.gray, linewidth=1, title="Daily Upper 1.414")
dfib10 = plot(dl != dl[1] ? na : dispdfibs ? dl + d_1618 : na, style=plot.style_linebr, color=color.gray, linewidth=1, title="Daily Upper 1.618")
dfib11 = plot(dl != dl[1] ? na : dispdfibs ? dl + d_2000 : na, style=plot.style_linebr, color=color.teal, linewidth=2, title="Daily Upper 2.0")
//--------------------

// Daily lower fibs
dfib12 = plot(dl != dl[1] ? na : dispdfibs ? dh - d_1272 : na, style=plot.style_linebr, color=color.gray, linewidth=1, title="Daily Lower 1.272")
dfib13 = plot(dl != dl[1] ? na : dispdfibs ? dh - d_1414 : na, style=plot.style_linebr, color=color.gray, linewidth=1, title="Daily Lower 1.414")
dfib14 = plot(dl != dl[1] ? na : dispdfibs ? dh - d_1618 : na, style=plot.style_linebr, color=color.gray, linewidth=1, title="Daily Lower 1.618")
dfib15 = plot(dl != dl[1] ? na : dispdfibs ? dh - d_2000 : na, style=plot.style_linebr, color=color.orange, linewidth=2, title="Daily Lower 2.0")
//--------------------


w_236 = w_diff * 0.236
w_382 = w_diff * 0.382
w_500 = w_diff * 0.5
w_618 = w_diff * 0.618
w_786 = w_diff * 0.786
w_1272 = w_diff * 1.272
w_1414 = w_diff * 1.414
w_1618 = w_diff * 1.618
w_2000 = w_diff * 2.000


// Weekly internal fibs
wfib1 = plot(wl != wl[1] ? na : dispwfibs ? wl : na, style=plot.style_linebr, color=color.red, linewidth=4, title="Weekly Bottom")
wfib2 = plot(wl != wl[1] ? na : dispwfibs ? wl + w_236 : na, style=plot.style_linebr, color=color.gray, linewidth=2, title="Weekly .236")
wfib3 = plot(wl != wl[1] ? na : dispwfibs ? wl + w_382 : na, style=plot.style_linebr, color=color.gray, linewidth=2, title="Weekly .382")
wfib4 = plot(wl != wl[1] ? na : dispwfibs ? wl + w_500 : na, style=plot.style_linebr, color=color.yellow, linewidth=2, title="Weekly .5")
wfib5 = plot(wl != wl[1] ? na : dispwfibs ? wl + w_618 : na, style=plot.style_linebr, color=color.gray, linewidth=2, title="Weekly .618")
wfib6 = plot(wl != wl[1] ? na : dispwfibs ? wl + w_786 : na, style=plot.style_linebr, color=color.gray, linewidth=2, title="Weekly .786")
wfib7 = plot(wl != wl[1] ? na : dispwfibs ? wh : na, style=plot.style_linebr, color=color.lime, linewidth=4, title="Weekly Top")

//--------------------

// Weekly upper fibs
wfib8 = plot(wl != wl[1] ? na : dispwfibs ? wl + w_1272 : na, style=plot.style_linebr, color=color.gray, linewidth=2, title="Weekly Upper 1.272")
wfib9 = plot(wl != wl[1] ? na : dispwfibs ? wl + w_1414 : na, style=plot.style_linebr, color=color.gray, linewidth=2, title="Weekly Upper 1.414")
wfib10 = plot(wl != wl[1] ? na : dispwfibs ? wl + w_1618 : na, style=plot.style_linebr, color=color.gray, linewidth=2, title="Weekly Upper 1.618")
wfib11 = plot(wl != wl[1] ? na : dispwfibs ? wl + w_2000 : na, style=plot.style_linebr, color=color.teal, linewidth=4, title="Weekly Upper 2.0")
//--------------------

// Weekly lower fibs
wfib12 = plot(wl != wl[1] ? na : dispwfibs ? wh - w_1272 : na, style=plot.style_linebr, color=color.gray, linewidth=2, title="Weekly Lower 1.272")
wfib13 = plot(wl != wl[1] ? na : dispwfibs ? wh - w_1414 : na, style=plot.style_linebr, color=color.gray, linewidth=2, title="Weekly Lower 1.414")
wfib14 = plot(wl != wl[1] ? na : dispwfibs ? wh - w_1618 : na, style=plot.style_linebr, color=color.gray, linewidth=2, title="Weekly Lower 1.618")
wfib15 = plot(wl != wl[1] ? na : dispwfibs ? wh - w_2000 : na, style=plot.style_linebr, color=color.orange, linewidth=4, title="Weekly Lower 2.0")
//--------------------
check the below:

CSS:
# Indicator for TOS
# @rumpypumpydumpy
#study("Rumpy's D/W Autofibs", shorttitle="RUMPYS_DW_AUTOFIBS", overlay=true)
# Converted by Sam4Cok@Samer800    - 08/2024

input extendLines = no;
input DisplayDailyFibs = yes; #(true, title="Display Daily Fibs?")
input DisplayWeeklyFibs = no; #(true, title="Display Weekly Fibs?")

def na = Double.NaN;
def last = isNaN(close);
def extend = if extendLines then yes else !last;
def dfib = extend and DisplayDailyFibs;
def wfib = extend and DisplayWeeklyFibs;

def dhigh = if last then dhigh[1] else high(Period = "DAY")[1];
def dlow  = if last then dlow[1]  else low(Period  = "DAY")[1];
def whigh = if last then whigh[1] else high(Period = "WEEK")[1];
def wlow  = if last then wlow[1]  else low(Period = "WEEK")[1];


def day = GetDay();
def week =  GetWeek();
def newdint = day != day[1];
def newwint = week != week[1];

def dh1 = if newdint then dhigh else dh1[1];
def dl1 = if newdint then dlow  else dl1[1];
def wh1 = if newwint then whigh else wh1[1];
def wl1 = if newwint then wlow  else wl1[1];

def dh = if dh1 then dh1 else na;
def dl = if dl1 then dl1 else na;
def wh = if wh1 then wh1 else na;
def wl = if wl1 then wl1 else na;
#//-------------------
def d_diff = dh - dl;
def w_diff = wh - wl;

def d_236 = d_diff * 0.236;
def d_382 = d_diff * 0.382;
def d_500 = d_diff * 0.5;
def d_618 = d_diff * 0.618;
def d_786 = d_diff * 0.786;
def d_1272 = d_diff * 1.272;
def d_1414 = d_diff * 1.414;
def d_1618 = d_diff * 1.618;
def d_2000 = d_diff * 2.000;

#// Daily internal fibs
plot dfib1 = if dl!=dl[1] then na else if dfib then dl else na;         # "Daily Bottom"
plot dfib2 = if dl!=dl[1] then na else if dfib then dl + d_236 else na; # "Daily .236"
plot dfib3 = if dl!=dl[1] then na else if dfib then dl + d_382 else na; # "Daily .382"
plot dfib4 = if dl!=dl[1] then na else if dfib then dl + d_500 else na; # "Daily .5"
plot dfib5 = if dl!=dl[1] then na else if dfib then dl + d_618 else na; # "Daily .618"
plot dfib6 = if dl!=dl[1] then na else if dfib then dl + d_786 else na; # "Daily .786"
plot dfib7 = if dl!=dl[1] then na else if dfib then dh else na;         # "Daily Top"


#// Daily upper fibs
plot dfib8  = if dl!=dl[1] then na else if dfib then dl + d_1272 else na; # "Daily Upper 1.272"
plot dfib9  = if dl!=dl[1] then na else if dfib then dl + d_1414 else na; # "Daily Upper 1.414"
plot dfib10 = if dl!=dl[1] then na else if dfib then dl + d_1618 else na; #  "Daily Upper 1.618"
plot dfib11 = if dl!=dl[1] then na else if dfib then dl + d_2000 else na; #  "Daily Upper 2.0"

#// Daily lower fibs
plot dfib12 = if dl!=dl[1] then na else if dfib then dh - d_1272 else na; #  "Daily Lower 1.272"
plot dfib13 = if dl!=dl[1] then na else if dfib then dh - d_1414 else na; #  "Daily Lower 1.414"
plot dfib14 = if dl!=dl[1] then na else if dfib then dh - d_1618 else na; #  "Daily Lower 1.618"
plot dfib15 = if dl!=dl[1] then na else if dfib then dh - d_2000 else na; #  "Daily Lower 2.0"

#//--------------------

def w_236 = w_diff * 0.236;
def w_382 = w_diff * 0.382;
def w_500 = w_diff * 0.5;
def w_618 = w_diff * 0.618;
def w_786 = w_diff * 0.786;
def w_1272 = w_diff * 1.272;
def w_1414 = w_diff * 1.414;
def w_1618 = w_diff * 1.618;
def w_2000 = w_diff * 2.000;

#// Weekly internal fibs
plot wfib1 = if wl!=wl[1] then na else if wfib then wl else na; #  "Weekly Bottom"
plot wfib2 = if wl!=wl[1] then na else if wfib then wl + w_236 else na; #  "Weekly .236"
plot wfib3 = if wl!=wl[1] then na else if wfib then wl + w_382 else na; #  "Weekly .382"
plot wfib4 = if wl!=wl[1] then na else if wfib then wl + w_500 else na; #  "Weekly .5"
plot wfib5 = if wl!=wl[1] then na else if wfib then wl + w_618 else na; #  "Weekly .618"
plot wfib6 = if wl!=wl[1] then na else if wfib then wl + w_786 else na; #  "Weekly .786"
plot wfib7 = if wl!=wl[1] then na else if wfib then wh else na; # "Weekly Top"


#// Weekly upper fibs
plot wfib8 = if wl!=wl[1] then na else if wfib then wl + w_1272 else na; # "Weekly Upper 1.272")
plot wfib9 = if wl!=wl[1] then na else if wfib then wl + w_1414 else na; # "Weekly Upper 1.414")
plot wfib10 = if wl!=wl[1] then na else if wfib then wl + w_1618 else na; # "Weekly Upper 1.618")
plot wfib11 = if wl!=wl[1] then na else if wfib then wl + w_2000 else na; # "Weekly Upper 2.0")

#// Weekly lower fibs
plot wfib12 = if wl!=wl[1] then na else if wfib then wh - w_1272 else na; # "Weekly Lower 1.272")
plot wfib13 = if wl!=wl[1] then na else if wfib then wh - w_1414 else na; # "Weekly Lower 1.414")
plot wfib14 = if wl!=wl[1] then na else if wfib then wh - w_1618 else na; # "Weekly Lower 1.618")
plot wfib15 = if wl!=wl[1] then na else if wfib then wh - w_2000 else na; # "Weekly Lower 2.0")

dfib1.SetLineWeight(2);
dfib7.SetLineWeight(2);
dfib11.SetLineWeight(2);
dfib15.SetLineWeight(2);
wfib1.SetLineWeight(2);
wfib7.SetLineWeight(2);
wfib11.SetLineWeight(2);
wfib15.SetLineWeight(2);
dfib1.SetDefaultColor(Color.RED);
dfib2.SetDefaultColor(Color.GRAY);
dfib3.SetDefaultColor(Color.GRAY);
dfib4.SetDefaultColor(GetColor(8));
dfib5.SetDefaultColor(Color.GRAY);
dfib6.SetDefaultColor(Color.GRAY);
dfib7.SetDefaultColor(Color.GREEN);
dfib8.SetDefaultColor(Color.GRAY);
dfib9.SetDefaultColor(Color.GRAY);
dfib10.SetDefaultColor(Color.GRAY);
dfib11.SetDefaultColor(Color.CYAN);
dfib12.SetDefaultColor(Color.GRAY);
dfib13.SetDefaultColor(Color.GRAY);
dfib14.SetDefaultColor(Color.GRAY);
dfib15.SetDefaultColor(GetColor(4));
wfib1.SetDefaultColor(Color.RED);
wfib2.SetDefaultColor(Color.GRAY);
wfib3.SetDefaultColor(Color.GRAY);
wfib4.SetDefaultColor(GetColor(8));
wfib5.SetDefaultColor(Color.GRAY);
wfib6.SetDefaultColor(Color.GRAY);
wfib7.SetDefaultColor(Color.GREEN);
wfib8.SetDefaultColor(Color.GRAY);
wfib9.SetDefaultColor(Color.GRAY);
wfib10.SetDefaultColor(Color.GRAY);
wfib11.SetDefaultColor(Color.CYAN);
wfib12.SetDefaultColor(Color.GRAY);
wfib13.SetDefaultColor(Color.GRAY);
wfib14.SetDefaultColor(Color.GRAY);
wfib15.SetDefaultColor(GetColor(4));
wfib1.SetStyle(Curve.SHORT_DASH);
wfib2.SetStyle(Curve.SHORT_DASH);
wfib3.SetStyle(Curve.SHORT_DASH);
wfib4.SetStyle(Curve.SHORT_DASH);
wfib5.SetStyle(Curve.SHORT_DASH);
wfib6.SetStyle(Curve.SHORT_DASH);
wfib7.SetStyle(Curve.SHORT_DASH);
wfib8.SetStyle(Curve.SHORT_DASH);
wfib9.SetStyle(Curve.SHORT_DASH);
wfib10.SetStyle(Curve.SHORT_DASH);
wfib11.SetStyle(Curve.SHORT_DASH);
wfib12.SetStyle(Curve.SHORT_DASH);
wfib13.SetStyle(Curve.SHORT_DASH);
wfib14.SetStyle(Curve.SHORT_DASH);
wfib15.SetStyle(Curve.SHORT_DASH);
# End of CODE
 
check the below:

CSS:
# Indicator for TOS
# @rumpypumpydumpy
#study("Rumpy's D/W Autofibs", shorttitle="RUMPYS_DW_AUTOFIBS", overlay=true)
# Converted by Sam4Cok@Samer800    - 08/2024

input extendLines = no;
input DisplayDailyFibs = yes; #(true, title="Display Daily Fibs?")
input DisplayWeeklyFibs = no; #(true, title="Display Weekly Fibs?")

def na = Double.NaN;
def last = isNaN(close);
def extend = if extendLines then yes else !last;
def dfib = extend and DisplayDailyFibs;
def wfib = extend and DisplayWeeklyFibs;

def dhigh = if last then dhigh[1] else high(Period = "DAY")[1];
def dlow  = if last then dlow[1]  else low(Period  = "DAY")[1];
def whigh = if last then whigh[1] else high(Period = "WEEK")[1];
def wlow  = if last then wlow[1]  else low(Period = "WEEK")[1];


def day = GetDay();
def week =  GetWeek();
def newdint = day != day[1];
def newwint = week != week[1];

def dh1 = if newdint then dhigh else dh1[1];
def dl1 = if newdint then dlow  else dl1[1];
def wh1 = if newwint then whigh else wh1[1];
def wl1 = if newwint then wlow  else wl1[1];

def dh = if dh1 then dh1 else na;
def dl = if dl1 then dl1 else na;
def wh = if wh1 then wh1 else na;
def wl = if wl1 then wl1 else na;
#//-------------------
def d_diff = dh - dl;
def w_diff = wh - wl;

def d_236 = d_diff * 0.236;
def d_382 = d_diff * 0.382;
def d_500 = d_diff * 0.5;
def d_618 = d_diff * 0.618;
def d_786 = d_diff * 0.786;
def d_1272 = d_diff * 1.272;
def d_1414 = d_diff * 1.414;
def d_1618 = d_diff * 1.618;
def d_2000 = d_diff * 2.000;

#// Daily internal fibs
plot dfib1 = if dl!=dl[1] then na else if dfib then dl else na;         # "Daily Bottom"
plot dfib2 = if dl!=dl[1] then na else if dfib then dl + d_236 else na; # "Daily .236"
plot dfib3 = if dl!=dl[1] then na else if dfib then dl + d_382 else na; # "Daily .382"
plot dfib4 = if dl!=dl[1] then na else if dfib then dl + d_500 else na; # "Daily .5"
plot dfib5 = if dl!=dl[1] then na else if dfib then dl + d_618 else na; # "Daily .618"
plot dfib6 = if dl!=dl[1] then na else if dfib then dl + d_786 else na; # "Daily .786"
plot dfib7 = if dl!=dl[1] then na else if dfib then dh else na;         # "Daily Top"


#// Daily upper fibs
plot dfib8  = if dl!=dl[1] then na else if dfib then dl + d_1272 else na; # "Daily Upper 1.272"
plot dfib9  = if dl!=dl[1] then na else if dfib then dl + d_1414 else na; # "Daily Upper 1.414"
plot dfib10 = if dl!=dl[1] then na else if dfib then dl + d_1618 else na; #  "Daily Upper 1.618"
plot dfib11 = if dl!=dl[1] then na else if dfib then dl + d_2000 else na; #  "Daily Upper 2.0"

#// Daily lower fibs
plot dfib12 = if dl!=dl[1] then na else if dfib then dh - d_1272 else na; #  "Daily Lower 1.272"
plot dfib13 = if dl!=dl[1] then na else if dfib then dh - d_1414 else na; #  "Daily Lower 1.414"
plot dfib14 = if dl!=dl[1] then na else if dfib then dh - d_1618 else na; #  "Daily Lower 1.618"
plot dfib15 = if dl!=dl[1] then na else if dfib then dh - d_2000 else na; #  "Daily Lower 2.0"

#//--------------------

def w_236 = w_diff * 0.236;
def w_382 = w_diff * 0.382;
def w_500 = w_diff * 0.5;
def w_618 = w_diff * 0.618;
def w_786 = w_diff * 0.786;
def w_1272 = w_diff * 1.272;
def w_1414 = w_diff * 1.414;
def w_1618 = w_diff * 1.618;
def w_2000 = w_diff * 2.000;

#// Weekly internal fibs
plot wfib1 = if wl!=wl[1] then na else if wfib then wl else na; #  "Weekly Bottom"
plot wfib2 = if wl!=wl[1] then na else if wfib then wl + w_236 else na; #  "Weekly .236"
plot wfib3 = if wl!=wl[1] then na else if wfib then wl + w_382 else na; #  "Weekly .382"
plot wfib4 = if wl!=wl[1] then na else if wfib then wl + w_500 else na; #  "Weekly .5"
plot wfib5 = if wl!=wl[1] then na else if wfib then wl + w_618 else na; #  "Weekly .618"
plot wfib6 = if wl!=wl[1] then na else if wfib then wl + w_786 else na; #  "Weekly .786"
plot wfib7 = if wl!=wl[1] then na else if wfib then wh else na; # "Weekly Top"


#// Weekly upper fibs
plot wfib8 = if wl!=wl[1] then na else if wfib then wl + w_1272 else na; # "Weekly Upper 1.272")
plot wfib9 = if wl!=wl[1] then na else if wfib then wl + w_1414 else na; # "Weekly Upper 1.414")
plot wfib10 = if wl!=wl[1] then na else if wfib then wl + w_1618 else na; # "Weekly Upper 1.618")
plot wfib11 = if wl!=wl[1] then na else if wfib then wl + w_2000 else na; # "Weekly Upper 2.0")

#// Weekly lower fibs
plot wfib12 = if wl!=wl[1] then na else if wfib then wh - w_1272 else na; # "Weekly Lower 1.272")
plot wfib13 = if wl!=wl[1] then na else if wfib then wh - w_1414 else na; # "Weekly Lower 1.414")
plot wfib14 = if wl!=wl[1] then na else if wfib then wh - w_1618 else na; # "Weekly Lower 1.618")
plot wfib15 = if wl!=wl[1] then na else if wfib then wh - w_2000 else na; # "Weekly Lower 2.0")

dfib1.SetLineWeight(2);
dfib7.SetLineWeight(2);
dfib11.SetLineWeight(2);
dfib15.SetLineWeight(2);
wfib1.SetLineWeight(2);
wfib7.SetLineWeight(2);
wfib11.SetLineWeight(2);
wfib15.SetLineWeight(2);
dfib1.SetDefaultColor(Color.RED);
dfib2.SetDefaultColor(Color.GRAY);
dfib3.SetDefaultColor(Color.GRAY);
dfib4.SetDefaultColor(GetColor(8));
dfib5.SetDefaultColor(Color.GRAY);
dfib6.SetDefaultColor(Color.GRAY);
dfib7.SetDefaultColor(Color.GREEN);
dfib8.SetDefaultColor(Color.GRAY);
dfib9.SetDefaultColor(Color.GRAY);
dfib10.SetDefaultColor(Color.GRAY);
dfib11.SetDefaultColor(Color.CYAN);
dfib12.SetDefaultColor(Color.GRAY);
dfib13.SetDefaultColor(Color.GRAY);
dfib14.SetDefaultColor(Color.GRAY);
dfib15.SetDefaultColor(GetColor(4));
wfib1.SetDefaultColor(Color.RED);
wfib2.SetDefaultColor(Color.GRAY);
wfib3.SetDefaultColor(Color.GRAY);
wfib4.SetDefaultColor(GetColor(8));
wfib5.SetDefaultColor(Color.GRAY);
wfib6.SetDefaultColor(Color.GRAY);
wfib7.SetDefaultColor(Color.GREEN);
wfib8.SetDefaultColor(Color.GRAY);
wfib9.SetDefaultColor(Color.GRAY);
wfib10.SetDefaultColor(Color.GRAY);
wfib11.SetDefaultColor(Color.CYAN);
wfib12.SetDefaultColor(Color.GRAY);
wfib13.SetDefaultColor(Color.GRAY);
wfib14.SetDefaultColor(Color.GRAY);
wfib15.SetDefaultColor(GetColor(4));
wfib1.SetStyle(Curve.SHORT_DASH);
wfib2.SetStyle(Curve.SHORT_DASH);
wfib3.SetStyle(Curve.SHORT_DASH);
wfib4.SetStyle(Curve.SHORT_DASH);
wfib5.SetStyle(Curve.SHORT_DASH);
wfib6.SetStyle(Curve.SHORT_DASH);
wfib7.SetStyle(Curve.SHORT_DASH);
wfib8.SetStyle(Curve.SHORT_DASH);
wfib9.SetStyle(Curve.SHORT_DASH);
wfib10.SetStyle(Curve.SHORT_DASH);
wfib11.SetStyle(Curve.SHORT_DASH);
wfib12.SetStyle(Curve.SHORT_DASH);
wfib13.SetStyle(Curve.SHORT_DASH);
wfib14.SetStyle(Curve.SHORT_DASH);
wfib15.SetStyle(Curve.SHORT_DASH);
# End of CODE
Thank you!
 
Hey @samer800 I love the work you contribute to the site! I edited the code to my liking and I use this indicator on a on a 1 minute chart and would like to get an alert from a stock on my watchlist when price closes above the dfib11 or setup a watchlist column where it would show how far the price is from the dfib11 using a -/+ percentage or cent/dollar value. If those are not possible, is there anything that would work? Thank you!

Here's my edit of the code:
Ruby:
# Indicator for TOS
# @rumpypumpydumpy
#study("Rumpy's D/W Autofibs", shorttitle="RUMPYS_DW_AUTOFIBS", overlay=true)
# Converted by Sam4Cok@Samer800 - 08/2024

input extendLines = no;
input DisplayDailyFibs = yes; #(true, title="Display Daily Fibs?")
input DisplayWeeklyFibs = no; #(true, title="Display Weekly Fibs?")

def na = Double.NaN;
def last = isNaN(close);
def extend = if extendLines then yes else !last;
def dfib = extend and DisplayDailyFibs;
def wfib = extend and DisplayWeeklyFibs;

def dhigh = if last then dhigh[1] else high(Period = "DAY")[1];
def dlow = if last then dlow[1] else low(Period = "DAY")[1];
def whigh = if last then whigh[1] else high(Period = "WEEK")[1];
def wlow = if last then wlow[1] else low(Period = "WEEK")[1];


def day = GetDay();
def week = GetWeek();
def newdint = day != day[1];
def newwint = week != week[1];

def dh1 = if newdint then dhigh else dh1[1];
def dl1 = if newdint then dlow else dl1[1];
def wh1 = if newwint then whigh else wh1[1];
def wl1 = if newwint then wlow else wl1[1];

def dh = if dh1 then dh1 else na;
def dl = if dl1 then dl1 else na;
def wh = if wh1 then wh1 else na;
def wl = if wl1 then wl1 else na;
#//-------------------
def d_diff = dh - dl;
def w_diff = wh - wl;

def d_236 = d_diff * 0.236;
def d_382 = d_diff * 0.382;
def d_500 = d_diff * 0.5;
def d_618 = d_diff * 0.618;
def d_786 = d_diff * 0.786;
def d_1272 = d_diff * 1.272;
def d_1414 = d_diff * 1.414;
def d_1618 = d_diff * 1.618;
def d_2000 = d_diff * 2.000;

plot dfib11 = if dl!=dl[1] then na else if dfib then dl + d_2000 else na; # "Daily Upper 2.0"



dfib11.SetDefaultColor(Color.CYAN);

# End of CODE
 
Last edited by a moderator:
Hello,

I have imported a code into my watchlist column which shows the price of a fib level. I have another column to the left that shows the last price. I wanted to know if someone could create another column which would show the difference in price between the last price and the fib price and show it in as a negative/positive (-\+) cent value.

Here is the code (converted by @samer800) used for the fib level value in my watchlist:

# Indicator for TOS
# @rumpypumpydumpy
#study("Rumpy's D/W Autofibs", shorttitle="RUMPYS_DW_AUTOFIBS", overlay=true)
# Converted by Sam4Cok@Samer800 - 08/2024

input extendLines = no;
input DisplayDailyFibs = yes; #(true, title="Display Daily Fibs?")
input DisplayWeeklyFibs = no; #(true, title="Display Weekly Fibs?")

def na = Double.NaN;
def last = isNaN(close);
def extend = if extendLines then yes else !last;
def dfib = extend and DisplayDailyFibs;
def wfib = extend and DisplayWeeklyFibs;

def dhigh = if last then dhigh[1] else high(Period = "DAY")[1];
def dlow = if last then dlow[1] else low(Period = "DAY")[1];
def whigh = if last then whigh[1] else high(Period = "WEEK")[1];
def wlow = if last then wlow[1] else low(Period = "WEEK")[1];


def day = GetDay();
def week = GetWeek();
def newdint = day != day[1];
def newwint = week != week[1];

def dh1 = if newdint then dhigh else dh1[1];
def dl1 = if newdint then dlow else dl1[1];
def wh1 = if newwint then whigh else wh1[1];
def wl1 = if newwint then wlow else wl1[1];

def dh = if dh1 then dh1 else na;
def dl = if dl1 then dl1 else na;
def wh = if wh1 then wh1 else na;
def wl = if wl1 then wl1 else na;
#//-------------------
def d_diff = dh - dl;
def w_diff = wh - wl;

def d_236 = d_diff * 0.236;
def d_382 = d_diff * 0.382;
def d_500 = d_diff * 0.5;
def d_618 = d_diff * 0.618;
def d_786 = d_diff * 0.786;
def d_1272 = d_diff * 1.272;
def d_1414 = d_diff * 1.414;
def d_1618 = d_diff * 1.618;
def d_2000 = d_diff * 2.000;

plot dfib11 = if dl!=dl[1] then na else if dfib then dl + d_2000 else na; # "Daily Upper 2.0"



dfib11.SetDefaultColor(Color.CYAN);

# End of CODE
 
Python:
# Indicator for TOS
# @rumpypumpydumpy
#study("Rumpy's D/W Autofibs", shorttitle="RUMPYS_DW_AUTOFIBS", overlay=true)
# Converted by Sam4Cok@Samer800 - 08/2024

input extendLines = no;
input DisplayDailyFibs = yes; #(true, title="Display Daily Fibs?")
input DisplayWeeklyFibs = no; #(true, title="Display Weekly Fibs?")

def na = Double.NaN;
def last = isNaN(close);
def extend = if extendLines then yes else !last;
def dfib = extend and DisplayDailyFibs;
def wfib = extend and DisplayWeeklyFibs;

def dhigh = if last then dhigh[1] else high(Period = "DAY")[1];
def dlow = if last then dlow[1] else low(Period = "DAY")[1];
def whigh = if last then whigh[1] else high(Period = "WEEK")[1];
def wlow = if last then wlow[1] else low(Period = "WEEK")[1];

def day = GetDay();
def week = GetWeek();
def newdint = day != day[1];
def newwint = week != week[1];

def dh1 = if newdint then dhigh else dh1[1];
def dl1 = if newdint then dlow else dl1[1];
def wh1 = if newwint then whigh else wh1[1];
def wl1 = if newwint then wlow else wl1[1];

def dh = if dh1 then dh1 else na;
def dl = if dl1 then dl1 else na;
def wh = if wh1 then wh1 else na;
def wl = if wl1 then wl1 else na;
#-------------------
def d_diff = dh - dl;
def w_diff = wh - wl;

def d_236 = d_diff * 0.236;
def d_382 = d_diff * 0.382;
def d_500 = d_diff * 0.5;
def d_618 = d_diff * 0.618;
def d_786 = d_diff * 0.786;
def d_1272 = d_diff * 1.272;
def d_1414 = d_diff * 1.414;
def d_1618 = d_diff * 1.618;
def d_2000 = d_diff * 2.000;

plot dfib11 = if dl != dl[1] then na else if dfib then dl + d_2000 else na; # "Daily Upper 2.0"
dfib11.SetDefaultColor(Color.CYAN);

[B]# Calculate the difference between the last price and the daily Fibonacci level
def lastPrice = close;
def fibPrice = dfib11;
def priceDifference = (lastPrice - fibPrice) * 100;  # Convert to cents

AddLabel(yes, "Price Diff: " + if priceDifference >= 0 then "+" else "" + Round(priceDifference, 2) + "¢",
         if priceDifference >= 0 then Color.GREEN else Color.RED);[/B]
 
Python:
# Indicator for TOS
# @rumpypumpydumpy
#study("Rumpy's D/W Autofibs", shorttitle="RUMPYS_DW_AUTOFIBS", overlay=true)
# Converted by Sam4Cok@Samer800 - 08/2024

input extendLines = no;
input DisplayDailyFibs = yes; #(true, title="Display Daily Fibs?")
input DisplayWeeklyFibs = no; #(true, title="Display Weekly Fibs?")

def na = Double.NaN;
def last = isNaN(close);
def extend = if extendLines then yes else !last;
def dfib = extend and DisplayDailyFibs;
def wfib = extend and DisplayWeeklyFibs;

def dhigh = if last then dhigh[1] else high(Period = "DAY")[1];
def dlow = if last then dlow[1] else low(Period = "DAY")[1];
def whigh = if last then whigh[1] else high(Period = "WEEK")[1];
def wlow = if last then wlow[1] else low(Period = "WEEK")[1];

def day = GetDay();
def week = GetWeek();
def newdint = day != day[1];
def newwint = week != week[1];

def dh1 = if newdint then dhigh else dh1[1];
def dl1 = if newdint then dlow else dl1[1];
def wh1 = if newwint then whigh else wh1[1];
def wl1 = if newwint then wlow else wl1[1];

def dh = if dh1 then dh1 else na;
def dl = if dl1 then dl1 else na;
def wh = if wh1 then wh1 else na;
def wl = if wl1 then wl1 else na;
#-------------------
def d_diff = dh - dl;
def w_diff = wh - wl;

def d_236 = d_diff * 0.236;
def d_382 = d_diff * 0.382;
def d_500 = d_diff * 0.5;
def d_618 = d_diff * 0.618;
def d_786 = d_diff * 0.786;
def d_1272 = d_diff * 1.272;
def d_1414 = d_diff * 1.414;
def d_1618 = d_diff * 1.618;
def d_2000 = d_diff * 2.000;

plot dfib11 = if dl != dl[1] then na else if dfib then dl + d_2000 else na; # "Daily Upper 2.0"
dfib11.SetDefaultColor(Color.CYAN);

[B]# Calculate the difference between the last price and the daily Fibonacci level
def lastPrice = close;
def fibPrice = dfib11;
def priceDifference = (lastPrice - fibPrice) * 100;  # Convert to cents

AddLabel(yes, "Price Diff: " + if priceDifference >= 0 then "+" else "" + Round(priceDifference, 2) + "¢",
         if priceDifference >= 0 then Color.GREEN else Color.RED);[/B]
if you want the label to be the output, then you should disable the plot
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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