PDF Div Class 2qs3tf Truncatedtext Module Wrapper fg1km9p Classtruncatedtext Module Lineclamped 85ulhh Style Max Lines5premium Lux Algo P Div
PDF Div Class 2qs3tf Truncatedtext Module Wrapper fg1km9p Classtruncatedtext Module Lineclamped 85ulhh Style Max Lines5premium Lux Algo P Div
0
International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © LuxAlgo
//@version=5
indicator("Premium Lux Algo", overlay=true, precision=0,
explicit_plot_zorder=true, max_labels_count=500)
// Functions
supertrend(_src, factor, atrLen) =>
atrat = ta.atr(atrLen)
upperBand = _src + factor * atrat
lowerBand = _src - factor * atrat
prevLowerBand = nz(lowerBand[1])
prevUpperBand = nz(upperBand[1])
lowerBand := lowerBand > prevLowerBand or close[1] < prevLowerBand ?
lowerBand : prevLowerBand
upperBand := upperBand < prevUpperBand or close[1] > prevUpperBand ?
upperBand : prevUpperBand
int direction = na
float superTrend =
na
prevSuperTrend =
superTrend[1] if na(atrat[1])
direction := 1
else if prevSuperTrend == prevUpperBand
// Strong TP Points //
maj_qual = 13
maj_len = 40
min_qual = 5
min_len = 5
min = false
selll = 0.0
buyy = 0.0
lele(qual, len) =>
bindex = 0.0
sindex = 0.0
bindex := nz(bindex[1], 0)
sindex := nz(sindex[1], 0)
ret = 0
if close > close[4]
bindex += 1
bindex
if close < close[4]
sindex += 1
sindex
if bindex > qual and close < open and high >= ta.highest(high, len)
bindex := 0
ret := -1
ret
if sindex > qual and close > open and low <= ta.lowest(low,
len) sindex := 0
ret := 1
ret
return_1 = ret
return_1
major = lele(maj_qual, maj_len)
minor = lele(min_qual, min_len)
if minor == -1 and min ==
true
selll := 1
selll
if major == -1 and maj == true
selll := 2
selll
if major == -1 and maj == true and minor == -1 and min == true
selll := 3
selll
if minor == 1 and min == true
buyy := 1
buyy
if major == 1 and maj == true
buyy := 2
buyy
if major == 1 and maj == true and minor == 1 and min == true
buyy := 3
buyy
plotshape(selll == 2, style=shape.xcross, location=location.abovebar,
color=color.new(#354996, 0), textcolor=color.new(color.white, 0), offset=0)
plotshape(buyy == 2, style=shape.xcross, location=location.belowbar,
color=color.new(#354996, 0), textcolor=color.new(color.white, 0), offset=0)
// Ha Market Bias //
tf(_res, _exp, gaps_on) =>
(sy mrg
iq a pfes _ o. n i c=u=ri0ity ? ry_emrqiusne,fso_t.t s e )ue:rriigaps_on
tdy,
enu
s ,o.t _etxsecp ,ker b adr,(s
mer g e. g ap se_xiopck
? _re == true
n ,
barmerge.lookahead_off) : request.security(syminfo.tickerid, _res, _exp,
barmerge.gaps_off, barmerge.lookahead_off)
ha_htf = ''
ha_len = 100
ha_len2 = 100
// Calculations {
o = ta.ema(open,
ha_len) c = ta.ema(close,
ha_len) h = ta.ema(high,
ha_len)
l = ta.ema(low, ha_len)
haclose = tf(ha_htf, (o + h + l + c) / 4, 0)
xhaopen = tf(ha_htf, (o + c) / 2, 0)
haopen = na(xhaopen[1]) ? (o + c) / 2 : (xhaopen[1] + haclose[1]) / 2
hahigh = math.max(h, math.max(haopen, haclose))
halow = math.min(l, math.min(haopen, haclose))
sigcolor =
(osc_bias > 0) and (osc_bias >= osc_smooth) ? color.new(color.lime, 35)
: (osc_bias > 0) and (osc_bias < osc_smooth) ? color.new(color.lime,
75) : (osc_bias < 0) and (osc_bias <= osc_smooth) ?
color.new(color.red, 35) : (osc_bias < 0) and (osc_bias > osc_smooth)
? color.new(color.red, 75) : na
// }
// Plots {
p_h = plot(h2, "Bias High", color=color(na), display=display.none,
editable=false) p_l = plot(l2, "Bias Low", color=color(na),
display=display.none, editable=false) p_avg = plot(ha_avg, "Bias Avergae",
color=color(na), display=display.none, editable=false)
// Range
Filter -
- -
//Conditional Sampling EMA Function
Cond_EMA(x, cond, n) =>
var val = array.new_float(0)
var ema_val =
array.new_float(1) if cond
array.push(val, x)
if array.size(val) > 1
array.remove(val, 0)
if na(array.get(ema_val, 0))
array.fill(ema_val, array.get(val, 0))
array.set(ema_val, 0, (array.get(val, 0) - array.get(ema_val, 0)) * (2 /
(n
+ 1)) + array.get(ema_val, 0))
EMA = array.get(ema_val,
0) EMA
//Conditional Sampling SMA Function
Cond_SMA(x, cond, n) =>
var vals = array.new_float(0)
if cond
array.push(vals, x)
if array.size(vals) > n
array.remove(vals, 0)
SMA =
array.avg(vals) SMA
/S/tSdteavn(dxa,rdn)D=e>viation Function
math.sqrt(Cond_SMA(math.pow(x, 2), 1, n) - math.pow(Cond_SMA(x, 1, n), 2))
//Range Size Function
rng_size(x, scale, qty, n)
=>
ATR = Cond_EMA(ta.tr(true), 1, n)
AC = Cond_EMA(math.abs(x - x[1]), 1,
n) SD = Stdev(x, n)
rng_size = scale == 'Pips' ? qty * 0.0001 : scale == 'Points' ? qty *
syminfo.pointvalue : scale == '% of Price' ? close * qty / 100 : scale == 'ATR'
? qty * ATR : scale == 'Average Change' ? qty * AC : scale == 'Standard
Deviation' ? qty * SD : scale == 'Ticks' ? qty * syminfo.mintick : qty
rng_size
//
//Inputs
//
//Filter Type
f_type = 'Type
2'
//Movement Source
mov_src = 'Close'
//Range Size Inputs
rng_qty = 2.618
rng_scale = 'Average Change'
//Range Period
rng_per = 14
//Range Smoothing Inputs
smooth_range = true
smooth_per = 27
//Filter Value Averaging Inputs
av_vals = false
av_samples = 2
//
//Definitions
//
//Filter Plot
filt_plot = plot(Show_rangefilter ? filt : na, color=filt_color, linewidth=3,
title='Filter', transp=0)
//Bar Color
//External Trend Output
plot(fdir, editable=false, display=display.none, title='External Output - Trend
Signal', transp=100)
// Superlchi + TBO
tenkan_len = 6
tenkan_mul = 2
t
kijun_len = 5
kijun_mult = 3.
spanB_len = 26
spanB_mult = 4.
offset = 0
//
avg(srcc,length,mult)
=>
atr = ta.atr(length)*mult
up = hl2 + atr
dn = hl2 - atr
upper = 0.,lower = 0.
upper := srcc[1] < upper[1] ? math.min(up,upper[1]) : up
lower := srcc[1] > lower[1] ? math.max(dn,lower[1]) : dn
os = 0,max = 0.,min = 0.
os := srcc > upper ? 1 : srcc < lower ? 0 : os[1]
spt = os == 1 ? lower : upper
max := ta.cross(srcc,spt) ? math.max(srcc,max[1]) : os == 1 ?
math.max(srcc,max[1]) : spt
min := ta.cross(srcc,spt) ? math.min(srcc,min[1]) : os == 0 ?
math.min(srcc,min[1]) : spt
math.avg(max,min)
//
tenkan =
avg(close,tenkan_len,tenkan_mult) kijun
= avg(close,kijun_len,kijun_mult)
senkouA = math.avg(kijun,tenkan)
senkouB = avg(close,spanB_len,spanB_mult)
//
tenkan_css = #2157f3
kijun_css = #ff5d00
cloud_a = color.new(color.teal,80)
cloud_b = color.new(color.red,80)
chikou_css = #7b1fa2
plot(Show_SuperIchi ? tenkan : na,'Tenkan-Sen',tenkan_css)
plot(Show_SuperIchi ? kijun : na,'Kijun-Sen',kijun_css)
plot(ta.crossover(tenkan,kijun) ? kijun :
na,'Crossover',#2157f3,3,plot.style_circles)
plot(ta.crossunder(tenkan,kijun) ? kijun :
na,'Crossunder',#ff5d00,3,plot.style_circles)
A = plot(Show_SuperIchi ? senkouA : na,'Senkou Span A',na,offset=offset-
1) B = plot(Show_SuperIchi ? senkouB : na,'Senkou Span
B',na,offset=offset-1) fill(A,B,senkouA > senkouB ? cloud_a : cloud_b)
plot(close,'Chikou',chikou_css,offset=-offset+1,display=display.none)
/ / C o lor s
g ree n n = =
#2FD282 pink =
#E34DED
// Plots
plotshape(Show_TBO ? openLong : na, "▲ Open Long", shape.triangleup,
location.belowbar, greenn, size=size.tiny)
plotshape(Show_TBO ? openShort : na, "▼ Open Short", shape.triangledown,
location.abovebar, pink, size=size.tiny)
// Smart Trail
trailType = input.string('modified', 'Trailtype',
options=['modified', 'unmodified'])
ATRPeriod = input(13, 'ATR Period')
ATRFactor = input(4, 'ATR Factor')
smoothing = input(8, 'Smoothing')
norm_o = request.security(ticker.new(syminfo.prefix, syminfo.ticker),
timeframe.period, open)
norm_h = request.security(ticker.new(syminfo.prefix, syminfo.ticker),
timeframe.period, high)
norm_l = request.security(ticker.new(syminfo.prefix, syminfo.ticker),
timeframe.period, low)
norm_c = request.security(ticker.new(syminfo.prefix, syminfo.ticker),
timeframe.period, close)
//}
ex = 0.0
ex := ta.crossover(Trend, 0) ? norm_h : ta.crossunder(Trend, 0) ? norm_l : Trend
==
1 ? math.max(ex[1], norm_h) : Trend == -1 ? math.min(ex[1], norm_l) : ex[1]
//}
// //////// PLOT TP and SL /////////////
////// FIBONACCI LEVELS ///////////
//{
state = Trend == 1 ? 'long' : 'short'
fib1Level = 61.8
fib2Level = 78.6
fib3Level = 88.6
f1 = ex + (trail - ex) * fib1Level / 100
f2 = ex + (trail - ex) * fib2Level / 100
f3 = ex + (trail - ex) * fib3Level / 100
l100 = trail + 0
fill(plot(ShowSmartTrail ? (ta.sma(trail, smoothing)) : na, 'Trailingstop',
style=plot.style_line, color=Trend == 1 ? color.new(#2157f9, 0) : Trend == -1 ?
color.new(#ff1100, 0) : na),
plot( ShowSmartTrail ? (ta.sma(f2, smoothing)) : na, 'Fib 2',
style=plot.style_line, display=display.none),
color=state == 'long' ? color.new(#2157f9, 80) : state == 'short' ?
color.new(#ff1100, 80) : na)
//}
// Reversal Signals
ReversalInputs = input.int(14, minval=1, title="Reversals Sensitivity",
group="Reversal Settings")
overbought = input(75, 'Reversal Down Level', group='Reversal
Settings') oversold= input(25, 'Reversal Up Level', group='Reversal
Settings')
upwardd = ta.rma(math.max(ta.change(close), 0), ReversalInputs)
dnwardd = ta.rma(-math.min(ta.change(close), 0), ReversalInputs)
source = dnwardd == 0 ? 100 : upwardd == 0 ? 0 : 100 - (100 / (1 + upwardd /
dnwardd))
revdn = ta.crossunder(source, overbought) and enableReversal
revup = ta.crossover(source, oversold) and enableReversal
plotshape(revup, 'Reversal Up Signal', shape.labelup, location.belowbar,
color.new(#2157f9, 65), text='Reversal Up Chance', size=size.small,
textcolor=color.white)
plotshape(revdn, 'Reversal Down Signal', shape.labeldown, location.abovebar,
color.new(#ff1100, 65), text='Reversal Down Chance', size=size.small,
textcolor=color.white)
// EzAlgo SR
// Get user input
colorSup =
#04994b colorRes =
#b4060d
strengthSR = input.int(4, "Support&Resistance Strength", 1, group="SR")
lineStyle = input.string("Solid", "Line Style", ["Solid", "Dotted",
"Dashed"], group="SR")
lineWidth = 2
useZones = input(true, "SR Zones",
group="SR") useHLZones = useZones
zoneWidth = 2
expandSR = true
// Functions
percWidth(len, perc) => (ta.highest(len) - ta.lowest(len)) * perc / 100
// Get components
rb =
10
prd = 284
ChannelW = 10
label_loc = 55
style = lineStyle == "Solid" ? line.style_solid : lineStyle ==
"Dotted" ? line.style_dotted : line.style_dashed
ph = ta.pivothigh(rb, rb)
pl = ta.pivotlow (rb, rb)
sr_levels = array.new_float(21,
na) prdhighest = ta.highest(prd)
prdlowest = ta.lowest(prd)
cwidth = percWidth(prd, ChannelW)
zonePerc = percWidth(300, zoneWidth)
aas = array.new_bool(41, true)
u1 = 0.0, u1 := nz(u1[1])
d1 = 0.0, d1 := nz(d1[1])
highestph = 0.0, highestph
highestph[1] lowestpl = 0.0, :=
lowestpl :=
lowestpl[1]
var sr_levs = array.new_float(21, na)
var sr_lines = array.new_line(21, na)
var sr_linesH = array.new_line(21, na)
var sr_linesL = array.new_line(21, na)
var sr_linesF = array.new_linefill(21,
na) var sr_labels =
array.new_label(21, na) if ph or pl
for x = 0 to array.size(sr_levels) - 1
array.set(sr_levels, x, na)
highestph := prdlowest
lowestpl := prdhighest
countpp = 0
for x = 0 to prd
if na(close[x])
break
if not na(ph[x]) or not na(pl[x])
highestph := math.max(highestph, nz(ph[x], prdlowest), nz(pl[x],
prdlowest))
lowestpl := math.min(lowestpl, nz(ph[x], prdhighest), nz(pl[x],
prdhighest)
) countpp += 1
if countpp > 40
break
if array.get(aas, countpp)
upl = (ph[x] ? high[x + rb] : low[x + rb]) + cwidth
dnl = (ph[x] ? high[x + rb] : low[x + rb]) -
cwidth
u1 := countpp
u1 d1 := countpp== ==
1 ?1 upl
? :
dnl
: d1
tmp = array.new_bool(41,
true) cnt = 0
tpoint = 0
for xx = 0 to prd
if na(close[xx])
break
if not na(ph[xx]) or not na(pl[xx])
chg = false
cnt += 1
if cnt > 40
break
if array.get(aas,
cnt) if not
na(ph[xx])
if high[xx + rb] <= upl and high[xx + rb] >= dnl
tpoint += 1
chg := true
if not na(pl[xx])
if low[xx + rb] <= upl and low[xx + rb] >= dnl
tpoint += 1
chg := true
if chg and cnt < 41
array.set(tmp, cnt, false)
if tpoint >= strengthSR
for g = 0 to 40 by 1
if not array.get(tmp, g)
// Plot array.set(aas, g, false)
if ph[x] and countpp < 21
array.set(sr_levels, countpp, high[x +
rb]) if pl[x] and countpp < 21
array.set(sr_levels, countpp, low[x + rb])
var line highest_ = na, line.delete(highest_)
var line lowest_ = na, line.delete(lowest_)
var line highest_fill1 = na,
line.delete(highest_fill1) var line highest_fill2 =
na, line.delete(highest_fill2) var line lowest_fill1 =
na, line.delete(lowest_fill1) var line lowest_fill2 =
na, line.delete(lowest_fill2) hi_col = close >=
highestph ? colorSup : colorRes lo_col = close >=
lowestpl ? colorSup : colorRes
if enableSR
highest_ := line.new(bar_index - 311, highestph, bar_index, highestph,
xloc.bar_index, expandSR ? extend.both : extend.right, hi_col, style, lineWidth)
lowest_ := line.new(bar_index - 311, lowestpl , bar_index, lowestpl ,
xloc.bar_index, expandSR ? extend.both : extend.right, lo_col, style,
lineWidth)
if useHLZones
highest_fill1 := line.new(bar_index - 311, highestph + zonePerc,
bar_index, highestph + zonePerc, xloc.bar_index, expandSR ? extend.both :
extend.right, na)
highest_fill2 := line.new(bar_index - 311, highestph - zonePerc,
bar_index, highestph - zonePerc, xloc.bar_index, expandSR ? extend.both :
extend.right, na)
lowest_fill1 := line.new(bar_index - 311, lowestpl + zonePerc ,
bar_index, lowestpl + zonePerc , xloc.bar_index, expandSR ? extend.both :
extend.right, na)
lowest_fill2 := line.new(bar_index - 311, lowestpl - zonePerc ,
bar_index, lowestpl - zonePerc , xloc.bar_index, expandSR ? extend.both :
extend.right, na)
linefill.new(highest_fill1, highest_fill2, color.new(hi_col, 80))
linefill.new(lowest_fill1 , lowest_fill2 , color.new(lo_col,
80))
if ph or pl
for x = 0 to array.size(sr_lines) - 1
//inputs
llength = input(50, title='Band Length')
bd1 = input(9, title='Frontrun Band Deviation')
bd2 = input(11, title='Initial Band Deviation')
bd3 = input(14, title='Final Band Deviation')
//logic
rg = kama(ta.tr, llength)
basis = kama(close,
llength) upper1 = basis + rg
* bd1 upper2 = basis + rg *
bd2 upper3 = basis + rg *
bd3 lower1 = basis - rg *
bd1 lower2 = basis - rg *
bd2 lower3 = basis - rg *
bd3
//ploting
pp1 = plot(show_rev ? upper1 : na,
transp=100) pp2 = plot(show_rev ? upper2
: na,
transp=100) pp3 = plot(show_rev ? upper3
: na,
transp=100) pp4 = plot(show_rev ? lower1 :
na, transp=100) pp5 = plot(show_rev ? lower2
: na,
transp=100) pp6 = plot(show_rev ? lower3 :
na, transp=100) fill(pp1, pp2,
color=color.new(#57202c, 70)) fill(pp2, pp3,
color=color.new(#57202c, 50)) fill(pp4, pp5,
color=color.new(#103c3c, 70)) fill(pp5, pp6,
color=color.new(#103c3c, 50))
// Candle Coloring
// Input
fastLength = input(title="Fast Length",
defval=12) slowLength = input(title="Slow
Length", defval=26) srrrc =
input(title="Source", defval=close)
signalLength = input.int(title="Signal Smoothing", minval = 1, maxval = 50,
defval
= 9)
// Data reference
[macd, signal, hist] = ta.macd(srrrc, fastLength, slowLength, signalLength)
// 4 level of green
greenHigh = #05df09
greenMidHigh = #05df09
greenMidLow = #388E3C
greenLow = #5f3a97
// Yellow
yellowLow = #5f3a97
// 4 level of red
redHigh = #ea0402
redMidHigh =
#ea0402 redMidLow =
#cc0402 redLow =
#5f3a97
// Default color
candleBody = yellowLow
//
if Ranging
hist > 0trend
if hist > hist[1] and hist[1] > 0
candleBody := greenLow
if hist < 0
if hist < hist[1] and hist[1] < 0
candleBody := redLow
// Bullish trend
if macd > 0 and hist > 0
candleBody := greenMidLow
if hist > hist[1] and macd[1] > 0 and hist[1] > 0
candleBody := greenMidHigh
if hist > hist[2] and macd[2] > 0 and hist[2] > 0
candleBody := greenHigh
// Bearish trend
if macd < 0 and hist < 0
candleBody :=
redMidLow
if hist < hist[1] and macd[1] < 0 and hist[1] < 0
candleBody := redMidHigh
if hist < hist[2] and macd[2] < 0 and hist[2] < 0
candleBody := redHigh
barcolor(candleBody) // Include suggestion by Shaheen204