Professional Documents
Culture Documents
Lux Ultra ? Fibonacci Tool
Lux Ultra ? Fibonacci Tool
▄▄▄▄▄▄▄▄▄▄
//▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░▌ ▐░▌ ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌
▐░░░░░░░░░░▌
//▐░█▀▀▀▀▀▀▀▀▀ ▀▀▀▀█░█▀▀▀▀ ▐░▌ ▐░▌ ▐░█▀▀▀▀▀▀▀█░▌ ▀▀▀▀█░█▀▀▀▀
▐░█▀▀▀▀▀▀▀█░▌
//▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌
▐░▌
//▐░█▄▄▄▄▄▄▄▄▄ ▐░▌ ▐░▌ ▐░▌ ▐░█▄▄▄▄▄▄▄█░▌ ▐░▌ ▐░▌
▐░▌
//▐░░░░░░░░░░░▌ ▐░▌ ▐░▌ ▐░▌ ▐░░░░░░░░░░░▌ ▐░▌ ▐░▌
▐░▌
// ▀▀▀▀▀▀▀▀▀█░▌ ▐░▌ ▐░▌ ▐░▌ ▐░█▀▀▀▀▀▀▀▀▀ ▐░▌ ▐░▌
▐░▌
// ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌
▐░▌
// ▄▄▄▄▄▄▄▄▄█░▌ ▄ ▐░▌ ▄ ▐░█▄▄▄▄▄▄▄█░▌ ▄ ▐░▌ ▄ ▄▄▄▄█░█▄▄▄▄ ▄
▐░█▄▄▄▄▄▄▄█░▌▄
//▐░░░░░░░░░░░▌▐░▌ ▐░▌▐░▌ ▐░░░░░░░░░░░▌▐░▌▐░▌▐░▌
▐░░░░░░░░░░░▌▐░▌▐░░░░░░░░░░▌▐░▌
// ▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀ ▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀ ▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀
▀▀▀▀▀▀▀▀▀▀ ▀
//
// ▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄
▄
//▐░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░▌
▐░▌
//▐░█▀▀▀▀▀▀▀█░▌▀▀▀▀█░█▀▀▀▀ ▀▀▀▀█░█▀▀▀▀ ▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀▀▀▀█░▌ ▀▀▀▀█░█▀▀▀▀
▐░▌░▌ ▐░▌
//▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌
▐░▌▐░▌ ▐░▌
//▐░█▄▄▄▄▄▄▄█░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌
▐░▌ ▐░▌
//▐░░░░░░░░░░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌
▐░▌ ▐░▌
//▐░█▀▀▀▀▀▀▀█░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌
▐░▌ ▐░▌
//▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌
▐░▌▐░▌
//▐░█▄▄▄▄▄▄▄█░▌▄▄▄▄█░█▄▄▄▄ ▐░▌ ▐░█▄▄▄▄▄▄▄▄▄ ▐░█▄▄▄▄▄▄▄█░▌ ▄▄▄▄█░█▄▄▄▄ ▐░▌
▐░▐░▌
//▐░░░░░░░░░░▌▐░░░░░░░░░░░▌ ▐░▌ ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░▌
▐░░▌
// ▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀
▀▀
//
// S.UPER T.REND U.LTIMATE P.ROJECT I.NTELLIGENT D.ESIGN
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0
at https://mozilla.org/MPL/2.0/
// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0
International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// Over 1000 indicator were referenced, credit goes to EACH AND EVERY CREATOR ON
TRADINGVIEW. It is impossible to list everyone. Thus, everyone gets credit.
// Extra Credit to: PVSRA, plasmapug, KIVANC, Quantvue, Lux algo; // orginal
combination of luxalgo Fibonacci Toolkit + Elliott Wave + Trendlines with Breaks:
modified by Stupid_Bitcoin 2024
// The summary of this code is work done by @ Stupid_Bitcoin 2024 and beyond.
// S.T.U.P.I.D. Donations ~ paypal ~ djyourstory@gmail.com
// A Market Maker and Casino are identical. They do not change the game.
// They understand your indicator, or your mind-set will keep changing.
// The Human Brain can not make a security call to the asset, but AI can.
// A majority of popular indicators are old, regardless of ratings.
// Many of these indicators can not upgrade into Version 5 of Pine Script.
// Before indicator design the 13 TEMA, 66 DEMA, created a tested trading
foundation.
//@version=5
indicator("Lux Ultra 📈 Fibonacci Tool", overlay=true, max_lines_count=500,
max_labels_count=500, max_boxes_count = 500, max_bars_back=5000)
plotcandle(open, high, low, close, title=' Vector Candle', color=(open < close) ?
color_1 : color_1, wickcolor=color_1, bordercolor=color_1, editable = false)
//----------VCLB data----------//
[currentVolume, pastVolume, ratio] = ta.relativeVolume(lookback, 'D', true)
ratio := math.round(ratio*100,0)
//----------VCLB conditions----------//
ratioCol = ratio >= extLev ? extCol : ratio >= highLev ? highCol : ratio >=
avgLev ? avgCol : ratio >= lightLev ? lightCol : dryCol
ratioWickCol = ratio >= ratio[1] ? colu0 :cold0
//----------VCLB plots----------//
plotcandle(open,high,low,close,color=ratioCol,wickcolor=ratioWickCol,
bordercolor=ratioCol, editable = false)
//
//------------------------------------------------------------------------------
//Settings
//-----------------------------------------------------------------------------{
i_hi = input.string('high' , title= '' , group='source
[high - low]', inline='hl', options=['high', 'close', 'max open/close'])
i_lo = input.string('low' , title= '' , group='source
[high - low]', inline='hl', options=['low' , 'close', 'min open/close'])
//-----------------------------------------------------------------------------}
//User Defined Types
//-----------------------------------------------------------------------------{
type ZZ
int [] d
int [] x
float[] y
line [] l
type Ewave
line l1
line l2
line l3
line l4
line l5
label b1
label b2
label b3
label b4
label b5
//
bool on
bool br //= na
//
int dir
//
line lA
line lB
line lC
label bA
label bB
label bC
//
bool next = false
//
label lb
box bx
type fibL
line wave1_0_500
line wave1_0_618
line wave1_0_764
line wave1_0_854
line wave1_pole_
linefill l_fill_
bool _break_ //= na
//-----------------------------------------------------------------------------}
//Functions
//-----------------------------------------------------------------------------{
hi = i_hi == 'high' ? high : i_hi == 'close' ? close : math.max(open, close)
lo = i_lo == 'low' ? low : i_hi == 'close' ? close : math.min(open, close)
method set(fibL nFibL, int x1, int x2, float max_500, float max_618, float max_764,
float max_854, float y2) =>
nFibL.wave1_0_500.set_xy1(x1, max_500)
nFibL.wave1_0_500.set_xy2(x2, max_500)
nFibL.wave1_0_618.set_xy1(x1, max_618)
nFibL.wave1_0_618.set_xy2(x2, max_618)
nFibL.wave1_0_764.set_xy1(x1, max_764)
nFibL.wave1_0_764.set_xy2(x2, max_764)
nFibL.wave1_0_854.set_xy1(x1, max_854)
nFibL.wave1_0_854.set_xy2(x2, max_854)
nFibL.wave1_pole_.set_xy1(x1, y2 )
nFibL.wave1_pole_.set_xy2(x1, max_854)
nFibL.l_fill_.get_line1().set_xy1(x1, max_764)
nFibL.l_fill_.get_line1().set_xy2(x2, max_764)
nFibL.l_fill_.get_line2().set_xy1(x1, max_854)
nFibL.l_fill_.get_line2().set_xy2(x2, max_854)
//
if barstate.islast
// –––[ get last 2 EW's ]–––
getEW = aEW.get(0)
if aEW.size() > 1
getEW1 = aEW.get(1)
last_0x := getEW.l1.get_x1(), last_0y := getEW.l1.get_y1()
last_6x := getEW.l5.get_x2(), last_6y := getEW.l5.get_y2()
//
diff = math.abs(last_6y - last_0y) // –––[ max/min difference ]–––
_500 = diff * i_500
_618 = diff * i_618
_764 = diff * i_764
_854 = diff * i_854
bull = getEW.dir == 1
// –––[ if EW is not valid or an ABC has developed -> remove
fibonacci lines ]–––
if getEW.on == false or getEW.bC.get_x() > getEW.b5.get_x()
nFibL.setNa()
else
// –––[ get.on == true ~ valid EW ]–––
max_500 = last_6y + ((bull ? -1 : 1) * _500)
max_618 = last_6y + ((bull ? -1 : 1) * _618)
max_764 = last_6y + ((bull ? -1 : 1) * _764)
max_854 = last_6y + ((bull ? -1 : 1) * _854)
//
nFibL.set(last_6x, bar_index + 10, max_500, max_618, max_764,
max_854, last_6y)
// –––[ if (2) label overlap with (C) label ]–––
if getEW.b2.get_x() == getEW1.bC.get_x()
getEW.b1.set_textcolor(color(na))
getEW.b2.set_textcolor(color(na))
strB = getEW1.bB.get_text()
strC = getEW1.bC.get_text()
strB_ = str.replace(strB, "(b)", "(b) (1)", 0)
strC_ = str.replace(strC, "(c)", "(c) (2)", 0)
getEW1.bB.set_text(strB_)
getEW1.bC.set_text(strC_)
//
// –––[ check if fib limits are broken ]–––
getP_854 = nFibL.wave1_0_854.get_y1()
for i = 0 to bar_index - nFibL.wave1_0_854.get_x1()
if getEW.dir == -1
if high[i] > getP_854
nFibL._break_ := true
break
else
if low [i] < getP_854
nFibL._break_ := true
break
//–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
–––––––––––
switch nFibL._break_
true => nFibL.sol_dot('dot', color.new(color.red , 95))
false => nFibL.sol_dot('sol', color.new(color.lime, 95))
=>
nFibL.wave1_0_500.set_xy1(na, na)
nFibL.wave1_0_500.set_xy2(na, na)
nFibL.wave1_0_618.set_xy1(na, na)
nFibL.wave1_0_618.set_xy2(na, na)
nFibL.wave1_0_764.set_xy1(na, na)
nFibL.wave1_0_764.set_xy2(na, na)
nFibL.wave1_0_854.set_xy1(na, na)
nFibL.wave1_0_854.set_xy2(na, na)
nFibL.wave1_pole_.set_xy1(na, na)
nFibL.wave1_pole_.set_xy2(na, na)
nFibL.l_fill_.set_color(color(na))
if aEW.size() > 15
pop = aEW.pop()
pop.l1.delete(), pop.b1.delete()
pop.l2.delete(), pop.b2.delete()
pop.l3.delete(), pop.b3.delete()
pop.l4.delete(), pop.b4.delete()
pop.l5.delete(), pop.b5.delete()
pop.lA.delete(), pop.bA.delete()
pop.lB.delete(), pop.bB.delete()
pop.lC.delete(), pop.bC.delete()
pop.lb.delete(), pop.bx.delete()
//----------------------------------
//-----------------------------------------------------------------------------}
//Plots
//-----------------------------------------------------------------------------{
draw(s1, len1, col1, 0)
draw(s2, len2, col2, 1)
draw(s3, len3, col3, 2)
//-----------------------------------------------------------------------------}
//Settings
//-----------------------------------------------------------------------------{
length = input.int(13, 'Swing Detection Lookback')
mult = input.float(1., 'Slope', minval = 0, step = .1)
calcMethod = input.string('Atr', 'Slope Calculation Method', options =
['Atr','Stdev','Linreg'])
backpaint = input(true, tooltip = 'Backpainting offset displayed elements in the
past. Disable backpainting to see real time information returned by the
indicator.')
//Style
upCss = input.color(color.rgb(110, 44, 176, 70), 'Up Trendline Color', group =
'Style')
dnCss = input.color(color.rgb(41, 153, 142, 70), 'Down Trendline Color', group =
'Style')
showExt = input(true, 'Show Extended Lines')
//-----------------------------------------------------------------------------}
//Calculations
//-----------------------------------------------------------------------------{
var upper = 0.
var lower = 0.
var slope_ph = 0.
var slope_pl = 0.
n = bar_index
src = close
ph = ta.pivothigh(length, length)
pl = ta.pivotlow(length, length)
var upos = 0
var dnos = 0
upos := ph ? 0 : close > upper - slope_ph * length ? 1 : upos
dnos := pl ? 0 : close < lower + slope_pl * length ? 1 : dnos
//-----------------------------------------------------------------------------}
//Extended Lines
//-----------------------------------------------------------------------------{
var uptl = line.new(na,na,na,na, color = upCss, style = line.style_dashed, extend
= extend.right)
var dntl = line.new(na,na,na,na, color = dnCss, style = line.style_dashed, extend
= extend.right)
if ph and showExt
uptl.set_xy1(n-offset, backpaint ? ph : upper - slope_ph * length)
uptl.set_xy2(n-offset+1, backpaint ? ph - slope : upper - slope_ph *
(length+1))
if pl and showExt
dntl.set_xy1(n-offset, backpaint ? pl : lower + slope_pl * length)
dntl.set_xy2(n-offset+1, backpaint ? pl + slope : lower + slope_pl *
(length+1))
//-----------------------------------------------------------------------------}
//Plots
//-----------------------------------------------------------------------------{
plot(backpaint ? upper : upper - slope_ph * length, 'Upper', color = ph ? na :
upCss, offset = -offset)
plot(backpaint ? lower : lower + slope_pl * length, 'Lower', color = pl ? na :
dnCss, offset = -offset)
//Breakouts
plotshape(upos > upos[1] ? low : na, "Upper Break"
, shape.labelup
, location.absolute
, upCss
, text = "B"
, textcolor = color.rgb(41, 153, 142, 50)
, size = size.tiny)
//-----------------------------------------------------------------------------}
//Alerts
//-----------------------------------------------------------------------------{
alertcondition(upos > upos[1], 'Upward Breakout', 'Price broke the down-trendline
upward')
alertcondition(dnos > dnos[1], 'Downward Breakout', 'Price broke the up-trendline
downward')
//-----------------------------------------------------------------------------}
//
// Fibonacci Toolkit
mode =
input.string('Retracements','Fibonacci',options=['Retracements','Arcs','Circles','F
an','Timezone','Spiral'])
ext = input(false,'Extend Reatracements')
start = input.time(0,'Start',confirm=true)
end = input.time(0,'End',confirm=true)
src3 = input(hlc3)
//----
fib_a = input(true,'Fib A',inline='inline1',group='Fibonacci')
fib_a_lvl = input(0.236,'',inline='inline1',group='Fibonacci')
fib_a_col = input(color.rgb(255, 0, 0, 50),'',inline='inline1',group='Fibonacci')
connecting_line = input(true,'Line',inline='inline7',group='Fibonacci')
line_col = input(color.rgb(120, 123, 134),'',inline='inline7',group='Fibonacci')
//----
var fib = array.new_float(0)
var fib_col = array.new_color(0)
if barstate.isfirst
if fib_a
array.push(fib,fib_a_lvl)
array.push(fib_col,fib_a_col)
if fib_b
array.push(fib,fib_b_lvl)
array.push(fib_col,fib_b_col)
if fib_c
array.push(fib,fib_c_lvl)
array.push(fib_col,fib_c_col)
if fib_d
array.push(fib,fib_d_lvl)
array.push(fib_col,fib_d_col)
if fib_e
array.push(fib,fib_e_lvl)
array.push(fib_col,fib_e_col)
if fib_f
array.push(fib,fib_f_lvl)
array.push(fib_col,fib_f_col)
//----
n3 = bar_index
dt = time-time[1]
s2 = math.sqrt(2)
if connecting_line
line.new(start_n,start_y,end_n,end_y,color=line_col)
if mode == 'Spiral'
int prev_x = na
float prev_y = na
for i = 0 to 499
t = i/499*7*math.pi
k = math.log(math.phi)/(math.pi/2)
r = (math.exp(t*k) - 1)/math.exp(5*math.pi*k)
x = r*math.cos(t)*diff_n
y = end_y + r*math.sin(t)*(start_y - end_y)*math.sign(end - start)
line.new(prev_x,prev_y,end-
math.round(x)*dt,y,xloc=xloc.bar_time,color=#ff5d00)
prev_x := end-math.round(x)*dt
prev_y := y
else
for i = 0 to array.size(fib)-1
if mode == 'Retracements'
lvl = end_y + array.get(fib,i)*diff_y
line.new(start_n,lvl,end_n,lvl,color=array.get(fib_col,i))
if ext
start_ext = math.max(start_n,end_n)
line.new(start_ext,lvl,start_ext+1,lvl,color=array.get(fib_col,i),extend=extend.rig
ht,style=line.style_dashed)
sty = label.style_label_right
label.new(math.min(start_n,end_n),lvl,str.tostring(array.get(fib,i)),color=#0000000
0,
style=sty,textcolor=array.get(fib_col,i),textalign=text.align_center,size=size.smal
l)
if mode == 'Arcs'
int prev_x = na
float prev_y = na
for j = -90 to 90 by 5
x = end_n +
diff_n*s2*array.get(fib,i)*math.sin(math.toradians(j))
y = end_y +
math.cos(math.toradians(j))*(diff_y*array.get(fib,i)*s2)
line.new(prev_x,prev_y,math.round(x),y,color=array.get(fib_col,i))
prev_x := math.round(x)
prev_y := y
label.new(prev_x,end_y,str.tostring(array.get(fib,i)),color=#00000000,
style=label.style_label_up,textcolor=array.get(fib_col,i),textalign=text.align_cent
er,size=size.small)
if mode == 'Circles'
int prev_x = na
float prev_y = na
for j = 0 to 360 by 5
x = end_n +
diff_n*s2*array.get(fib,i)*math.sin(math.toradians(j))
y = end_y +
math.cos(math.toradians(j))*(diff_y*array.get(fib,i)*s2)
line.new(prev_x,prev_y,math.round(x),y,color=array.get(fib_col,i))
prev_x := math.round(x)
prev_y := y
x = diff_n*s2*array.get(fib,i)*math.sin(math.toradians(90))
label.new(end_n+math.round(x),end_y,str.tostring(array.get(fib,i)),color=#00000000,
style=sty,textcolor=array.get(fib_col,i),textalign=text.align_right,size=size.small
)
if mode == 'Fan'
int prev_x = na
float prev_y = na
get_fib = array.get(fib,i)
if mode == 'Timezone'
line.new(start + (end-start)*sum,high,start + (end-
start)*sum,low,xloc.bar_time,extend=extend.both,color=array.get(fib_col,i))
sum := a + b
a := b
b := sum
//
//